Hi Jerome,
I changed this code in the file administrator/components/com_hikashop/helpers/helper.php
$product_ids = array_keys($shipping_price->products);
JArrayHelper::toInteger($product_ids);
to your code:
foreach($order->shipping_prices as $key => $shipping_price) {
if(empty($shipping_price->price_per_product) || empty($shipping_price->products))
continue;
$shipping_ids = array_keys($shipping_price->price_per_product);
JArrayHelper::toInteger($shipping_ids);
$product_ids = array_keys($shipping_price->products);
$query = 'SELECT a.shipping_id, a.shipping_price_ref_id as `ref_id`, a.shipping_price_min_quantity as `min_quantity`, a.shipping_price_value as `price`, a.shipping_fee_value as `fee` '.
' FROM ' . hikashop_table('shipping_price') . ' AS a '.
' WHERE a.shipping_id IN (' . implode(',', $shipping_ids) . ') '.
' AND a.shipping_price_ref_id IN (' . implode(',', $product_ids) . ') AND a.shipping_price_ref_type = \'product\' '.
' ORDER BY a.shipping_id, a.shipping_price_ref_id, a.shipping_price_min_quantity';
$db = JFactory::getDBO();
$db->setQuery($query);
$ret = $db->loadObjectList();
if(empty($ret))
continue;
$products_qty = $shipping_price->products;
foreach($order->products as $ordered_product) {
if($ordered_product->product_parent_id == 0)
continue;
foreach($ret as $ship) {
if($ordered_product->product_id == $ship->ref_id) {
$products_qty[ (int)$ordered_product->product_parent_id ] -= $products_qty[ (int)$ordered_product->product_id ];
}
}
}
foreach($ret as $ship) {
if($products_qty[$ship->ref_id] > 0 && $ship->min_quantity <= $products_qty[$ship->ref_id]) {
$order->shipping_prices[$key]->price_per_product[$ship->shipping_id]['products'][$ship->ref_id] = ($ship->price * $products_qty[$ship->ref_id]) + $ship->fee;
}
}
unset($products_qty);
}
See screenshot:
But that didn't fixed the issue that you can do it for the main product and it will apply to all the variants of the product.
It looks like one variant (the first one) is updated but not all the other variants.
This message contains confidential information
But one the second test it looks like only the last variant is updated. So that really strange!!!
This message contains confidential information
P.S. I don't get an warningmessage like michelpouli. I have no issue with shipping and paymentmethodes and shippingmethods showing at the checkout. In my case it's working fine.
There is another issue but that's only related to this issue. Because when I have a product in my cart which may not be sent to Germany (in my case) then I get as shipping address the address from the shop and not from the Germany address. But that's fine!. So when I delete the specific product which may not be sent to Germany, then still the address from the shop is displayed as the shipping address. To fix this I have to go first to step 3 and then select a shipping method and then I have to go back to step 2 to see my address with the option to change it. But that's not really user friendly I think.
This message contains confidential information
I hope you find a solution for both issues.
Kind regards,
Lumiga