shipping price based on one of the products

  • Posts: 18
  • Thank you received: 0
7 years 5 months ago #272234

-- url of the page with the problem -- : ramblas.rocks/
-- HikaShop version -- : 3.1.1
-- Joomla version -- : 3.7.2
-- PHP version -- : 7.0.7
-- Browser(s) name and version -- : chrome 59.0.3071.104

Ramblas is a big street festival in Antwerp. The stands are to be rented in different settings.
Two of the most important differences are: FOOD and NONFOOD.
Every standholder - who rents an stand - pays a deposit. They have to leave their place clean, otherwise they will lose their deposit.
FOOD-Standholders pay a different deposit than NONFOOD-Standholders: FOOD=100€, NONFOOD=30€. This is per order, not per product. The deposit will be the shipping cost, standard 30€.

Every standholder can rent multiple stands. So, par example, a standholder can rent 2 stands; 1 FOOD and 1 NONFOOD.

If a standholder has rented ANY FOOD-stand in the order, then he has to deposit 100€.
If the order contains no FOOD stands, then the deposit is 30€


Now comes the hard part :)
I can make a foreach to traverse the order, searching for a FOOD stand and break when found.
If found, then I have to change the shipping costs (=deposit) into 100€.

EXAMPLE.
Standholder rents 1 stand FOOD (type S) and 1 stand NONFOOD (type H).
In the foreach the FOOD-type S is found, so the shipping cost has to be altered in 100€.

I did that in the checkout (/templates/[the_template_name]/html/com_hikashop/checkout/cart.php.
So far so good; Hikashop shows the corect shipping cost.
But it does not change the values in the order.

Where/how can I change the shipping cost AND the total cost in the MySQL-order table?
Or is there a more intelligent way to accomplish what I'm trying to do?

Thanks!

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
7 years 5 months ago #272239

Hi,

Why not simply use the weight or volume restrictions of your shipping methods:
You create two shipping methods, one with a max volume of 0.5 with a price of 30 and one with a min volume of 0.5 with a price of 100.
Then, for the products for which the shipping price need to be 100, set dimensions of 1, 1, 1 and otherwise keep the dimensions at 0 for the other products.
And then, the system will switch between both shipping methods automatically based on the products in the cart without one line of custom code.

The following user(s) said Thank You: schipperskwartier

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

  • Posts: 18
  • Thank you received: 0
7 years 5 months ago #272261

Thanks Nicolas! Man... I feel really awkward by not thinking of this simple solution!
But since dimensions are already in use (for the dimensions of the stand), I took the product_weight instead, with the same principle:

  • max weight 0.5g = 30€
  • min weight 0.5g = 100€
Made a short test: works!
Thanks again!

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

Time to create page: 0.053 seconds
Powered by Kunena Forum