Shipping Fee for Specific Zone (in addition to shipping rate)

  • Posts: 106
  • Thank you received: 5
1 year 3 months ago #348292

-- HikaShop version -- : 4.7.0
-- Joomla version -- : 3.10.11
-- PHP version -- : 7.3.33

Our state of Colorado has instituted a Retail Delivery Fee. The fee is a flat $0.27 USD and applies to any order we ship to customers within the state of Colorado and is on top of the shipping rate. We have virtual products in addition to physical products, so it will not apply to all of our Colorado customers. This fee must be listed separately, not added to the shipping charge. Is there a way to configure this in HikaShop?

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

  • Posts: 81423
  • Thank you received: 13056
  • MODERATOR
1 year 3 months ago #348295

Hi,

I'm afraid this will require some coding.
This plugin can add a flat fee to orders:
www.hikashop.com/marketplace/product/224-global-cart-fee.html
However, it doesn't have options to restrict the fee based on the location of the user or the weight of the products (no weight means virtual product). So it would require modifying that plugin to add these restrictions in it.

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

  • Posts: 106
  • Thank you received: 5
1 year 3 months ago #348327

nicolas wrote: Hi,

I'm afraid this will require some coding.
This plugin can add a flat fee to orders:
www.hikashop.com/marketplace/product/224-global-cart-fee.html
However, it doesn't have options to restrict the fee based on the location of the user or the weight of the products (no weight means virtual product). So it would require modifying that plugin to add these restrictions in it.

Well, that at least gives me a starting point. I'll have a go at modifying that plug-in. I assume that I can glean some code from the shipping plugins on restricting it to a specified zone and a minimum weight.

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

  • Posts: 81423
  • Thank you received: 13056
  • MODERATOR
1 year 2 months ago #348332

Well, yes and no. The shipping plugins extend the hikashopShippingPlugin class.
The code which checks the weight comes from that class hikashopShippingPlugin so the code is not directly in the plugins.
This class is defined in the file administrator/components/com_hikashop/helpers/shippingplugin.php so that's where you want to look.
The code is in the function onShippingDisplay. You will be able to use it quite easily in the global cart fee plugin code.

For the zone, the simplest is to get the current zone id with the function hikashop_getZone(). Then, you can just check it against the id of the colorado state zone you can get from System>Zones.

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

  • Posts: 106
  • Thank you received: 5
1 year 2 months ago #348353

nicolas wrote: Well, yes and no. The shipping plugins extend the hikashopShippingPlugin class.
The code which checks the weight comes from that class hikashopShippingPlugin so the code is not directly in the plugins.
This class is defined in the file administrator/components/com_hikashop/helpers/shippingplugin.php so that's where you want to look.
The code is in the function onShippingDisplay. You will be able to use it quite easily in the global cart fee plugin code.

For the zone, the simplest is to get the current zone id with the function hikashop_getZone(). Then, you can just check it against the id of the colorado state zone you can get from System>Zones.

I did just a quick down and dirty change, which looks to be working. I replaced the last line of code with the code below. As a feature request, it would be nice to provide a more flexible plugin by allowing the user to restrict by a selected zone and if only for orders with shipping.
            $physicalProduct = false;
            
            foreach($cart->products as $product) {
                if (isset($product->product_weight) && $product->product_weight > 0) {
                    $physicalProduct = true;
                    break;
                }
            }
            
            if ($physicalProduct && $cart->shipping_address->address_state[0] == 'state_Colorado_4266') {
                $cart->additional['global_cart_fee_'.$plugin] = $additional;
            }

The following user(s) said Thank You: nicolas

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

Time to create page: 0.055 seconds
Powered by Kunena Forum