Calculate price on length and width ?

  • Posts: 13
  • Thank you received: 0
11 years 5 months ago #107707

Hello,

I would like to start a shop to sell hand-woven carpets. The pricing is simply based on the size of the carpet, irrespective of the design.

This simplifies things considerably, especially with regard to shipping as each square foot has a fixed weight.

The thing is that I want to be able to show the carpet patterns (there are many) as individual products but then allow the customer to select length and width.

The price is then calculated on these inputs.

Can Hikashop do this?

Please advise

Thanks

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

  • Posts: 2334
  • Thank you received: 403
11 years 5 months ago #107730

Hi there,

This is actually not yet possible in Hikashop. We are thinking about making that kind of thing possible with the custom fields but we didn't started the development yet.
If the width and length have a limit, you can create 2 characteristics (one for each) with values from 1 to 10. Then, you can add it to your basic product and customize the prices of the variants.
But this method will be quite long. Last option is to write a custom code or ask for a commercial job on the related forum.

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
9 years 11 months ago #182787

Hi,

Please note that there is now a small plugin that can be used to do that with HikaShop Business.
We have a section of the FAQ titled "How to sell products by Width and Length ?" which explains that:
www.hikashop.com/support/support/documen...on/106-faq.html#cart

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

  • Posts: 7
  • Thank you received: 0
9 years 7 months ago #196959

Hi, I have installed the plug in and added the custom fields. What's next? How do I configure HikaShop to calculate my price?
Thanks

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
9 years 7 months ago #196980

Hi,

There is nothing else to do. It will automatically take the price of the product and multiply it by the value entered by the customer in the width and length fields in order to get the total price of the product in the cart.
If that doesn't work, it probably means that the custom fields are not configured properly. We would need a screenshot of your custom fields settings in order to say more on that.

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

  • Posts: 7
  • Thank you received: 0
9 years 7 months ago #197188

Thank you, I have that working now. Is it possible to have the calculated price displayed before adding it to the cart?

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

  • Posts: 7
  • Thank you received: 0
9 years 7 months ago #197193

Also, my price is per square metre and the width & length are entered in millimetres for accuracy. This results in a price * 1,000,000. I could change the product price to reflect this but that would be messy so I changed the calculation in the plugin to
$product->order_product_total_price_no_vat = $product->order_product_price*($quantity/1000000);
$product->order_product_total_price = (($product->order_product_price+$product->order_product_tax)*($quantity/1000000));
Apologies if this is complete nonsense in code terms, I can see where the change is required but I'm a novice. The change has had no effect. Basically I need to convert the quantity to mm therefore divide by 1,000,000. Please advise. Thank you for your help.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 7 months ago #197206

Hi,

To have the calculated price on the product page before adding it to the cart it will require custom code, and AJAX to edit dynamically the product price based on the custom fields. So it require good php and javascript knowledges.

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

  • Posts: 7
  • Thank you received: 0
9 years 7 months ago #197501

Ok thank you, could you tell me which files display the detailed product page, and the file that is creating JavaScript for that file
plus php files, and their hierarchy that is where they reside, folder hierarchy please. This will enable me to get the changes made. Thank you

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
9 years 7 months ago #197520

Hi,

There are only two files you want to look at:
- The "show_block_custom_item" view file where you can add a call to a custom JS function in order to refresh the price on the line:
' '.$onWhat.'="hikashopToggleFields(this.value,\''.$fieldName.'\',\'item\',0);"'
You can add your custom function definition at the end of that file in a script tag.
- The "listing_price" view file of the "product" view where the price is displayed. It's just to look at the HTML and maybe add additional HTML tags if you see that as necessary for your custom code.

These two files can be edited via the menu Display>Views of the backend of HikaShop. That way, you'll keep your modifications when you update HikaShop.

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

  • Posts: 7
  • Thank you received: 0
9 years 7 months ago #197881

As your code is generated by your framework classes, I can find your customized JS code in the product detail page (under script tag) but can't find the classes/files (PHP Script) that are generating this script. Can you please guide me so that I can customize that according to my needs.Thank you

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
9 years 7 months ago #197909

Hi,

I don't see why that would be necessary for what you want to do.

I would instead recommend to do like this:
' '.$onWhat.'="myfunction(this);hikashopToggleFields(this.value,\''.$fieldName.'\',\'item\',0);"'

and have your "myfunction" javascript fucntion defined in the view, as I had explained previously.

But if you really want to hack in the core files of HikaShop, you'll find the dynamic javascript of the fields generated in the administrator/components/com_hikashop/classes/field.php file.

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

Time to create page: 0.103 seconds
Powered by Kunena Forum