Strange behaviour with blocked Price per Product shipping methods

  • Posts: 3
  • Thank you received: 0
4 years 6 months ago #311422

-- url of the page with the problem -- : joomla.evocat.net/test-components/wineshop/wineshop/
-- HikaShop version -- : 4.2.1
-- Joomla version -- : 3.9.12
-- PHP version -- : 7.2.16
-- Error-message(debug-mod must be tuned on) -- : Notice: Undefined index: p5 in /var/www/joomla/sites/development/test-components/wineshop/wineshop/administrator/components/com_hikashop/helpers/shippingplugin.php on line 194

Notice: Trying to get property 'product_name' of non-object in /var/www/joomla/sites/development/test-components/wineshop/wineshop/administrator/components/com_hikashop/helpers/shippingplugin.php on line 194

Hello

(Running hikashop business 4.2.1 under joomla 3.9.12)

I've found a couple of apparent issues with "Blocked" shipping prices for products (which I am using to restrict purchase of some products to UK-only shipping addresses).

(I have set up a simple test site at joomla.evocat.net/test-components/wineshop/wineshop/ to show these issues.)

A. If the product has variants, and if the "parent" product has shipping blocked to non-UK addresses, I get weird behaviour if we have a non-UK address and the product is selected (namely "Add to cart" buttons on the product listing page no longer apparently do anything).

Steps to reproduce:
1. Go to above site
2. "Choose options" for "Wine" product (this product has variants, and has shipping to UK only)
3. "Add to cart"
4. Proceed to checkout
5. Enter Guest details (with a NON-UK Country)
6. Select "Next"
(at this point the checkout page shows php Notices re line 194 of /administrator/components/com_hikashop/helpers/shippingplugin.php -- see note at end)
7. Return to "Shop" (top menu)
(cart module on right of page shows same php Notices)
8. Try to add to Cart any item eg Wine Glasses.
(*** the cart module is not responsive to any additions ***, although they are actually added to the cart, as seen by proceeding to the checkout)

B. If a product is bought that has shipping blocked, and also a virtual product is bought, I get a weird error message eg "No shipping method found for the warehouse : 2"

Steps to reproduce:
1. Go to above site with an empty cart
2. "Add to cart" for Wine Glasses (which has shipping to UK only)
3. Proceed to checkout
4. Enter Guest details (with a NON-UK Country)
5. Select "Next"
6. Return to "Shop" (top menu)
7. "Add to cart" for the Wine Leaflet (which is a virtual product)
8. "Proceed to checkout"
9. Get strange error: "No shipping method found for the warehouse : 2"
(I don't have a warehouse "2")

I'm probably doing something stupid, but perhaps you could double-check this behaviour. I can give backend access to the site above if needed.

Thanks,
David


The php notices from step A6 are:

Notice: Undefined index: p5 in /var/www/joomla/sites/development/test-components/wineshop/wineshop/administrator/components/com_hikashop/helpers/shippingplugin.php on line 194

Notice: Trying to get property 'product_name' of non-object in /var/www/joomla/sites/development/test-components/wineshop/wineshop/administrator/components/com_hikashop/helpers/shippingplugin.php on line 194

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
4 years 6 months ago #311453

Hello,

1. Thank you for your feedback, we'll try to reproduce and fix it on our end. Also, If you're only having "notice" and no warning messages it won't affect your shop.
Note that when your shop is in production mode you should :
- Disable the Joomla debug mode ("Administration->Global configuration->System->Debug System/Language")
- Set the "error reporting" option of the Joomla configuration to "none"

2. That issue is coming from the fact that you used the "Warehouse" option through your product configuration page or shipping method configuration page. So you should unset it if you don't want to use warehouses.


We wish you a nice day !
Kind regards,
Mohamed Thelji.

Please Log in or Create an account to join the conversation.

  • Posts: 3
  • Thank you received: 0
4 years 6 months ago #311952

Hello

Thanks for your reply, but

1. My problem isn't that I don't know how to suppress php notices (I reported the notices as it suggests a problem with the code that is probably related to my issue). My problem is that the hikashop cart module does not reflect buying a product in the situation I outlined.

2. I need to use Warehouses, so unfortunately I cannot follow your suggestion.

I would be great if a fix could be found for these issues. As it stands hikashop is of no use to me.

Thanks,
David

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
4 years 6 months ago #311968

Hello David,

Can you show us how you configured your 2 products and shipping methods through some screenshots so that we can directly test it on our end ? Thank you.

Kind regards,
Mohamed Thelji.

Last edit: 4 years 6 months ago by Mohamed Thelji.

Please Log in or Create an account to join the conversation.

  • Posts: 3
  • Thank you received: 0
4 years 6 months ago #312050

Hello. Rather than waste time doing screenshots (although I did offer you backend access to the test site), I had a peek at the hikashop code (particularly where the php notices were coming from).

1. (Re the hikashop cart module being unresponsive to purchases if a product with variants has its shipping blocked)

I tried out the following patch:


diff --git a/mysite.com/administrator/components/com_hikashop/helpers/shippingplugin.php b/mysite.com/administrator/components/com_hikashop/helpers/shippingplugin.php
index 4293a10..bc65982 100644
--- a/mysite.com/administrator/components/com_hikashop/helpers/shippingplugin.php
+++ b/mysite.com/administrator/components/com_hikashop/helpers/shippingplugin.php
@@ -180,6 +180,11 @@ class hikashopShippingPlugin extends hikashopPlugin {
                $price = 0;
                $rate_prices['products']['product_names'] = array();
                foreach($order->products as $k => $row) {
+
+                    if (substr($k,0,1) === 'p') { // don't check a parent product directly -- we check it via its variant if appropriate
+                        continue;
+                    }
+
                    if(!empty($rate->products) && !in_array($row->product_id, $rate->products))
                        continue;
 
@@ -191,7 +196,7 @@ class hikashopShippingPlugin extends hikashopPlugin {
                    } elseif(isset($rate_prices['products'][$row->product_parent_id])) {
                        $price += $rate_prices['products'][$row->product_parent_id];
                        if($rate_prices['blocked'])
-                           $rate_prices['products']['product_names'][] = '"' . $order->products['p'.$row->product_id]->product_name . '"';
+                           $rate_prices['products']['product_names'][] = '"' . $order->products['p'.$row->cart_product_id]->product_name . '"';
                        $rate_prices['products'][$row->product_parent_id] = 0;
                    } elseif(!isset($rate->shipping_params->shipping_virtual_included) || $rate->shipping_params->shipping_virtual_included || $row->product_weight > 0) {
                        $price += $rate_prices['price'] * $row->cart_product_quantity;


It seems to fix it for me, but I'm not familiar enough with the hikashop code to be sure it's ok.

2. (Unclear error message on checkout of the form "No shipping method found for the warehouse : 2" in some circumstances)

Looking at the code, it seems this isn't a bug, just an unclear message obtained when products from more than 1 warehouse have been ordered, and some products have had their shipping blocked.

I'm now just getting rid of the message with a language override:
NO_SHIPPING_METHOD_FOUND_FOR_WAREHOUSE=""

So I think my issues have been cleared up.
Thanks,
David

Please Log in or Create an account to join the conversation.

Time to create page: 0.076 seconds
Powered by Kunena Forum