Calculations, calculations

  • Posts: 20
  • Thank you received: 0
11 years 8 months ago #93260

Hi again

Today I got a demand from a customer for complex calculation of the price for products.

Price of the product will be dependable on characteristics and the value of quantity field. There actually isn't basic price for a product. It is calculated later.
I should say that price will be shown only on a product page, in the cart module and on the checkout process. in category listings its not showing.

So, I think I need to write a plug-in that wil do next:
• at loading of product page will show calculated price for minimal quantity of the first variant.
• triggers when variant is changed and shows calculated price for that variant.
• triggers when quantity is changed and shows calculated price for that variant.

Problem here is that every variant has it's own equation for calculating prices, so when there is change of variant it grabs another equation. When quantity is changed it recalculate the price.

All this must be done before add to cart button, so when user deside to buy product, calculated price for that variant goes to cart and check out process.

Is this possible to do in hikashop? Please tell me it is, cause I'm in love with this component, I don't want to look for other solutions. I know there will be a lot of coding, but I am prepared to do it.
Am I on the right way? Which files should I edit to achieve this? I believe product/default.php, product/quantity.php, maybe characteristics?

I should add that I use Joomla 2.5.7 and Just updated Hikashop essential 2.1.0.

Attachments:
Last edit: 11 years 8 months ago by krhin07.

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

  • Posts: 82795
  • Thank you received: 13356
  • MODERATOR
11 years 8 months ago #93261

Hi,

Why not simply enter the price for each variant for each quantity in the backend ?
The prices displayed on the product page is actually updated automatically when you select the characteristic. So there is nothing to do for that.
The price based on the quantity is actually displayed on the cart, once the variant has been added to the cart.

So that would require some javascript magic for the product page (in the show_default view file that you can edit via the menu Display>Views) to get the current variant prices and generate the price based on the quantity to display it on the product page when the quantity changes. Normally, you should already have all the data already in the HTML to do that.

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

  • Posts: 20
  • Thank you received: 0
11 years 8 months ago #93268

Hi. Thanks for quick reply, but it's not what I really need.


Prices here is depending on diferent variables that users cannot change.
For example:
I have a busines card that can be printed in 4 modes of printing: 1colour, 2 colour, 3 colour, 4 colour.
every mode have different equations for prices that is dependable of quantity.

first mode: -0,00001 * $qty * $qty + 0,0516 * $qty + 30,883
second mode: 0,0000006 * $qty * $qty + 0,0332 * $qty + 47,876
third mode: -0,000007 * $qty * $qty + 0,0525 * $qty + 63,613

so every time user change variant, other equation is called to calculate the price. It is not determined as price * quantity.
I got exell file with those equations and it's working very nice there. Now I need to make it work in Hikashop.


Cause it's printing office I have different sizes of products:
flyer A5, Flyer A4... and every product has same variants: different modes for printing. So I defined sizes as separate product, now I need to implement calculations per variant.

Is it possible?

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

  • Posts: 82795
  • Thank you received: 13356
  • MODERATOR
11 years 8 months ago #93282

Hi,

Then, I would recommend to create custom item fields instead of variants and create a quantity price calculation override plugin to set the price of the product based on the item fields values selected when the user add the product to the cart. We have some documentation about that here:
www.hikashop.com/en/support/documentatio...tation.html#override
and an example here:
demo.hikashop.com/index.php?option=com_h...ct&task=show&cid=214
The only thing is that this only apply to the product price once it has been added to the cart, not on the product page.

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

  • Posts: 20
  • Thank you received: 0
11 years 8 months ago #93298

Sorry, but I cant get custom fields to show on product page.

For example, I made custom field - dropdown list where user can select options for printing, but I cant get it to show on product page so user can select its options. I erased my template overrides for hikashop, but it still don't shows anything. I have just upgraded my instalation of hika

Am I missing something?

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

  • Posts: 82795
  • Thank you received: 13356
  • MODERATOR
11 years 8 months ago #93302

You're probably creating custom fields of the table "product" (to have them on the product edition page on the backend) and not custom fields of the table "item" (to have them on the product details page of the frontend):
www.hikashop.com/en/support/documentatio...ing.html#description

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

  • Posts: 20
  • Thank you received: 0
11 years 8 months ago #93305

Yes, I'm on the essentials version. Need to upgrade to business...

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

  • Posts: 20
  • Thank you received: 0
11 years 8 months ago #93320

Hi again.

I've upgraded to business, created custom fields, but now my cart wont update when I add product to cart.

here is the link artisk.si/artisk/index.php/2013-01-15-07...veni?popup=1&popup=1

I haven't modified any file yet

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

  • Posts: 82795
  • Thank you received: 13356
  • MODERATOR
11 years 8 months ago #93344

It's working fine for me on your website.
Probably a user session issue on your end after the update.
Try to logout/login and/or clear your browser's cookies/cache and that should help.

The following user(s) said Thank You: krhin07

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

  • Posts: 20
  • Thank you received: 0
11 years 8 months ago #93377

It was something with cookies. CTRL+F5 solved it :)

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

Time to create page: 0.054 seconds
Powered by Kunena Forum