Based on a custom field set a value in the cart...

  • Posts: 62
  • Thank you received: 0
10 years 9 months ago #168249

-- HikaShop version -- : 2.3.2
-- Joomla version -- : 3.3.3

Hi,

I want to have a drop down list in the checkout process that has two values Yes and No. That is easy enough, however I want to add/remove a line item in the cart based on what is selected. So if YES is selected add a line to cart of:

Cooler Box 1.00

if NO then I want

Cooler Box 0.00

Naturally as those changes are made I need the total of the cart updated as part of the checkout process.

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

  • Posts: 13201
  • Thank you received: 2322
10 years 9 months ago #168292

Hi,

You can create this custom field thanks to our custom fields system.
Create a custom field with the type "order" via the menu Display > Custom fields, and set it as a dropdown with the desired values.

Then you will have to create your own plugin to edit the cart based on the value of this custom field.
So it require good PHP knwoledges, here is documentation for the plugins:
hikashop.com/support/support/documentati...r-documentation.html

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

  • Posts: 62
  • Thank you received: 0
10 years 9 months ago #169160

Hi,

OK, I can do the PHP side of things. My questions Hikashop are

1) What trigger do I hook off the custom field so that I know when the select box changes?
2) In that trigger how do I get hold of the cart global object so I can add/remove an item?
3) Will doing 2) change the total for the cart or will I have to perform a postback of some form?

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

  • Posts: 83904
  • Thank you received: 13581
  • MODERATOR
10 years 9 months ago #169244

Hi,

1. It depends what kind of custom field you're using so I can't answer to that without more information. Could you maybe do a screenshot of the options of the custom field so that we can tell you ?

2. You could do that directly in the trigger of point 1 by adding/removing the product from the cart directly in the hikashop_cart_product table of the database.

3. It depends. If you do that via a query to the database and that the cart was already loaded on the page, a redirect to the same page could be necessary so that the system reloads the cart with/without the product.

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

Time to create page: 0.066 seconds
Powered by Kunena Forum