PDF Product Vouchers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
// Export product "Vouchers" class WOE_Product_Vouchers { function __construct() { // add new fields add_filter('woe_get_order_product_fields', function ($fields,$format) { $fields['voucher_number'] = array( 'label' => 'Voucher Number', 'colname' => 'Voucher Number', 'checked' => 1 ); $fields['voucher_value'] = array( 'label' => 'Voucher Value', 'colname' => 'Voucher Value', 'checked' => 1); $fields['voucher_value_incl_tax'] = array( 'label' => 'Voucher Value (+Tax)', 'colname' => 'Voucher Value(+Tax)', 'checked' => 1); $fields['voucher_recipient_name'] = array( 'label' => 'Recipient Name', 'colname' => 'Recipient Name', 'checked' => 1 ); $fields['voucher_message'] = array( 'label' => 'Message', 'colname' => 'Message', 'checked' => 1 ); $fields['voucher_expiration_date'] = array( 'label' => 'Voucher Expiration Date', 'colname' => 'Voucher Expiration Date', 'checked' => 1); return $fields; }, 10, 2); // get voucher for item add_action( "woe_get_order_product_item", function ($item) { $this->voucher = false; $voucher_meta = $item->get_meta( '_voucher_id', true); if( $voucher_meta ) $this->voucher = wc_pdf_product_vouchers_get_voucher( $voucher_meta ); }); // just return fields add_filter('woe_get_order_product_value_voucher_number', function ($value,$order, $item, $product) { if( $this->voucher ) $value = $this->voucher->get_voucher_number(); return $value; }, 10, 4); add_filter('woe_get_order_product_value_voucher_value', function ($value,$order, $item, $product) { if( $this->voucher ) $value = $this->voucher->get_voucher_value(); return $value; }, 10, 4); add_filter('woe_get_order_product_value_voucher_value_incl_tax', function ($value,$order, $item, $product) { if( $this->voucher ) $value = $this->voucher->get_voucher_value_incl_tax(); return $value; }, 10, 4); add_filter('woe_get_order_product_value_voucher_recipient_name', function ($value,$order, $item, $product) { if( $this->voucher ) $value = $this->voucher->get_recipient_name(); return $value; }, 10, 4); add_filter('woe_get_order_product_value_voucher_message', function ($value,$order, $item, $product) { if( $this->voucher ) $value = $this->voucher->get_message(); return $value; }, 10, 4); add_filter('woe_get_order_product_value_voucher_expiration_date', function ($value,$order, $item, $product) { if( $this->voucher ) $value = $this->voucher->get_expiration_date(); return $value; }, 10, 4); } } new WOE_Product_Vouchers(); |