- Posts: 18
- Thank you received: 0
Change price calculation
- MaartenVdp
-
Topic Author
- Offline
-- HikaShop version -- : 2.3.1
-- Joomla version -- : 2.5
Hi,
I'm creating a webshop for a printing company.
The current hikashop configuration allows to order products.
So, example situation:
I have two pieces: first one is 30x30cm (€ price_a), second one is 60x40cm (€ price_b).
A customer can order, sees the amount and pays.
The owner of this company wants to change it:
he has the custom fields width and height and want to define a price per cm², in stead of per product.
Does someone know how I can configure this?
So, I'll have a price per cm² for each product and the price will be calculated for the dimensions.
Please Log in or Create an account to join the conversation.
You can follow the instructions of the section "How to sell products by Width and Length ?" of our FAQ:
www.hikashop.com/support/support/documen...on/106-faq.html#cart
Please Log in or Create an account to join the conversation.
- Posts: 608
- Thank you received: 13
Hope this helps.
Please Log in or Create an account to join the conversation.
- MaartenVdp
-
Topic Author
- Offline
- Posts: 18
- Thank you received: 0
thanks for the fasts responses.
It's no solution to put the amount of cm² in the quantity field:
for some products he can do this (e.g. wallpaper), but for some products (like a canvas) he wants to have the amount of products in the quantity field. Those products have a width and length (and so a cm² defined).
Now he want to set a price per cm² and he wants the price being calculated based on the cm²...
Please Log in or Create an account to join the conversation.
- Posts: 608
- Thank you received: 13
Please Log in or Create an account to join the conversation.
- MaartenVdp
-
Topic Author
- Offline
- Posts: 18
- Thank you received: 0
I know you can do it like that, but it's not that clean right?
It's just: 1 product (e.g. mouse mat) can have two dimensions 30x30cm (i.e. 900cm²) or 40x20cm (i.e. 800cm²).
The price needs to be calculated based on the width and height of the product (characteristics), but the quantity is the amount of products (e.g. mouse mats) that the customer wants to buy.
So the price is the amount of cm² x price_per_cm² x quantity....
Is there a clean solution to do this, without adapting the PHP code of hikashop?
Please Log in or Create an account to join the conversation.
- MaartenVdp
-
Topic Author
- Offline
- Posts: 18
- Thank you received: 0
The issue now is that I don't find documentation (or if possible) an example on how to do template overrides for a particular product...
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- MaartenVdp
-
Topic Author
- Offline
- Posts: 18
- Thank you received: 0
I searched further. It can be enough that I define a price on the product level (without length and with characteristics).
The price that needs to be created when I add width and height characteristic has to be width x height x global price product (will be defined per cm²).
Is there a way to manipulate how the prices are calculated and stored into the database?
Please Log in or Create an account to join the conversation.
- MaartenVdp
-
Topic Author
- Offline
- Posts: 18
- Thank you received: 0
I didn't see that it was a link :blush:
I just saw that I had to create the plugin....
Many thanks!
Please Log in or Create an account to join the conversation.
- MaartenVdp
-
Topic Author
- Offline
- Posts: 18
- Thank you received: 0
I installed the plugin, but nothing is happening....
- I installed the plugin (with these changes:
if(!function_exists('hikashop_product_price_for_quantity_in_cart') && !function_exists('hikashop_product_price_for_quantity_in_order')) {
function hikashop_product_price_for_quantity_in_cart(&$product){
$currencyClass = hikashop_get('class.currency');
$quantity = @$product->cart_product_quantity;
if(!empty($product->length) && !empty($product->width)){
$quantity = 500;//$quantity*$product->length*$product->width;
}
$currencyClass->quantityPrices($product->prices,$quantity,$product->cart_product_total_quantity);
}
function hikashop_product_price_for_quantity_in_order(&$product){
$quantity = $product->order_product_quantity;
if(!empty($product->length) && !empty($product->width)){
$quantity = $quantity*$product->length*$product->width;
}
$product->order_product_total_price_no_vat = -100;//$product->order_product_price*$quantity;
$product->order_product_total_price = -50;//($product->order_product_price+$product->order_product_tax)*$quantity;
}
}
just to see that it's working...
- I have width & length and published it on the front end.
Now I still have the old prices on the front end
Please Log in or Create an account to join the conversation.
The prices will only change in the cart since that an override of the quantity price calculated when the cart is loaded in memory.
So make sure that the plugin is published and that you're looking at the price of the product in the cart.
Please Log in or Create an account to join the conversation.
- MaartenVdp
-
Topic Author
- Offline
- Posts: 18
- Thank you received: 0
I give as a price for the global product: €amountA (e.g. mouse mat) ==> price is per cm²
mouse mat has 2 variants: 20x20cm, and 40x40cm.
when I enter those variants, with there length and with, I want to have the price calculated based on the global price set.
Is this possible through a hikashop plugin, or should I add a database trigger?
Please Log in or Create an account to join the conversation.
Just click on the "manage variants" button of the product edition page, edit each variant, and enter what you want in the field "Main product price percentage" of each one.
The price will then be calculated automatically for each variant.
Please Log in or Create an account to join the conversation.
- MaartenVdp
-
Topic Author
- Offline
- Posts: 18
- Thank you received: 0
this is indeed what I'm looking for.
Is there a plugin way to put in "product price percentage" automatically "width * length"?
like the quantity plugin for the cart
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.