we have identified the following issue in your code:
When the code calls $tax_rate = $this->get_item_tax_rate($order_item, $order); it ends up with the wrong value.
It seems the reason being down to rounding of incorrect values in the get_item_tax_rate() function. Specifically these two variables ending up with incorrect values:
$total_without_tax = $order->get_line_total($item, false, false);
$total_with_tax = $order->get_line_total($item, true, false);
For an line item with a cost of 0,80€ and 24% tax rate, these will produce the values 0.645161 and 0.795161.
Then when doing the final calculation for $tax_rate = round(( $tax_total / $total_without_tax ) * 100); we get the incorrect tax rate of 23% and not 24%.
To reproduce the issue you can take these steps:
If you need any further information, please let us know, thank you!
]]>I am trying to add meta-data to my orderline items.
But it looks like the “$quantity” output is not right, it is not taking the qty from the right product line?
Also what I actually want is that this meta data is being updated when an order is updated, not only when it is set to processsing.
Do you have any idea what I am doing wrong?
function add_pakket_aantal_productline( $items, $order ) {
foreach ( $order->get_items() as $item_id => $item ) {
$quantity = $item->get_quantity();
$product_id = $item->get_product_id();
$product = wc_get_product($product_id);
$step_value = $product->get_meta('_alg_wc_pq_step');
$pakket_aantal = $quantity / $step_value;
$items = $order->get_items();
foreach ( $items as $item ) {
$item->update_meta_data( '_pakketten', $pakket_aantal );
$item->save_meta_data();
}
}
}
add_action( 'woocommerce_order_status_processing', 'add_pakket_aantal_productline', 10, 2 );
Best regards,
Olga
I am wondering wether it is possible to add the order number as meta_data to the line item. We are working with merging and splitting plugins and to be able to recall where the item was originally belonged to we would like to add this information.
I tried the code below, but it is adding as order number “0” to the line items.
// Add order Id as custom order item meta data
add_action( 'woocommerce_checkout_create_order_line_item', 'add_meta_to_line_item', 10, 4 );
function add_meta_to_line_item( $item, $cart_item_key, $values, $order ) {
$item->add_meta_data( 'order_nummer', $order->get_id() );
}
Maybe I am adding the function too early?
I hope you can help me out
Best regards,
Olga
Im having issue with woocommerce: an extra product line item is added to the Cart, After I successfully hit the checkout button.
I can’t seem to fix it, and the Theme developer says its not the Theme plugin which is causing the issue.
Can someone please assist?
Product name – attribute value #1, attribute value #2…
Attribute #1: attribute value #1
Attribute #2: attribute value #2
…
Some time after April, this was changed to just:
Product name
Attribute #1: attribute value #1
Attribute #2: attribute value #2
…
What triggered the change? when was it made? I could not find it in the change log. I know this is reverting to the original behavior but it would have been nice to be notified of such a change. Thank you for any insight.
]]>Now, when we take a look at the order in WooCommerce there is a difference to regular orders: the shipping line item is missing (usually displayed below the line items with a truck icon). So in effect it’s also missing from the totals listed in all order emails, and furthermore not listed on the PDF.
That said, it would be nice to have this fixed in the plugin itself.
We are using WooCommerce 3.6.2, WP 5.2, Germanized Pro and Flatsome Theme.
I more or less fixed this today by hooking a function into WooCommerce hooks, checking if there is such a shipping line item present or not, and if necessary appending it for all physical goods carts. I noticed that the method for getting the shipping cost did give me the correct amount, still the line item wasn’t there.
Weirdly, when simply saving the new order instead of going to the checkout I see a shop_order with status draft that does have the shipping cost line item.
Thanks
]]>