Is it possible to edit the item custom field in checkout?

  • Posts: 13
  • Thank you received: 0
4 years 11 months ago #306289

-- HikaShop version -- : 4.0.3
-- Joomla version -- : 3.9.5

Greetings. I'm working with a company that designs and produces plastic products like bottles or caps and I'm using Hikashop to show the product to their potential clients but the checkout process has been modified to only create quotes that are sent to the company.

Recently my client explain me that all their products are distribuited in "packages", for example: 20 caps per bag or 500 bottles per box. so when the user adds 1 product to the cart, in reality they are going to quote 20 caps or 500 bottles.

Because of this, they want that the product page show a total of products included in the "package" and it can increase or decrease based on the quantity of "packages" set in the quantity field. The total of products ordered has to be included in the order mail.

I'm currently planning to use the item custom field, hidden it and use some javascript to set its value to the total of products. However, I don't think I can replicate this method in the checkout process, more specific in the cart view, because it only shows the value of the item custom field filled previously.

Is there a way to edit this field in the checkout process so when the user make change in the quantity field, the item custom field updates the total?

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

  • Posts: 4508
  • Thank you received: 610
  • MODERATOR
4 years 11 months ago #306298

Hello,

Thanks for your details, but with your example, we don't get why you don't create product ("package") like this kind of scheme :
- 1 product that in description explain that you have 20 caps with its price
- 1 product with the same idea, will contain 30 caps with its price

Etc, from my previous example, you can imagine that the customer can decrease or increase quantity that will multiply quantity.
Note that you can use Variants, if you have package that can't be regular on their quantities, something like :
- A product with 20 caps
- His variants with 30 caps

Same idea than previous, customer will be able to modify quantities.
From this idea, and if you have this question what can't allow you to use this kind of settings ? There must be something that we don't know, then we need to have this specific case to better answer you.

Regards

Last edit: 4 years 11 months ago by Philip.

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

  • Posts: 13
  • Thank you received: 0
4 years 11 months ago #306346

The idea of my client is that the total of products included in the "package" update dinamically when the users increase or decrease the quantity field. (Image01 and image02)

When the users go to the checkout, they will see an extra column that display the total of products included in the order (image03)

My plan to solve this is creating an item type custom field, hidden it and use some javascript to set its value to the total of products and display said value on screen.

However, after looking how the checkout page is rendered, I don't think I can replicate this method in the cart page, because it only shows the value of the item custom field that I filled previously.

Is there a way to edit this field during the checkout process so when the user increase or decrease the quantity field, the products total changes too? Also, How can I show a custom field in a new column?

Attachments:
Last edit: 4 years 11 months ago by HALVAM.

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

  • Posts: 81504
  • Thank you received: 13062
  • MODERATOR
4 years 11 months ago #306361

Hi,

I suppose that the "contenido" display is a custom product field you already have.
What I would recommend is to edit the view files where you want to add that display to add HTML and some javascript to update the HTML to display the total amount.
It should only be a few lines of HTML/javascript.
On the checkout, you don't even need the javascript, only the HTML since the view has an update button to refresh it when you change the quantity field.
To know which view file to edit, you can activate the "Display view files" setting of the HikaShop configuration.
You can then edit them via the menu Display>Views.

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

  • Posts: 13
  • Thank you received: 0
4 years 11 months ago #306435

What I would recommend is to edit the view files where you want to add that display to add HTML and some javascript to update the HTML to display the total amount.
It should only be a few lines of HTML/javascript.


I have added the necessary JS and HTML to show and update the total amount of products. Also with JS, I set the value of a new custom field of the item table called "total" so I can have a way to save it into the database. This field is hidden with CSS in the product page.

This is how it looks now when you go to the checkout page. (Image01)

On the checkout, you don't even need the javascript, only the HTML since the view has an update button to refresh it when you change the quantity field.


Based on I did with the "total" custom field. How can I save the new updated value into said custom field?

Attachments:

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

  • Posts: 81504
  • Thank you received: 13062
  • MODERATOR
4 years 11 months ago #306462

Hi,

If you add a value to a custom field of the table "item" on the product page, then when you click on the add to cart button, it should automatically save it along with the product in the cart.

Now, if you want to update the value of that custom item field when the quantity is changed during the checkout, you would have to create a joomla plugin of the group hikashop and implement the "onAfterCartSave(&$cart)" trigger in it. That way, you can get the new quantity and cart_product_id of the product and update the custom field value in the hikashop_cart_product table with a MySQL query in your plugin.

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

Time to create page: 0.064 seconds
Powered by Kunena Forum