Open dokker opened 4 years ago
Hi @dokker,
Thank you for taking the time to share this idea, we really appreciate your help.
For now, I am going to mark this issue with question
label which means we are going to discuss it further with the WooCommerce Core team to identify what is the best course of action here and if we should implement it at all. There are both pros and cons to doing this.
I can confirm it's buggy when you set taxable = false
, even with the first example. The final fee line would look like this (pulled via REST):
"fee_lines": [
{
"id": 589,
"name": "Custom discount",
"tax_class": "0",
"tax_status": "taxable",
"amount": "100",
"total": "100",
"total_tax": "0",
"taxes": [],
"meta_data": []
}
],
Notice the tax status of "taxable".
@juliaamosova Regarding negative fees. That is already supported for a normal WC_Order
, via $order->add_item( $fee )
where $fee
(WC_Order_Item_Fee
) can be negative without issues.
Support for this, you should be able to use negative numbers for add_fee
@larssn @Sam-Xronn : I seem to have a similar problem with negative fees and taxes, but I might be doing it wrong ?
On the woocommerce_checkout_update_order_meta
hook, I'm manipulating the order to add a WC_Order_Item_Fee
non-taxable with a negative value :
$fee = new WC_Order_Item_Fee();
$fee->set_name('Retour consigne :');
$fee->set_total_tax(0);
$fee->set_tax_class(false);
$fee->set_tax_status('none');
$fee->set_taxes(false);
$fee->set_amount($fee_amount);
$fee->set_total($fee_amount);
$fee->save();
$order->add_item($fee);
And at that point, all looks fine in my order :
Relevant bit
["data":protected]=> array(8) {
["order_id"]=> int(0)
["name"]=> string(17) "Retour consigne :"
["tax_class"]=> bool(false)
["tax_status"]=> string(4) "none"
["amount"]=> string(3) "-10"
["total"]=> string(3) "-10"
["total_tax"]=> string(1) "0"
["taxes"]=> array(1) {
["total"]=> array(0) { }
}
}
``` object(Automattic\WooCommerce\Admin\Overrides\Order)#15635 (15) { ["refunded_line_items":protected]=> NULL ["status_transition":protected]=> bool(false) ["data":protected]=> array(28) { ["parent_id"]=> int(0) ["status"]=> string(7) "pending" ["currency"]=> string(3) "EUR" ["version"]=> string(5) "4.8.0" ["prices_include_tax"]=> bool(true) ["date_created"]=> object(WC_DateTime)#15637 (4) { ["utc_offset":protected]=> int(0) ["date"]=> string(26) "2021-01-17 18:41:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } ["date_modified"]=> object(WC_DateTime)#15644 (4) { ["utc_offset":protected]=> int(0) ["date"]=> string(26) "2021-01-17 18:41:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } ["discount_total"]=> string(4) "9.48" ["discount_tax"]=> string(4) "0.52" ["shipping_total"]=> string(4) "0.00" ["shipping_tax"]=> string(1) "0" ["cart_tax"]=> string(4) "2.74" ["total"]=> string(5) "62.50" ["total_tax"]=> string(4) "2.74" ["customer_id"]=> int(1) ["order_key"]=> string(22) "wc_order_hTMFaHqdR7bUP" ["billing"]=> array(11) { ["first_name"]=> string(8) "Manuella" ["last_name"]=> string(8) "Courtois" ["company"]=> string(0) "" ["address_1"]=> string(26) "15 rue de la porte Gellée" ["address_2"]=> string(0) "" ["city"]=> string(6) "Nantes" ["state"]=> string(0) "" ["postcode"]=> string(5) "44200" ["country"]=> string(0) "" ["email"]=> string(15) "gestion@k-ba.fr" ["phone"]=> string(0) "" } ["shipping"]=> array(9) { ["first_name"]=> string(0) "" ["last_name"]=> string(0) "" ["company"]=> string(0) "" ["address_1"]=> string(0) "" ["address_2"]=> string(0) "" ["city"]=> string(0) "" ["state"]=> string(0) "" ["postcode"]=> string(0) "" ["country"]=> string(0) "" } ["payment_method"]=> string(8) "fake_pay" ["payment_method_title"]=> string(8) "Fake Pay" ["transaction_id"]=> string(0) "" ["customer_ip_address"]=> string(10) "172.18.0.1" ["customer_user_agent"]=> string(121) "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" ["created_via"]=> string(8) "checkout" ["customer_note"]=> string(0) "" ["date_completed"]=> NULL ["date_paid"]=> NULL ["cart_hash"]=> string(32) "1173534728d9ac544c69df1311c927d8" } ["items":protected]=> array(2) { ["coupon_lines"]=> array(0) { } ["fee_lines"]=> array(2) { [456]=> object(WC_Order_Item_Fee)#15587 (11) { ["extra_data":protected]=> array(6) { ["tax_class"]=> string(0) "" ["tax_status"]=> string(7) "taxable" ["amount"]=> string(0) "" ["total"]=> string(0) "" ["total_tax"]=> string(0) "" ["taxes"]=> array(1) { ["total"]=> array(0) { } } } ["data":protected]=> array(8) { ["order_id"]=> int(1506) ["name"]=> string(11) "Consigne : " ["tax_class"]=> string(1) "0" ["tax_status"]=> string(7) "taxable" ["amount"]=> string(2) "10" ["total"]=> string(2) "10" ["total_tax"]=> string(1) "0" ["taxes"]=> array(1) { ["total"]=> array(0) { } } } ["cache_group":protected]=> string(11) "order-items" ["meta_type":protected]=> string(10) "order_item" ["object_type":protected]=> string(10) "order_item" ["id":protected]=> int(456) ["changes":protected]=> array(0) { } ["object_read":protected]=> bool(true) ["default_data":protected]=> array(8) { ["order_id"]=> int(0) ["name"]=> string(0) "" ["tax_class"]=> string(0) "" ["tax_status"]=> string(7) "taxable" ["amount"]=> string(0) "" ["total"]=> string(0) "" ["total_tax"]=> string(0) "" ["taxes"]=> array(1) { ["total"]=> array(0) { } } } ["data_store":protected]=> object(WC_Data_Store)#15684 (4) { ["instance":"WC_Data_Store":private]=> object(WC_Order_Item_Fee_Data_Store)#15660 (4) { ["internal_meta_keys":protected]=> array(16) { [0]=> string(9) "_order_id" [1]=> string(5) "_name" [2]=> string(10) "_tax_class" [3]=> string(11) "_tax_status" [4]=> string(7) "_amount" [5]=> string(6) "_total" [6]=> string(10) "_total_tax" [7]=> string(6) "_taxes" [8]=> string(11) "_fee_amount" [9]=> string(10) "_tax_class" [10]=> string(11) "_tax_status" [11]=> string(14) "_line_subtotal" [12]=> string(18) "_line_subtotal_tax" [13]=> string(11) "_line_total" [14]=> string(9) "_line_tax" [15]=> string(14) "_line_tax_data" } ["meta_type":protected]=> string(10) "order_item" ["object_id_field_for_meta":protected]=> string(13) "order_item_id" ["must_exist_meta_keys":protected]=> array(0) { } } ["stores":"WC_Data_Store":private]=> array(38) { ["coupon"]=> string(24) "WC_Coupon_Data_Store_CPT" ["customer"]=> string(22) "WC_Customer_Data_Store" ["customer-download"]=> string(31) "WC_Customer_Download_Data_Store" ["customer-download-log"]=> string(35) "WC_Customer_Download_Log_Data_Store" ["customer-session"]=> string(30) "WC_Customer_Data_Store_Session" ["order"]=> string(23) "WC_Order_Data_Store_CPT" ["order-refund"]=> string(30) "WC_Order_Refund_Data_Store_CPT" ["order-item"]=> string(24) "WC_Order_Item_Data_Store" ["order-item-coupon"]=> string(31) "WC_Order_Item_Coupon_Data_Store" ["order-item-fee"]=> string(28) "WC_Order_Item_Fee_Data_Store" ["order-item-product"]=> string(32) "WC_Order_Item_Product_Data_Store" ["order-item-shipping"]=> string(33) "WC_Order_Item_Shipping_Data_Store" ["order-item-tax"]=> string(28) "WC_Order_Item_Tax_Data_Store" ["payment-token"]=> string(27) "WC_Payment_Token_Data_Store" ["product"]=> string(25) "WC_Product_Data_Store_CPT" ["product-grouped"]=> string(33) "WC_Product_Grouped_Data_Store_CPT" ["product-variable"]=> string(34) "WC_Product_Variable_Data_Store_CPT" ["product-variation"]=> string(35) "WC_Product_Variation_Data_Store_CPT" ["shipping-zone"]=> string(27) "WC_Shipping_Zone_Data_Store" ["webhook"]=> string(21) "WC_Webhook_Data_Store" ["report-revenue-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-orders"]=> string(57) "Automattic\WooCommerce\Admin\API\Reports\Orders\DataStore" ["report-orders-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-products"]=> string(59) "Automattic\WooCommerce\Admin\API\Reports\Products\DataStore" ["report-variations"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Variations\DataStore" ["report-products-stats"]=> string(65) "Automattic\WooCommerce\Admin\API\Reports\Products\Stats\DataStore" ["report-variations-stats"]=> string(67) "Automattic\WooCommerce\Admin\API\Reports\Variations\Stats\DataStore" ["report-categories"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Categories\DataStore" ["report-taxes"]=> string(56) "Automattic\WooCommerce\Admin\API\Reports\Taxes\DataStore" ["report-taxes-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore" ["report-coupons"]=> string(58) "Automattic\WooCommerce\Admin\API\Reports\Coupons\DataStore" ["report-coupons-stats"]=> string(64) "Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats\DataStore" ["report-downloads"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Downloads\DataStore" ["report-downloads-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Downloads\Stats\DataStore" ["admin-note"]=> string(44) "Automattic\WooCommerce\Admin\Notes\DataStore" ["report-customers"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore" ["report-customers-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Customers\Stats\DataStore" ["report-stock-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Stock\Stats\DataStore" } ["current_class_name":"WC_Data_Store":private]=> string(28) "WC_Order_Item_Fee_Data_Store" ["object_type":"WC_Data_Store":private]=> string(14) "order-item-fee" } ["meta_data":protected]=> array(0) { } } [459]=> object(WC_Order_Item_Fee)#15675 (11) { ["extra_data":protected]=> array(6) { ["tax_class"]=> string(0) "" ["tax_status"]=> string(7) "taxable" ["amount"]=> string(0) "" ["total"]=> string(0) "" ["total_tax"]=> string(0) "" ["taxes"]=> array(1) { ["total"]=> array(0) { } } } ["data":protected]=> array(8) { ["order_id"]=> int(0) ["name"]=> string(17) "Retour consigne :" ["tax_class"]=> bool(false) ["tax_status"]=> string(4) "none" ["amount"]=> string(3) "-10" ["total"]=> string(3) "-10" ["total_tax"]=> string(1) "0" ["taxes"]=> array(1) { ["total"]=> array(0) { } } } ["cache_group":protected]=> string(11) "order-items" ["meta_type":protected]=> string(10) "order_item" ["object_type":protected]=> string(10) "order_item" ["id":protected]=> int(459) ["changes":protected]=> array(1) { ["order_id"]=> int(1506) } ["object_read":protected]=> bool(true) ["default_data":protected]=> array(8) { ["order_id"]=> int(0) ["name"]=> string(0) "" ["tax_class"]=> string(0) "" ["tax_status"]=> string(7) "taxable" ["amount"]=> string(0) "" ["total"]=> string(0) "" ["total_tax"]=> string(0) "" ["taxes"]=> array(1) { ["total"]=> array(0) { } } } ["data_store":protected]=> object(WC_Data_Store)#15681 (4) { ["instance":"WC_Data_Store":private]=> object(WC_Order_Item_Fee_Data_Store)#15682 (4) { ["internal_meta_keys":protected]=> array(8) { [0]=> string(11) "_fee_amount" [1]=> string(10) "_tax_class" [2]=> string(11) "_tax_status" [3]=> string(14) "_line_subtotal" [4]=> string(18) "_line_subtotal_tax" [5]=> string(11) "_line_total" [6]=> string(9) "_line_tax" [7]=> string(14) "_line_tax_data" } ["meta_type":protected]=> string(10) "order_item" ["object_id_field_for_meta":protected]=> string(13) "order_item_id" ["must_exist_meta_keys":protected]=> array(0) { } } ["stores":"WC_Data_Store":private]=> array(38) { ["coupon"]=> string(24) "WC_Coupon_Data_Store_CPT" ["customer"]=> string(22) "WC_Customer_Data_Store" ["customer-download"]=> string(31) "WC_Customer_Download_Data_Store" ["customer-download-log"]=> string(35) "WC_Customer_Download_Log_Data_Store" ["customer-session"]=> string(30) "WC_Customer_Data_Store_Session" ["order"]=> string(23) "WC_Order_Data_Store_CPT" ["order-refund"]=> string(30) "WC_Order_Refund_Data_Store_CPT" ["order-item"]=> string(24) "WC_Order_Item_Data_Store" ["order-item-coupon"]=> string(31) "WC_Order_Item_Coupon_Data_Store" ["order-item-fee"]=> string(28) "WC_Order_Item_Fee_Data_Store" ["order-item-product"]=> string(32) "WC_Order_Item_Product_Data_Store" ["order-item-shipping"]=> string(33) "WC_Order_Item_Shipping_Data_Store" ["order-item-tax"]=> string(28) "WC_Order_Item_Tax_Data_Store" ["payment-token"]=> string(27) "WC_Payment_Token_Data_Store" ["product"]=> string(25) "WC_Product_Data_Store_CPT" ["product-grouped"]=> string(33) "WC_Product_Grouped_Data_Store_CPT" ["product-variable"]=> string(34) "WC_Product_Variable_Data_Store_CPT" ["product-variation"]=> string(35) "WC_Product_Variation_Data_Store_CPT" ["shipping-zone"]=> string(27) "WC_Shipping_Zone_Data_Store" ["webhook"]=> string(21) "WC_Webhook_Data_Store" ["report-revenue-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-orders"]=> string(57) "Automattic\WooCommerce\Admin\API\Reports\Orders\DataStore" ["report-orders-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-products"]=> string(59) "Automattic\WooCommerce\Admin\API\Reports\Products\DataStore" ["report-variations"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Variations\DataStore" ["report-products-stats"]=> string(65) "Automattic\WooCommerce\Admin\API\Reports\Products\Stats\DataStore" ["report-variations-stats"]=> string(67) "Automattic\WooCommerce\Admin\API\Reports\Variations\Stats\DataStore" ["report-categories"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Categories\DataStore" ["report-taxes"]=> string(56) "Automattic\WooCommerce\Admin\API\Reports\Taxes\DataStore" ["report-taxes-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore" ["report-coupons"]=> string(58) "Automattic\WooCommerce\Admin\API\Reports\Coupons\DataStore" ["report-coupons-stats"]=> string(64) "Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats\DataStore" ["report-downloads"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Downloads\DataStore" ["report-downloads-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Downloads\Stats\DataStore" ["admin-note"]=> string(44) "Automattic\WooCommerce\Admin\Notes\DataStore" ["report-customers"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore" ["report-customers-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Customers\Stats\DataStore" ["report-stock-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Stock\Stats\DataStore" } ["current_class_name":"WC_Data_Store":private]=> string(28) "WC_Order_Item_Fee_Data_Store" ["object_type":"WC_Data_Store":private]=> string(14) "order-item-fee" } ["meta_data":protected]=> NULL } } } ["items_to_delete":protected]=> array(1) { [0]=> object(WC_Order_Item_Coupon)#15655 (11) { ["extra_data":protected]=> array(3) { ["code"]=> string(0) "" ["discount"]=> int(0) ["discount_tax"]=> int(0) } ["data":protected]=> array(5) { ["order_id"]=> int(1506) ["name"]=> string(0) "" ["code"]=> string(34) "consigne-manuella-courtois-10-1358" ["discount"]=> string(4) "9.48" ["discount_tax"]=> string(4) "0.52" } ["cache_group":protected]=> string(11) "order-items" ["meta_type":protected]=> string(10) "order_item" ["object_type":protected]=> string(10) "order_item" ["id":protected]=> int(458) ["changes":protected]=> array(0) { } ["object_read":protected]=> bool(true) ["default_data":protected]=> array(5) { ["order_id"]=> int(0) ["name"]=> string(0) "" ["code"]=> string(0) "" ["discount"]=> int(0) ["discount_tax"]=> int(0) } ["data_store":protected]=> object(WC_Data_Store)#15656 (4) { ["instance":"WC_Data_Store":private]=> object(WC_Order_Item_Coupon_Data_Store)#15657 (4) { ["internal_meta_keys":protected]=> array(7) { [0]=> string(9) "_order_id" [1]=> string(5) "_name" [2]=> string(5) "_code" [3]=> string(9) "_discount" [4]=> string(13) "_discount_tax" [5]=> string(15) "discount_amount" [6]=> string(19) "discount_amount_tax" } ["meta_type":protected]=> string(10) "order_item" ["object_id_field_for_meta":protected]=> string(13) "order_item_id" ["must_exist_meta_keys":protected]=> array(0) { } } ["stores":"WC_Data_Store":private]=> array(38) { ["coupon"]=> string(24) "WC_Coupon_Data_Store_CPT" ["customer"]=> string(22) "WC_Customer_Data_Store" ["customer-download"]=> string(31) "WC_Customer_Download_Data_Store" ["customer-download-log"]=> string(35) "WC_Customer_Download_Log_Data_Store" ["customer-session"]=> string(30) "WC_Customer_Data_Store_Session" ["order"]=> string(23) "WC_Order_Data_Store_CPT" ["order-refund"]=> string(30) "WC_Order_Refund_Data_Store_CPT" ["order-item"]=> string(24) "WC_Order_Item_Data_Store" ["order-item-coupon"]=> string(31) "WC_Order_Item_Coupon_Data_Store" ["order-item-fee"]=> string(28) "WC_Order_Item_Fee_Data_Store" ["order-item-product"]=> string(32) "WC_Order_Item_Product_Data_Store" ["order-item-shipping"]=> string(33) "WC_Order_Item_Shipping_Data_Store" ["order-item-tax"]=> string(28) "WC_Order_Item_Tax_Data_Store" ["payment-token"]=> string(27) "WC_Payment_Token_Data_Store" ["product"]=> string(25) "WC_Product_Data_Store_CPT" ["product-grouped"]=> string(33) "WC_Product_Grouped_Data_Store_CPT" ["product-variable"]=> string(34) "WC_Product_Variable_Data_Store_CPT" ["product-variation"]=> string(35) "WC_Product_Variation_Data_Store_CPT" ["shipping-zone"]=> string(27) "WC_Shipping_Zone_Data_Store" ["webhook"]=> string(21) "WC_Webhook_Data_Store" ["report-revenue-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-orders"]=> string(57) "Automattic\WooCommerce\Admin\API\Reports\Orders\DataStore" ["report-orders-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-products"]=> string(59) "Automattic\WooCommerce\Admin\API\Reports\Products\DataStore" ["report-variations"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Variations\DataStore" ["report-products-stats"]=> string(65) "Automattic\WooCommerce\Admin\API\Reports\Products\Stats\DataStore" ["report-variations-stats"]=> string(67) "Automattic\WooCommerce\Admin\API\Reports\Variations\Stats\DataStore" ["report-categories"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Categories\DataStore" ["report-taxes"]=> string(56) "Automattic\WooCommerce\Admin\API\Reports\Taxes\DataStore" ["report-taxes-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore" ["report-coupons"]=> string(58) "Automattic\WooCommerce\Admin\API\Reports\Coupons\DataStore" ["report-coupons-stats"]=> string(64) "Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats\DataStore" ["report-downloads"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Downloads\DataStore" ["report-downloads-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Downloads\Stats\DataStore" ["admin-note"]=> string(44) "Automattic\WooCommerce\Admin\Notes\DataStore" ["report-customers"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore" ["report-customers-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Customers\Stats\DataStore" ["report-stock-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Stock\Stats\DataStore" } ["current_class_name":"WC_Data_Store":private]=> string(31) "WC_Order_Item_Coupon_Data_Store" ["object_type":"WC_Data_Store":private]=> string(17) "order-item-coupon" } ["meta_data":protected]=> array(1) { [0]=> object(WC_Meta_Data)#15662 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(3066) ["key"]=> string(11) "coupon_data" ["value"]=> array(24) { ["id"]=> int(1505) ["code"]=> string(34) "consigne-manuella-courtois-10-1358" ["amount"]=> string(2) "10" ["date_created"]=> object(WC_DateTime)#15663 (4) { ["utc_offset":protected]=> int(0) ["date"]=> string(26) "2021-01-17 18:40:22.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } ["date_modified"]=> object(WC_DateTime)#15664 (4) { ["utc_offset":protected]=> int(0) ["date"]=> string(26) "2021-01-17 18:40:22.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } ["date_expires"]=> NULL ["discount_type"]=> string(10) "fixed_cart" ["description"]=> string(0) "" ["usage_count"]=> int(0) ["individual_use"]=> bool(false) ["product_ids"]=> array(0) { } ["excluded_product_ids"]=> array(0) { } ["usage_limit"]=> int(1) ["usage_limit_per_user"]=> int(1) ["limit_usage_to_x_items"]=> NULL ["free_shipping"]=> bool(false) ["product_categories"]=> array(0) { } ["excluded_product_categories"]=> array(0) { } ["exclude_sale_items"]=> bool(false) ["minimum_amount"]=> string(0) "" ["maximum_amount"]=> string(0) "" ["email_restrictions"]=> array(0) { } ["virtual"]=> bool(false) ["meta_data"]=> array(4) { [0]=> object(WC_Meta_Data)#15665 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(13788) ["key"]=> string(16) "apply_before_tax" ["value"]=> string(2) "no" } ["data":protected]=> array(3) { ["id"]=> int(13788) ["key"]=> string(16) "apply_before_tax" ["value"]=> string(2) "no" } } [1]=> object(WC_Meta_Data)#15666 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(13789) ["key"]=> string(18) "email_restrictions" ["value"]=> array(1) { [0]=> string(15) "gestion@k-ba.fr" } } ["data":protected]=> array(3) { ["id"]=> int(13789) ["key"]=> string(18) "email_restrictions" ["value"]=> array(1) { [0]=> string(15) "gestion@k-ba.fr" } } } [2]=> object(WC_Meta_Data)#15667 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(13795) ["key"]=> string(30) "_coupon_held_1610908863_fdtgkb" ["value"]=> string(0) "" } ["data":protected]=> array(3) { ["id"]=> int(13795) ["key"]=> string(30) "_coupon_held_1610908863_fdtgkb" ["value"]=> string(0) "" } } [3]=> object(WC_Meta_Data)#15668 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(13796) ["key"]=> string(32) "_maybe_used_by_1610908863_XQBba0" ["value"]=> string(1) "1" } ["data":protected]=> array(3) { ["id"]=> int(13796) ["key"]=> string(32) "_maybe_used_by_1610908863_XQBba0" ["value"]=> string(1) "1" } } } } } ["data":protected]=> array(3) { ["id"]=> int(3066) ["key"]=> string(11) "coupon_data" ["value"]=> array(24) { ["id"]=> int(1505) ["code"]=> string(34) "consigne-manuella-courtois-10-1358" ["amount"]=> string(2) "10" ["date_created"]=> object(WC_DateTime)#15663 (4) { ["utc_offset":protected]=> int(0) ["date"]=> string(26) "2021-01-17 18:40:22.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } ["date_modified"]=> object(WC_DateTime)#15664 (4) { ["utc_offset":protected]=> int(0) ["date"]=> string(26) "2021-01-17 18:40:22.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } ["date_expires"]=> NULL ["discount_type"]=> string(10) "fixed_cart" ["description"]=> string(0) "" ["usage_count"]=> int(0) ["individual_use"]=> bool(false) ["product_ids"]=> array(0) { } ["excluded_product_ids"]=> array(0) { } ["usage_limit"]=> int(1) ["usage_limit_per_user"]=> int(1) ["limit_usage_to_x_items"]=> NULL ["free_shipping"]=> bool(false) ["product_categories"]=> array(0) { } ["excluded_product_categories"]=> array(0) { } ["exclude_sale_items"]=> bool(false) ["minimum_amount"]=> string(0) "" ["maximum_amount"]=> string(0) "" ["email_restrictions"]=> array(0) { } ["virtual"]=> bool(false) ["meta_data"]=> array(4) { [0]=> object(WC_Meta_Data)#15665 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(13788) ["key"]=> string(16) "apply_before_tax" ["value"]=> string(2) "no" } ["data":protected]=> array(3) { ["id"]=> int(13788) ["key"]=> string(16) "apply_before_tax" ["value"]=> string(2) "no" } } [1]=> object(WC_Meta_Data)#15666 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(13789) ["key"]=> string(18) "email_restrictions" ["value"]=> array(1) { [0]=> string(15) "gestion@k-ba.fr" } } ["data":protected]=> array(3) { ["id"]=> int(13789) ["key"]=> string(18) "email_restrictions" ["value"]=> array(1) { [0]=> string(15) "gestion@k-ba.fr" } } } [2]=> object(WC_Meta_Data)#15667 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(13795) ["key"]=> string(30) "_coupon_held_1610908863_fdtgkb" ["value"]=> string(0) "" } ["data":protected]=> array(3) { ["id"]=> int(13795) ["key"]=> string(30) "_coupon_held_1610908863_fdtgkb" ["value"]=> string(0) "" } } [3]=> object(WC_Meta_Data)#15668 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(13796) ["key"]=> string(32) "_maybe_used_by_1610908863_XQBba0" ["value"]=> string(1) "1" } ["data":protected]=> array(3) { ["id"]=> int(13796) ["key"]=> string(32) "_maybe_used_by_1610908863_XQBba0" ["value"]=> string(1) "1" } } } } } } } } } ["cache_group":protected]=> string(6) "orders" ["data_store_name":protected]=> string(5) "order" ["object_type":protected]=> string(5) "order" ["id":protected]=> int(1506) ["changes":protected]=> array(0) { } ["object_read":protected]=> bool(true) ["extra_data":protected]=> array(0) { } ["default_data":protected]=> array(28) { ["parent_id"]=> int(0) ["status"]=> string(0) "" ["currency"]=> string(0) "" ["version"]=> string(0) "" ["prices_include_tax"]=> bool(false) ["date_created"]=> NULL ["date_modified"]=> NULL ["discount_total"]=> int(0) ["discount_tax"]=> int(0) ["shipping_total"]=> int(0) ["shipping_tax"]=> int(0) ["cart_tax"]=> int(0) ["total"]=> int(0) ["total_tax"]=> int(0) ["customer_id"]=> int(0) ["order_key"]=> string(0) "" ["billing"]=> array(11) { ["first_name"]=> string(0) "" ["last_name"]=> string(0) "" ["company"]=> string(0) "" ["address_1"]=> string(0) "" ["address_2"]=> string(0) "" ["city"]=> string(0) "" ["state"]=> string(0) "" ["postcode"]=> string(0) "" ["country"]=> string(0) "" ["email"]=> string(0) "" ["phone"]=> string(0) "" } ["shipping"]=> array(9) { ["first_name"]=> string(0) "" ["last_name"]=> string(0) "" ["company"]=> string(0) "" ["address_1"]=> string(0) "" ["address_2"]=> string(0) "" ["city"]=> string(0) "" ["state"]=> string(0) "" ["postcode"]=> string(0) "" ["country"]=> string(0) "" } ["payment_method"]=> string(0) "" ["payment_method_title"]=> string(0) "" ["transaction_id"]=> string(0) "" ["customer_ip_address"]=> string(0) "" ["customer_user_agent"]=> string(0) "" ["created_via"]=> string(0) "" ["customer_note"]=> string(0) "" ["date_completed"]=> NULL ["date_paid"]=> NULL ["cart_hash"]=> string(0) "" } ["data_store":protected]=> object(WC_Data_Store)#15643 (4) { ["instance":"WC_Data_Store":private]=> object(WC_Order_Data_Store_CPT)#15581 (4) { ["internal_meta_keys":protected]=> array(78) { [0]=> string(10) "_parent_id" [1]=> string(7) "_status" [2]=> string(9) "_currency" [3]=> string(8) "_version" [4]=> string(19) "_prices_include_tax" [5]=> string(13) "_date_created" [6]=> string(14) "_date_modified" [7]=> string(15) "_discount_total" [8]=> string(13) "_discount_tax" [9]=> string(15) "_shipping_total" [10]=> string(13) "_shipping_tax" [11]=> string(9) "_cart_tax" [12]=> string(6) "_total" [13]=> string(10) "_total_tax" [14]=> string(12) "_customer_id" [15]=> string(10) "_order_key" [16]=> string(8) "_billing" [17]=> string(9) "_shipping" [18]=> string(15) "_payment_method" [19]=> string(21) "_payment_method_title" [20]=> string(15) "_transaction_id" [21]=> string(20) "_customer_ip_address" [22]=> string(20) "_customer_user_agent" [23]=> string(12) "_created_via" [24]=> string(14) "_customer_note" [25]=> string(15) "_date_completed" [26]=> string(10) "_date_paid" [27]=> string(10) "_cart_hash" [28]=> string(14) "_customer_user" [29]=> string(10) "_order_key" [30]=> string(15) "_order_currency" [31]=> string(19) "_billing_first_name" [32]=> string(18) "_billing_last_name" [33]=> string(16) "_billing_company" [34]=> string(18) "_billing_address_1" [35]=> string(18) "_billing_address_2" [36]=> string(13) "_billing_city" [37]=> string(14) "_billing_state" [38]=> string(17) "_billing_postcode" [39]=> string(16) "_billing_country" [40]=> string(14) "_billing_email" [41]=> string(14) "_billing_phone" [42]=> string(20) "_shipping_first_name" [43]=> string(19) "_shipping_last_name" [44]=> string(17) "_shipping_company" [45]=> string(19) "_shipping_address_1" [46]=> string(19) "_shipping_address_2" [47]=> string(14) "_shipping_city" [48]=> string(15) "_shipping_state" [49]=> string(18) "_shipping_postcode" [50]=> string(17) "_shipping_country" [51]=> string(15) "_completed_date" [52]=> string(10) "_paid_date" [53]=> string(10) "_edit_lock" [54]=> string(10) "_edit_last" [55]=> string(14) "_cart_discount" [56]=> string(18) "_cart_discount_tax" [57]=> string(15) "_order_shipping" [58]=> string(19) "_order_shipping_tax" [59]=> string(10) "_order_tax" [60]=> string(12) "_order_total" [61]=> string(15) "_payment_method" [62]=> string(21) "_payment_method_title" [63]=> string(15) "_transaction_id" [64]=> string(20) "_customer_ip_address" [65]=> string(20) "_customer_user_agent" [66]=> string(12) "_created_via" [67]=> string(14) "_order_version" [68]=> string(19) "_prices_include_tax" [69]=> string(15) "_date_completed" [70]=> string(10) "_date_paid" [71]=> string(15) "_payment_tokens" [72]=> string(22) "_billing_address_index" [73]=> string(23) "_shipping_address_index" [74]=> string(15) "_recorded_sales" [75]=> string(29) "_recorded_coupon_usage_counts" [76]=> string(29) "_download_permissions_granted" [77]=> string(20) "_order_stock_reduced" } ["meta_type":protected]=> string(4) "post" ["object_id_field_for_meta":protected]=> string(0) "" ["must_exist_meta_keys":protected]=> array(0) { } } ["stores":"WC_Data_Store":private]=> array(38) { ["coupon"]=> string(24) "WC_Coupon_Data_Store_CPT" ["customer"]=> string(22) "WC_Customer_Data_Store" ["customer-download"]=> string(31) "WC_Customer_Download_Data_Store" ["customer-download-log"]=> string(35) "WC_Customer_Download_Log_Data_Store" ["customer-session"]=> string(30) "WC_Customer_Data_Store_Session" ["order"]=> string(23) "WC_Order_Data_Store_CPT" ["order-refund"]=> string(30) "WC_Order_Refund_Data_Store_CPT" ["order-item"]=> string(24) "WC_Order_Item_Data_Store" ["order-item-coupon"]=> string(31) "WC_Order_Item_Coupon_Data_Store" ["order-item-fee"]=> string(28) "WC_Order_Item_Fee_Data_Store" ["order-item-product"]=> string(32) "WC_Order_Item_Product_Data_Store" ["order-item-shipping"]=> string(33) "WC_Order_Item_Shipping_Data_Store" ["order-item-tax"]=> string(28) "WC_Order_Item_Tax_Data_Store" ["payment-token"]=> string(27) "WC_Payment_Token_Data_Store" ["product"]=> string(25) "WC_Product_Data_Store_CPT" ["product-grouped"]=> string(33) "WC_Product_Grouped_Data_Store_CPT" ["product-variable"]=> string(34) "WC_Product_Variable_Data_Store_CPT" ["product-variation"]=> string(35) "WC_Product_Variation_Data_Store_CPT" ["shipping-zone"]=> string(27) "WC_Shipping_Zone_Data_Store" ["webhook"]=> string(21) "WC_Webhook_Data_Store" ["report-revenue-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-orders"]=> string(57) "Automattic\WooCommerce\Admin\API\Reports\Orders\DataStore" ["report-orders-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-products"]=> string(59) "Automattic\WooCommerce\Admin\API\Reports\Products\DataStore" ["report-variations"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Variations\DataStore" ["report-products-stats"]=> string(65) "Automattic\WooCommerce\Admin\API\Reports\Products\Stats\DataStore" ["report-variations-stats"]=> string(67) "Automattic\WooCommerce\Admin\API\Reports\Variations\Stats\DataStore" ["report-categories"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Categories\DataStore" ["report-taxes"]=> string(56) "Automattic\WooCommerce\Admin\API\Reports\Taxes\DataStore" ["report-taxes-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore" ["report-coupons"]=> string(58) "Automattic\WooCommerce\Admin\API\Reports\Coupons\DataStore" ["report-coupons-stats"]=> string(64) "Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats\DataStore" ["report-downloads"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Downloads\DataStore" ["report-downloads-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Downloads\Stats\DataStore" ["admin-note"]=> string(44) "Automattic\WooCommerce\Admin\Notes\DataStore" ["report-customers"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore" ["report-customers-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Customers\Stats\DataStore" ["report-stock-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Stock\Stats\DataStore" } ["current_class_name":"WC_Data_Store":private]=> string(23) "WC_Order_Data_Store_CPT" ["object_type":"WC_Data_Store":private]=> string(5) "order" } ["meta_data":protected]=> array(3) { [0]=> object(WC_Meta_Data)#15672 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(13822) ["key"]=> string(17) "_coupon_held_keys" ["value"]=> array(1) { [1505]=> string(30) "_coupon_held_1610908863_fdtgkb" } } ["data":protected]=> array(3) { ["id"]=> int(13822) ["key"]=> string(17) "_coupon_held_keys" ["value"]=> array(1) { [1505]=> string(30) "_coupon_held_1610908863_fdtgkb" } } } [1]=> object(WC_Meta_Data)#15673 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(13823) ["key"]=> string(27) "_coupon_held_keys_for_users" ["value"]=> array(1) { [1505]=> string(32) "_maybe_used_by_1610908863_XQBba0" } } ["data":protected]=> array(3) { ["id"]=> int(13823) ["key"]=> string(27) "_coupon_held_keys_for_users" ["value"]=> array(1) { [1505]=> string(32) "_maybe_used_by_1610908863_XQBba0" } } } [2]=> object(WC_Meta_Data)#15674 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(13824) ["key"]=> string(13) "is_vat_exempt" ["value"]=> string(2) "no" } ["data":protected]=> array(3) { ["id"]=> int(13824) ["key"]=> string(13) "is_vat_exempt" ["value"]=> string(2) "no" } } } } ```
But after that, I do :
$order->recalculate_coupons();
$order->calculate_totals();
$order->save();
To "apply" the item and after that the taxes are calculated weirdly again :
Relevant bit
["data":protected]=> array(8) {
["order_id"]=> int(1506)
["name"]=> string(17) "Retour consigne :"
["tax_class"]=> bool(false)
["tax_status"]=> string(4) "none"
["amount"]=> string(3) "-10"
["total"]=> string(3) "-10"
["total_tax"]=> string(5) "-0.47"
["taxes"]=> array(1) {
["total"]=> array(1) {
[5]=> string(9) "-0.470568"
}
}
}
``` object(Automattic\WooCommerce\Admin\Overrides\Order)#15635 (15) { ["refunded_line_items":protected]=> NULL ["status_transition":protected]=> bool(false) ["data":protected]=> array(28) { ["parent_id"]=> int(0) ["status"]=> string(7) "pending" ["currency"]=> string(3) "EUR" ["version"]=> string(5) "4.8.0" ["prices_include_tax"]=> bool(true) ["date_created"]=> object(WC_DateTime)#15637 (4) { ["utc_offset":protected]=> int(0) ["date"]=> string(26) "2021-01-17 18:41:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } ["date_modified"]=> object(WC_DateTime)#15644 (4) { ["utc_offset":protected]=> int(0) ["date"]=> string(26) "2021-01-17 18:41:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } ["discount_total"]=> string(1) "0" ["discount_tax"]=> string(1) "0" ["shipping_total"]=> string(1) "0" ["shipping_tax"]=> string(1) "0" ["cart_tax"]=> string(4) "2.79" ["total"]=> string(5) "62.03" ["total_tax"]=> string(4) "2.79" ["customer_id"]=> int(1) ["order_key"]=> string(22) "wc_order_hTMFaHqdR7bUP" ["billing"]=> array(11) { ["first_name"]=> string(8) "Manuella" ["last_name"]=> string(8) "Courtois" ["company"]=> string(0) "" ["address_1"]=> string(26) "15 rue de la porte Gellée" ["address_2"]=> string(0) "" ["city"]=> string(6) "Nantes" ["state"]=> string(0) "" ["postcode"]=> string(5) "44200" ["country"]=> string(0) "" ["email"]=> string(15) "gestion@k-ba.fr" ["phone"]=> string(0) "" } ["shipping"]=> array(9) { ["first_name"]=> string(0) "" ["last_name"]=> string(0) "" ["company"]=> string(0) "" ["address_1"]=> string(0) "" ["address_2"]=> string(0) "" ["city"]=> string(0) "" ["state"]=> string(0) "" ["postcode"]=> string(0) "" ["country"]=> string(0) "" } ["payment_method"]=> string(8) "fake_pay" ["payment_method_title"]=> string(8) "Fake Pay" ["transaction_id"]=> string(0) "" ["customer_ip_address"]=> string(10) "172.18.0.1" ["customer_user_agent"]=> string(121) "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" ["created_via"]=> string(8) "checkout" ["customer_note"]=> string(0) "" ["date_completed"]=> NULL ["date_paid"]=> NULL ["cart_hash"]=> string(32) "1173534728d9ac544c69df1311c927d8" } ["items":protected]=> array(5) { ["coupon_lines"]=> array(0) { } ["fee_lines"]=> array(2) { [456]=> object(WC_Order_Item_Fee)#15587 (11) { ["extra_data":protected]=> array(6) { ["tax_class"]=> string(0) "" ["tax_status"]=> string(7) "taxable" ["amount"]=> string(0) "" ["total"]=> string(0) "" ["total_tax"]=> string(0) "" ["taxes"]=> array(1) { ["total"]=> array(0) { } } } ["data":protected]=> array(8) { ["order_id"]=> int(1506) ["name"]=> string(11) "Consigne : " ["tax_class"]=> string(1) "0" ["tax_status"]=> string(7) "taxable" ["amount"]=> string(2) "10" ["total"]=> string(2) "10" ["total_tax"]=> string(1) "0" ["taxes"]=> array(1) { ["total"]=> array(0) { } } } ["cache_group":protected]=> string(11) "order-items" ["meta_type":protected]=> string(10) "order_item" ["object_type":protected]=> string(10) "order_item" ["id":protected]=> int(456) ["changes":protected]=> array(0) { } ["object_read":protected]=> bool(true) ["default_data":protected]=> array(8) { ["order_id"]=> int(0) ["name"]=> string(0) "" ["tax_class"]=> string(0) "" ["tax_status"]=> string(7) "taxable" ["amount"]=> string(0) "" ["total"]=> string(0) "" ["total_tax"]=> string(0) "" ["taxes"]=> array(1) { ["total"]=> array(0) { } } } ["data_store":protected]=> object(WC_Data_Store)#15684 (4) { ["instance":"WC_Data_Store":private]=> object(WC_Order_Item_Fee_Data_Store)#15660 (4) { ["internal_meta_keys":protected]=> array(16) { [0]=> string(9) "_order_id" [1]=> string(5) "_name" [2]=> string(10) "_tax_class" [3]=> string(11) "_tax_status" [4]=> string(7) "_amount" [5]=> string(6) "_total" [6]=> string(10) "_total_tax" [7]=> string(6) "_taxes" [8]=> string(11) "_fee_amount" [9]=> string(10) "_tax_class" [10]=> string(11) "_tax_status" [11]=> string(14) "_line_subtotal" [12]=> string(18) "_line_subtotal_tax" [13]=> string(11) "_line_total" [14]=> string(9) "_line_tax" [15]=> string(14) "_line_tax_data" } ["meta_type":protected]=> string(10) "order_item" ["object_id_field_for_meta":protected]=> string(13) "order_item_id" ["must_exist_meta_keys":protected]=> array(0) { } } ["stores":"WC_Data_Store":private]=> array(38) { ["coupon"]=> string(24) "WC_Coupon_Data_Store_CPT" ["customer"]=> string(22) "WC_Customer_Data_Store" ["customer-download"]=> string(31) "WC_Customer_Download_Data_Store" ["customer-download-log"]=> string(35) "WC_Customer_Download_Log_Data_Store" ["customer-session"]=> string(30) "WC_Customer_Data_Store_Session" ["order"]=> string(23) "WC_Order_Data_Store_CPT" ["order-refund"]=> string(30) "WC_Order_Refund_Data_Store_CPT" ["order-item"]=> string(24) "WC_Order_Item_Data_Store" ["order-item-coupon"]=> string(31) "WC_Order_Item_Coupon_Data_Store" ["order-item-fee"]=> string(28) "WC_Order_Item_Fee_Data_Store" ["order-item-product"]=> string(32) "WC_Order_Item_Product_Data_Store" ["order-item-shipping"]=> string(33) "WC_Order_Item_Shipping_Data_Store" ["order-item-tax"]=> string(28) "WC_Order_Item_Tax_Data_Store" ["payment-token"]=> string(27) "WC_Payment_Token_Data_Store" ["product"]=> string(25) "WC_Product_Data_Store_CPT" ["product-grouped"]=> string(33) "WC_Product_Grouped_Data_Store_CPT" ["product-variable"]=> string(34) "WC_Product_Variable_Data_Store_CPT" ["product-variation"]=> string(35) "WC_Product_Variation_Data_Store_CPT" ["shipping-zone"]=> string(27) "WC_Shipping_Zone_Data_Store" ["webhook"]=> string(21) "WC_Webhook_Data_Store" ["report-revenue-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-orders"]=> string(57) "Automattic\WooCommerce\Admin\API\Reports\Orders\DataStore" ["report-orders-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-products"]=> string(59) "Automattic\WooCommerce\Admin\API\Reports\Products\DataStore" ["report-variations"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Variations\DataStore" ["report-products-stats"]=> string(65) "Automattic\WooCommerce\Admin\API\Reports\Products\Stats\DataStore" ["report-variations-stats"]=> string(67) "Automattic\WooCommerce\Admin\API\Reports\Variations\Stats\DataStore" ["report-categories"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Categories\DataStore" ["report-taxes"]=> string(56) "Automattic\WooCommerce\Admin\API\Reports\Taxes\DataStore" ["report-taxes-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore" ["report-coupons"]=> string(58) "Automattic\WooCommerce\Admin\API\Reports\Coupons\DataStore" ["report-coupons-stats"]=> string(64) "Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats\DataStore" ["report-downloads"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Downloads\DataStore" ["report-downloads-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Downloads\Stats\DataStore" ["admin-note"]=> string(44) "Automattic\WooCommerce\Admin\Notes\DataStore" ["report-customers"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore" ["report-customers-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Customers\Stats\DataStore" ["report-stock-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Stock\Stats\DataStore" } ["current_class_name":"WC_Data_Store":private]=> string(28) "WC_Order_Item_Fee_Data_Store" ["object_type":"WC_Data_Store":private]=> string(14) "order-item-fee" } ["meta_data":protected]=> array(0) { } } [459]=> object(WC_Order_Item_Fee)#15675 (11) { ["extra_data":protected]=> array(6) { ["tax_class"]=> string(0) "" ["tax_status"]=> string(7) "taxable" ["amount"]=> string(0) "" ["total"]=> string(0) "" ["total_tax"]=> string(0) "" ["taxes"]=> array(1) { ["total"]=> array(0) { } } } ["data":protected]=> array(8) { ["order_id"]=> int(1506) ["name"]=> string(17) "Retour consigne :" ["tax_class"]=> bool(false) ["tax_status"]=> string(4) "none" ["amount"]=> string(3) "-10" ["total"]=> string(3) "-10" ["total_tax"]=> string(5) "-0.47" ["taxes"]=> array(1) { ["total"]=> array(1) { [5]=> string(9) "-0.470568" } } } ["cache_group":protected]=> string(11) "order-items" ["meta_type":protected]=> string(10) "order_item" ["object_type":protected]=> string(10) "order_item" ["id":protected]=> int(459) ["changes":protected]=> array(0) { } ["object_read":protected]=> bool(true) ["default_data":protected]=> array(8) { ["order_id"]=> int(0) ["name"]=> string(0) "" ["tax_class"]=> string(0) "" ["tax_status"]=> string(7) "taxable" ["amount"]=> string(0) "" ["total"]=> string(0) "" ["total_tax"]=> string(0) "" ["taxes"]=> array(1) { ["total"]=> array(0) { } } } ["data_store":protected]=> object(WC_Data_Store)#15681 (4) { ["instance":"WC_Data_Store":private]=> object(WC_Order_Item_Fee_Data_Store)#15682 (4) { ["internal_meta_keys":protected]=> array(8) { [0]=> string(11) "_fee_amount" [1]=> string(10) "_tax_class" [2]=> string(11) "_tax_status" [3]=> string(14) "_line_subtotal" [4]=> string(18) "_line_subtotal_tax" [5]=> string(11) "_line_total" [6]=> string(9) "_line_tax" [7]=> string(14) "_line_tax_data" } ["meta_type":protected]=> string(10) "order_item" ["object_id_field_for_meta":protected]=> string(13) "order_item_id" ["must_exist_meta_keys":protected]=> array(0) { } } ["stores":"WC_Data_Store":private]=> array(38) { ["coupon"]=> string(24) "WC_Coupon_Data_Store_CPT" ["customer"]=> string(22) "WC_Customer_Data_Store" ["customer-download"]=> string(31) "WC_Customer_Download_Data_Store" ["customer-download-log"]=> string(35) "WC_Customer_Download_Log_Data_Store" ["customer-session"]=> string(30) "WC_Customer_Data_Store_Session" ["order"]=> string(23) "WC_Order_Data_Store_CPT" ["order-refund"]=> string(30) "WC_Order_Refund_Data_Store_CPT" ["order-item"]=> string(24) "WC_Order_Item_Data_Store" ["order-item-coupon"]=> string(31) "WC_Order_Item_Coupon_Data_Store" ["order-item-fee"]=> string(28) "WC_Order_Item_Fee_Data_Store" ["order-item-product"]=> string(32) "WC_Order_Item_Product_Data_Store" ["order-item-shipping"]=> string(33) "WC_Order_Item_Shipping_Data_Store" ["order-item-tax"]=> string(28) "WC_Order_Item_Tax_Data_Store" ["payment-token"]=> string(27) "WC_Payment_Token_Data_Store" ["product"]=> string(25) "WC_Product_Data_Store_CPT" ["product-grouped"]=> string(33) "WC_Product_Grouped_Data_Store_CPT" ["product-variable"]=> string(34) "WC_Product_Variable_Data_Store_CPT" ["product-variation"]=> string(35) "WC_Product_Variation_Data_Store_CPT" ["shipping-zone"]=> string(27) "WC_Shipping_Zone_Data_Store" ["webhook"]=> string(21) "WC_Webhook_Data_Store" ["report-revenue-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-orders"]=> string(57) "Automattic\WooCommerce\Admin\API\Reports\Orders\DataStore" ["report-orders-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-products"]=> string(59) "Automattic\WooCommerce\Admin\API\Reports\Products\DataStore" ["report-variations"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Variations\DataStore" ["report-products-stats"]=> string(65) "Automattic\WooCommerce\Admin\API\Reports\Products\Stats\DataStore" ["report-variations-stats"]=> string(67) "Automattic\WooCommerce\Admin\API\Reports\Variations\Stats\DataStore" ["report-categories"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Categories\DataStore" ["report-taxes"]=> string(56) "Automattic\WooCommerce\Admin\API\Reports\Taxes\DataStore" ["report-taxes-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore" ["report-coupons"]=> string(58) "Automattic\WooCommerce\Admin\API\Reports\Coupons\DataStore" ["report-coupons-stats"]=> string(64) "Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats\DataStore" ["report-downloads"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Downloads\DataStore" ["report-downloads-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Downloads\Stats\DataStore" ["admin-note"]=> string(44) "Automattic\WooCommerce\Admin\Notes\DataStore" ["report-customers"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore" ["report-customers-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Customers\Stats\DataStore" ["report-stock-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Stock\Stats\DataStore" } ["current_class_name":"WC_Data_Store":private]=> string(28) "WC_Order_Item_Fee_Data_Store" ["object_type":"WC_Data_Store":private]=> string(14) "order-item-fee" } ["meta_data":protected]=> NULL } } ["line_items"]=> array(1) { [455]=> object(WC_Order_Item_Product)#15658 (11) { ["extra_data":protected]=> array(9) { ["product_id"]=> int(0) ["variation_id"]=> int(0) ["quantity"]=> int(1) ["tax_class"]=> string(0) "" ["subtotal"]=> int(0) ["subtotal_tax"]=> int(0) ["total"]=> int(0) ["total_tax"]=> int(0) ["taxes"]=> array(2) { ["subtotal"]=> array(0) { } ["total"]=> array(0) { } } } ["data":protected]=> array(11) { ["order_id"]=> int(1506) ["name"]=> string(45) "Biscuits bretons chocolat et fleur de sel - M" ["product_id"]=> int(1004) ["variation_id"]=> int(1006) ["quantity"]=> int(10) ["tax_class"]=> string(2) "55" ["subtotal"]=> string(9) "59.241706" ["subtotal_tax"]=> string(4) "3.26" ["total"]=> string(9) "59.241706" ["total_tax"]=> string(4) "3.26" ["taxes"]=> array(2) { ["total"]=> array(1) { [5]=> string(8) "3.258294" } ["subtotal"]=> array(1) { [5]=> string(8) "3.258294" } } } ["cache_group":protected]=> string(11) "order-items" ["meta_type":protected]=> string(10) "order_item" ["object_type":protected]=> string(10) "order_item" ["id":protected]=> int(455) ["changes":protected]=> array(0) { } ["object_read":protected]=> bool(true) ["default_data":protected]=> array(11) { ["order_id"]=> int(0) ["name"]=> string(0) "" ["product_id"]=> int(0) ["variation_id"]=> int(0) ["quantity"]=> int(1) ["tax_class"]=> string(0) "" ["subtotal"]=> int(0) ["subtotal_tax"]=> int(0) ["total"]=> int(0) ["total_tax"]=> int(0) ["taxes"]=> array(2) { ["subtotal"]=> array(0) { } ["total"]=> array(0) { } } } ["data_store":protected]=> object(WC_Data_Store)#15690 (4) { ["instance":"WC_Data_Store":private]=> object(WC_Order_Item_Product_Data_Store)#15691 (4) { ["internal_meta_keys":protected]=> array(20) { [0]=> string(9) "_order_id" [1]=> string(5) "_name" [2]=> string(11) "_product_id" [3]=> string(13) "_variation_id" [4]=> string(9) "_quantity" [5]=> string(10) "_tax_class" [6]=> string(9) "_subtotal" [7]=> string(13) "_subtotal_tax" [8]=> string(6) "_total" [9]=> string(10) "_total_tax" [10]=> string(6) "_taxes" [11]=> string(11) "_product_id" [12]=> string(13) "_variation_id" [13]=> string(4) "_qty" [14]=> string(10) "_tax_class" [15]=> string(14) "_line_subtotal" [16]=> string(18) "_line_subtotal_tax" [17]=> string(11) "_line_total" [18]=> string(9) "_line_tax" [19]=> string(14) "_line_tax_data" } ["meta_type":protected]=> string(10) "order_item" ["object_id_field_for_meta":protected]=> string(13) "order_item_id" ["must_exist_meta_keys":protected]=> array(0) { } } ["stores":"WC_Data_Store":private]=> array(38) { ["coupon"]=> string(24) "WC_Coupon_Data_Store_CPT" ["customer"]=> string(22) "WC_Customer_Data_Store" ["customer-download"]=> string(31) "WC_Customer_Download_Data_Store" ["customer-download-log"]=> string(35) "WC_Customer_Download_Log_Data_Store" ["customer-session"]=> string(30) "WC_Customer_Data_Store_Session" ["order"]=> string(23) "WC_Order_Data_Store_CPT" ["order-refund"]=> string(30) "WC_Order_Refund_Data_Store_CPT" ["order-item"]=> string(24) "WC_Order_Item_Data_Store" ["order-item-coupon"]=> string(31) "WC_Order_Item_Coupon_Data_Store" ["order-item-fee"]=> string(28) "WC_Order_Item_Fee_Data_Store" ["order-item-product"]=> string(32) "WC_Order_Item_Product_Data_Store" ["order-item-shipping"]=> string(33) "WC_Order_Item_Shipping_Data_Store" ["order-item-tax"]=> string(28) "WC_Order_Item_Tax_Data_Store" ["payment-token"]=> string(27) "WC_Payment_Token_Data_Store" ["product"]=> string(25) "WC_Product_Data_Store_CPT" ["product-grouped"]=> string(33) "WC_Product_Grouped_Data_Store_CPT" ["product-variable"]=> string(34) "WC_Product_Variable_Data_Store_CPT" ["product-variation"]=> string(35) "WC_Product_Variation_Data_Store_CPT" ["shipping-zone"]=> string(27) "WC_Shipping_Zone_Data_Store" ["webhook"]=> string(21) "WC_Webhook_Data_Store" ["report-revenue-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-orders"]=> string(57) "Automattic\WooCommerce\Admin\API\Reports\Orders\DataStore" ["report-orders-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-products"]=> string(59) "Automattic\WooCommerce\Admin\API\Reports\Products\DataStore" ["report-variations"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Variations\DataStore" ["report-products-stats"]=> string(65) "Automattic\WooCommerce\Admin\API\Reports\Products\Stats\DataStore" ["report-variations-stats"]=> string(67) "Automattic\WooCommerce\Admin\API\Reports\Variations\Stats\DataStore" ["report-categories"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Categories\DataStore" ["report-taxes"]=> string(56) "Automattic\WooCommerce\Admin\API\Reports\Taxes\DataStore" ["report-taxes-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore" ["report-coupons"]=> string(58) "Automattic\WooCommerce\Admin\API\Reports\Coupons\DataStore" ["report-coupons-stats"]=> string(64) "Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats\DataStore" ["report-downloads"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Downloads\DataStore" ["report-downloads-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Downloads\Stats\DataStore" ["admin-note"]=> string(44) "Automattic\WooCommerce\Admin\Notes\DataStore" ["report-customers"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore" ["report-customers-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Customers\Stats\DataStore" ["report-stock-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Stock\Stats\DataStore" } ["current_class_name":"WC_Data_Store":private]=> string(32) "WC_Order_Item_Product_Data_Store" ["object_type":"WC_Data_Store":private]=> string(18) "order-item-product" } ["meta_data":protected]=> array(1) { [0]=> object(WC_Meta_Data)#15697 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(3051) ["key"]=> string(9) "pa_taille" ["value"]=> string(1) "m" } ["data":protected]=> array(3) { ["id"]=> int(3051) ["key"]=> string(9) "pa_taille" ["value"]=> string(1) "m" } } } } } ["shipping_lines"]=> array(0) { } ["tax_lines"]=> array(1) { [457]=> object(WC_Order_Item_Tax)#15704 (11) { ["extra_data":protected]=> array(7) { ["rate_code"]=> string(0) "" ["rate_id"]=> int(0) ["label"]=> string(0) "" ["compound"]=> bool(false) ["tax_total"]=> int(0) ["shipping_tax_total"]=> int(0) ["rate_percent"]=> NULL } ["data":protected]=> array(9) { ["order_id"]=> int(1506) ["name"]=> string(0) "" ["rate_code"]=> string(5) "TVA-1" ["rate_id"]=> int(5) ["label"]=> string(3) "TVA" ["compound"]=> bool(false) ["tax_total"]=> string(4) "2.79" ["shipping_tax_total"]=> int(0) ["rate_percent"]=> float(5.5) } ["cache_group":protected]=> string(11) "order-items" ["meta_type":protected]=> string(10) "order_item" ["object_type":protected]=> string(10) "order_item" ["id":protected]=> int(457) ["changes":protected]=> array(0) { } ["object_read":protected]=> bool(true) ["default_data":protected]=> array(9) { ["order_id"]=> int(0) ["name"]=> string(0) "" ["rate_code"]=> string(0) "" ["rate_id"]=> int(0) ["label"]=> string(0) "" ["compound"]=> bool(false) ["tax_total"]=> int(0) ["shipping_tax_total"]=> int(0) ["rate_percent"]=> NULL } ["data_store":protected]=> object(WC_Data_Store)#15716 (4) { ["instance":"WC_Data_Store":private]=> object(WC_Order_Item_Tax_Data_Store)#15718 (4) { ["internal_meta_keys":protected]=> array(15) { [0]=> string(9) "_order_id" [1]=> string(5) "_name" [2]=> string(10) "_rate_code" [3]=> string(8) "_rate_id" [4]=> string(6) "_label" [5]=> string(9) "_compound" [6]=> string(10) "_tax_total" [7]=> string(19) "_shipping_tax_total" [8]=> string(13) "_rate_percent" [9]=> string(7) "rate_id" [10]=> string(5) "label" [11]=> string(8) "compound" [12]=> string(10) "tax_amount" [13]=> string(19) "shipping_tax_amount" [14]=> string(12) "rate_percent" } ["meta_type":protected]=> string(10) "order_item" ["object_id_field_for_meta":protected]=> string(13) "order_item_id" ["must_exist_meta_keys":protected]=> array(0) { } } ["stores":"WC_Data_Store":private]=> array(38) { ["coupon"]=> string(24) "WC_Coupon_Data_Store_CPT" ["customer"]=> string(22) "WC_Customer_Data_Store" ["customer-download"]=> string(31) "WC_Customer_Download_Data_Store" ["customer-download-log"]=> string(35) "WC_Customer_Download_Log_Data_Store" ["customer-session"]=> string(30) "WC_Customer_Data_Store_Session" ["order"]=> string(23) "WC_Order_Data_Store_CPT" ["order-refund"]=> string(30) "WC_Order_Refund_Data_Store_CPT" ["order-item"]=> string(24) "WC_Order_Item_Data_Store" ["order-item-coupon"]=> string(31) "WC_Order_Item_Coupon_Data_Store" ["order-item-fee"]=> string(28) "WC_Order_Item_Fee_Data_Store" ["order-item-product"]=> string(32) "WC_Order_Item_Product_Data_Store" ["order-item-shipping"]=> string(33) "WC_Order_Item_Shipping_Data_Store" ["order-item-tax"]=> string(28) "WC_Order_Item_Tax_Data_Store" ["payment-token"]=> string(27) "WC_Payment_Token_Data_Store" ["product"]=> string(25) "WC_Product_Data_Store_CPT" ["product-grouped"]=> string(33) "WC_Product_Grouped_Data_Store_CPT" ["product-variable"]=> string(34) "WC_Product_Variable_Data_Store_CPT" ["product-variation"]=> string(35) "WC_Product_Variation_Data_Store_CPT" ["shipping-zone"]=> string(27) "WC_Shipping_Zone_Data_Store" ["webhook"]=> string(21) "WC_Webhook_Data_Store" ["report-revenue-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-orders"]=> string(57) "Automattic\WooCommerce\Admin\API\Reports\Orders\DataStore" ["report-orders-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-products"]=> string(59) "Automattic\WooCommerce\Admin\API\Reports\Products\DataStore" ["report-variations"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Variations\DataStore" ["report-products-stats"]=> string(65) "Automattic\WooCommerce\Admin\API\Reports\Products\Stats\DataStore" ["report-variations-stats"]=> string(67) "Automattic\WooCommerce\Admin\API\Reports\Variations\Stats\DataStore" ["report-categories"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Categories\DataStore" ["report-taxes"]=> string(56) "Automattic\WooCommerce\Admin\API\Reports\Taxes\DataStore" ["report-taxes-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore" ["report-coupons"]=> string(58) "Automattic\WooCommerce\Admin\API\Reports\Coupons\DataStore" ["report-coupons-stats"]=> string(64) "Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats\DataStore" ["report-downloads"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Downloads\DataStore" ["report-downloads-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Downloads\Stats\DataStore" ["admin-note"]=> string(44) "Automattic\WooCommerce\Admin\Notes\DataStore" ["report-customers"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore" ["report-customers-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Customers\Stats\DataStore" ["report-stock-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Stock\Stats\DataStore" } ["current_class_name":"WC_Data_Store":private]=> string(28) "WC_Order_Item_Tax_Data_Store" ["object_type":"WC_Data_Store":private]=> string(14) "order-item-tax" } ["meta_data":protected]=> array(0) { } } } } ["items_to_delete":protected]=> array(0) { } ["cache_group":protected]=> string(6) "orders" ["data_store_name":protected]=> string(5) "order" ["object_type":protected]=> string(5) "order" ["id":protected]=> int(1506) ["changes":protected]=> array(0) { } ["object_read":protected]=> bool(true) ["extra_data":protected]=> array(0) { } ["default_data":protected]=> array(28) { ["parent_id"]=> int(0) ["status"]=> string(0) "" ["currency"]=> string(0) "" ["version"]=> string(0) "" ["prices_include_tax"]=> bool(false) ["date_created"]=> NULL ["date_modified"]=> NULL ["discount_total"]=> int(0) ["discount_tax"]=> int(0) ["shipping_total"]=> int(0) ["shipping_tax"]=> int(0) ["cart_tax"]=> int(0) ["total"]=> int(0) ["total_tax"]=> int(0) ["customer_id"]=> int(0) ["order_key"]=> string(0) "" ["billing"]=> array(11) { ["first_name"]=> string(0) "" ["last_name"]=> string(0) "" ["company"]=> string(0) "" ["address_1"]=> string(0) "" ["address_2"]=> string(0) "" ["city"]=> string(0) "" ["state"]=> string(0) "" ["postcode"]=> string(0) "" ["country"]=> string(0) "" ["email"]=> string(0) "" ["phone"]=> string(0) "" } ["shipping"]=> array(9) { ["first_name"]=> string(0) "" ["last_name"]=> string(0) "" ["company"]=> string(0) "" ["address_1"]=> string(0) "" ["address_2"]=> string(0) "" ["city"]=> string(0) "" ["state"]=> string(0) "" ["postcode"]=> string(0) "" ["country"]=> string(0) "" } ["payment_method"]=> string(0) "" ["payment_method_title"]=> string(0) "" ["transaction_id"]=> string(0) "" ["customer_ip_address"]=> string(0) "" ["customer_user_agent"]=> string(0) "" ["created_via"]=> string(0) "" ["customer_note"]=> string(0) "" ["date_completed"]=> NULL ["date_paid"]=> NULL ["cart_hash"]=> string(0) "" } ["data_store":protected]=> object(WC_Data_Store)#15643 (4) { ["instance":"WC_Data_Store":private]=> object(WC_Order_Data_Store_CPT)#15581 (4) { ["internal_meta_keys":protected]=> array(78) { [0]=> string(10) "_parent_id" [1]=> string(7) "_status" [2]=> string(9) "_currency" [3]=> string(8) "_version" [4]=> string(19) "_prices_include_tax" [5]=> string(13) "_date_created" [6]=> string(14) "_date_modified" [7]=> string(15) "_discount_total" [8]=> string(13) "_discount_tax" [9]=> string(15) "_shipping_total" [10]=> string(13) "_shipping_tax" [11]=> string(9) "_cart_tax" [12]=> string(6) "_total" [13]=> string(10) "_total_tax" [14]=> string(12) "_customer_id" [15]=> string(10) "_order_key" [16]=> string(8) "_billing" [17]=> string(9) "_shipping" [18]=> string(15) "_payment_method" [19]=> string(21) "_payment_method_title" [20]=> string(15) "_transaction_id" [21]=> string(20) "_customer_ip_address" [22]=> string(20) "_customer_user_agent" [23]=> string(12) "_created_via" [24]=> string(14) "_customer_note" [25]=> string(15) "_date_completed" [26]=> string(10) "_date_paid" [27]=> string(10) "_cart_hash" [28]=> string(14) "_customer_user" [29]=> string(10) "_order_key" [30]=> string(15) "_order_currency" [31]=> string(19) "_billing_first_name" [32]=> string(18) "_billing_last_name" [33]=> string(16) "_billing_company" [34]=> string(18) "_billing_address_1" [35]=> string(18) "_billing_address_2" [36]=> string(13) "_billing_city" [37]=> string(14) "_billing_state" [38]=> string(17) "_billing_postcode" [39]=> string(16) "_billing_country" [40]=> string(14) "_billing_email" [41]=> string(14) "_billing_phone" [42]=> string(20) "_shipping_first_name" [43]=> string(19) "_shipping_last_name" [44]=> string(17) "_shipping_company" [45]=> string(19) "_shipping_address_1" [46]=> string(19) "_shipping_address_2" [47]=> string(14) "_shipping_city" [48]=> string(15) "_shipping_state" [49]=> string(18) "_shipping_postcode" [50]=> string(17) "_shipping_country" [51]=> string(15) "_completed_date" [52]=> string(10) "_paid_date" [53]=> string(10) "_edit_lock" [54]=> string(10) "_edit_last" [55]=> string(14) "_cart_discount" [56]=> string(18) "_cart_discount_tax" [57]=> string(15) "_order_shipping" [58]=> string(19) "_order_shipping_tax" [59]=> string(10) "_order_tax" [60]=> string(12) "_order_total" [61]=> string(15) "_payment_method" [62]=> string(21) "_payment_method_title" [63]=> string(15) "_transaction_id" [64]=> string(20) "_customer_ip_address" [65]=> string(20) "_customer_user_agent" [66]=> string(12) "_created_via" [67]=> string(14) "_order_version" [68]=> string(19) "_prices_include_tax" [69]=> string(15) "_date_completed" [70]=> string(10) "_date_paid" [71]=> string(15) "_payment_tokens" [72]=> string(22) "_billing_address_index" [73]=> string(23) "_shipping_address_index" [74]=> string(15) "_recorded_sales" [75]=> string(29) "_recorded_coupon_usage_counts" [76]=> string(29) "_download_permissions_granted" [77]=> string(20) "_order_stock_reduced" } ["meta_type":protected]=> string(4) "post" ["object_id_field_for_meta":protected]=> string(0) "" ["must_exist_meta_keys":protected]=> array(0) { } } ["stores":"WC_Data_Store":private]=> array(38) { ["coupon"]=> string(24) "WC_Coupon_Data_Store_CPT" ["customer"]=> string(22) "WC_Customer_Data_Store" ["customer-download"]=> string(31) "WC_Customer_Download_Data_Store" ["customer-download-log"]=> string(35) "WC_Customer_Download_Log_Data_Store" ["customer-session"]=> string(30) "WC_Customer_Data_Store_Session" ["order"]=> string(23) "WC_Order_Data_Store_CPT" ["order-refund"]=> string(30) "WC_Order_Refund_Data_Store_CPT" ["order-item"]=> string(24) "WC_Order_Item_Data_Store" ["order-item-coupon"]=> string(31) "WC_Order_Item_Coupon_Data_Store" ["order-item-fee"]=> string(28) "WC_Order_Item_Fee_Data_Store" ["order-item-product"]=> string(32) "WC_Order_Item_Product_Data_Store" ["order-item-shipping"]=> string(33) "WC_Order_Item_Shipping_Data_Store" ["order-item-tax"]=> string(28) "WC_Order_Item_Tax_Data_Store" ["payment-token"]=> string(27) "WC_Payment_Token_Data_Store" ["product"]=> string(25) "WC_Product_Data_Store_CPT" ["product-grouped"]=> string(33) "WC_Product_Grouped_Data_Store_CPT" ["product-variable"]=> string(34) "WC_Product_Variable_Data_Store_CPT" ["product-variation"]=> string(35) "WC_Product_Variation_Data_Store_CPT" ["shipping-zone"]=> string(27) "WC_Shipping_Zone_Data_Store" ["webhook"]=> string(21) "WC_Webhook_Data_Store" ["report-revenue-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-orders"]=> string(57) "Automattic\WooCommerce\Admin\API\Reports\Orders\DataStore" ["report-orders-stats"]=> string(63) "Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore" ["report-products"]=> string(59) "Automattic\WooCommerce\Admin\API\Reports\Products\DataStore" ["report-variations"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Variations\DataStore" ["report-products-stats"]=> string(65) "Automattic\WooCommerce\Admin\API\Reports\Products\Stats\DataStore" ["report-variations-stats"]=> string(67) "Automattic\WooCommerce\Admin\API\Reports\Variations\Stats\DataStore" ["report-categories"]=> string(61) "Automattic\WooCommerce\Admin\API\Reports\Categories\DataStore" ["report-taxes"]=> string(56) "Automattic\WooCommerce\Admin\API\Reports\Taxes\DataStore" ["report-taxes-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore" ["report-coupons"]=> string(58) "Automattic\WooCommerce\Admin\API\Reports\Coupons\DataStore" ["report-coupons-stats"]=> string(64) "Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats\DataStore" ["report-downloads"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Downloads\DataStore" ["report-downloads-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Downloads\Stats\DataStore" ["admin-note"]=> string(44) "Automattic\WooCommerce\Admin\Notes\DataStore" ["report-customers"]=> string(60) "Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore" ["report-customers-stats"]=> string(66) "Automattic\WooCommerce\Admin\API\Reports\Customers\Stats\DataStore" ["report-stock-stats"]=> string(62) "Automattic\WooCommerce\Admin\API\Reports\Stock\Stats\DataStore" } ["current_class_name":"WC_Data_Store":private]=> string(23) "WC_Order_Data_Store_CPT" ["object_type":"WC_Data_Store":private]=> string(5) "order" } ["meta_data":protected]=> array(3) { [0]=> object(WC_Meta_Data)#15672 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(13822) ["key"]=> string(17) "_coupon_held_keys" ["value"]=> array(1) { [1505]=> string(30) "_coupon_held_1610908863_fdtgkb" } } ["data":protected]=> array(3) { ["id"]=> int(13822) ["key"]=> string(17) "_coupon_held_keys" ["value"]=> array(1) { [1505]=> string(30) "_coupon_held_1610908863_fdtgkb" } } } [1]=> object(WC_Meta_Data)#15673 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(13823) ["key"]=> string(27) "_coupon_held_keys_for_users" ["value"]=> array(1) { [1505]=> string(32) "_maybe_used_by_1610908863_XQBba0" } } ["data":protected]=> array(3) { ["id"]=> int(13823) ["key"]=> string(27) "_coupon_held_keys_for_users" ["value"]=> array(1) { [1505]=> string(32) "_maybe_used_by_1610908863_XQBba0" } } } [2]=> object(WC_Meta_Data)#15674 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(13824) ["key"]=> string(13) "is_vat_exempt" ["value"]=> string(2) "no" } ["data":protected]=> array(3) { ["id"]=> int(13824) ["key"]=> string(13) "is_vat_exempt" ["value"]=> string(2) "no" } } } } ```
Any insight on what goes wrong? 🤔
Thanks a lot (I've been blocked on that for a while now 😓 )
Following today's debugging session, I understand that my negative value fee does not appear in $costs
because it's value is, well, negative, therefore we go into this condition
This lead me to understand that I had weirdly 2 recalculations of that fee, and I finally understood why !?! (and I left out one part of what I'm doing that explains why).
I am actually transforming the discount of a promo code here into a fee, because there's no way that I found to apply a promo code that is exempt of taxes.
Therefore, my whole code was :
add_action( 'woocommerce_checkout_update_order_meta', 'add_deconsigne_fee' );
function add_deconsigne_fee( $order_id ) {
$order = wc_get_order($order_id);
$coupons = $order->get_items( 'coupon' );
$fee_amount = 0;
foreach ($coupons as $item_id => $coupon_item) {
if (strpos($coupon_item->get_code(), "consigne") > -1) {
$coupon = new WC_Coupon($coupon_item->get_code());
$coupon_amount = $coupon->get_amount();
$order->remove_item($item_id);
$fee_amount += -1 * ((float) $coupon_amount);
$fee = new WC_Order_Item_Fee();
$fee->set_name('Retour consigne :');
$fee->set_total_tax(0);
$fee->set_tax_class(false);
$fee->set_tax_status('none');
$fee->set_taxes(false);
$fee->set_amount($fee_amount);
$fee->set_total($fee_amount);
$fee->save();
$order->add_item($fee);
}
}
$order->recalculate_coupons();
$order->calculate_totals();
$order->save();
}
But this issue with this actually does not come from the fee itself, but from the coupon, that creates a discount on the order originally which needs to be distributed on the different items.
My solution was to actually separate my 2 operations : 1) Calculate the amount to be discounted and remove the coupon and recalculate the order 2) Apply my negative fee that will discount amount from the order (without applying taxes!)
The working code is now :
add_action( 'woocommerce_checkout_update_order_meta', 'add_deconsigne_fee' );
function add_deconsigne_fee( $order_id ) {
$order = wc_get_order($order_id);
$coupons = $order->get_items( 'coupon' );
$fee_amount = 0;
foreach ($coupons as $item_id => $coupon_item) {
if (strpos($coupon_item->get_code(), "consigne") > -1) {
$coupon = new WC_Coupon($coupon_item->get_code());
$coupon_amount = $coupon->get_amount();
$order->remove_item($item_id);
$fee_amount += -1 * ((float) $coupon_amount);
}
}
$order->recalculate_coupons();
if ($fee_amount !== 0) {
$fee = new WC_Order_Item_Fee();
$fee->set_name('Retour consigne :');
$fee->set_total_tax(0);
$fee->set_tax_class(false);
$fee->set_tax_status('none');
$fee->set_taxes(false);
$fee->set_amount($fee_amount);
$fee->set_total($fee_amount);
$fee->save();
$order->add_item($fee);
}
$order->calculate_totals(false);
$order->save();
}
By recalculating the "coupons totals" on the order after removing the promo code, the leftover taxes are nulled, and I can then apply my fee and recalculate the totals without having a tax applied to it ! 🎉
Leaving that comment in case someone needs it 🤗
Spotted in 7354290-zen. While this can be fixed by setting fee taxes zero via woocommerce_cart_totals_get_fees_from_cart_taxes
, recalculating totals in order doesn't respect taxable or tax class parameters.
Is your feature request related to a problem? Please describe. I'd like to add custom discount to the cart. I can't use the cart object's add_discount because it is for adding coupons. I should use the add_fee instead with negative value.
Unfortunately when I add a negative value, the tax added to it regardless of the $taxable attribute value.
Describe the solution you'd like It would be great that the add_fee method would be support the negative values too.