- Posts: 22
- Thank you received: 0
Price = quantity x length x price per meter?
- adm_memphis
-
Topic Author
- Offline
-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.6.5
-- PHP version -- : 5.3.28
-- Browser(s) name and version -- : Chrome Версия 55.0.2883.87 m
We need to sell a certain length profiles. Specify a price per meter, and the choice of the length that the price remained the same (per square meter), and the factor has changed and applied to the final price.
For example, on the product page: the price per square meter € 1, option: The length of 2.5 meters.
In order: 1 Profile of length 2.5 meters of 2.5 €.
price = quantity x length x price per meter
Is that possible?
Please Log in or Create an account to join the conversation.
Yes, it's possible with a custom field of the table "item" and a price override plugin to take into account the value in the custom item field where the customer can enter the length.
In our FAQ, we provide a plugin to handle the same thing but to have the customer enter both the width and the length:
www.hikashop.com/support/documentation/106-faq.html#cart
Adpting the plugin to handle only the length is really easy.
You just need to change :
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- adm_memphis
-
Topic Author
- Offline
- Posts: 22
- Thank you received: 0
Please Log in or Create an account to join the conversation.
- adm_memphis
-
Topic Author
- Offline
- Posts: 22
- Thank you received: 0
The problem is that the price does not change depending on the length value.
Please Log in or Create an account to join the conversation.
Please provide more details about your issue.
As written in the FAQ, the plugin requires item custom fields to let the customer enter the dimensions when he add the product in the cart.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Please Log in or Create an account to join the conversation.
- adm_memphis
-
Topic Author
- Offline
- Posts: 22
- Thank you received: 0
custom_quantity_width_length.php :
<?php
jimport('joomla.plugin.plugin');
class plgSystemCustom_quantity_width_length extends JPlugin{
}
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)){
$quantity = $quantity*$product->length;
}
$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)){
$quantity = $quantity*$product->length;
}
$product->order_product_total_price_no_vat = $product->order_product_price*$quantity;
$product->order_product_total_price = ($product->order_product_price+$product->order_product_tax)*$quantity;
}
Please Log in or Create an account to join the conversation.
In the code you copy pasted, coming from the plugin, you can see that the variable is called "length", but in your screenshots, you can see that the custom field column name is "lenght".
Because of that difference, the plugin won't use the value entered in the custom field.
Please Log in or Create an account to join the conversation.
- adm_memphis
-
Topic Author
- Offline
- Posts: 22
- Thank you received: 0
Please Log in or Create an account to join the conversation.
- adm_memphis
-
Topic Author
- Offline
- Posts: 22
- Thank you received: 0
Please Log in or Create an account to join the conversation.
Sure it is possible.
You will need to perform a view override of the checkout cart view, add a column in the table and display the product length in the corresponding cell.
In the cart products you will find all information coming from the product table ; so you will have the product dimensions.
www.hikashop.com/support/documentation/1...-display.html#layout
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Please Log in or Create an account to join the conversation.
- adm_memphis
-
Topic Author
- Offline
- Posts: 22
- Thank you received: 0
I have successfully created a new column but still could not change value to quantity*length.
Do I need to create new class "hikashop_cart_product_full_length"?
I take the length from custom_quantity_width_length.php (HikaShopCustom Quantity plugin).
Please Log in or Create an account to join the conversation.
In checkout/cart.php the quantity is available in $this->row->cart_product_quantity and the length is available in $this->row->length
The HTML class of the element is not important.
Please Log in or Create an account to join the conversation.
- adm_memphis
-
Topic Author
- Offline
- Posts: 22
- Thank you received: 0
I'm sorry that wasting your time, but I did not reach any success with this problem.
I can't find $this->row->cart_product_quantity and $this->row->length In checkout/cart.php (txt in the attachment).
Still need to output length*quantity value before CART_PRODUCT_UNIT_PRICE.
I not quite understand the code, but understand that I need copy-paste and customize these fragments:
Maybe I can give even some information?
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- adm_memphis
-
Topic Author
- Offline
- Posts: 22
- Thank you received: 0
I used this modification:
I also try to display "Length: 2m" instead
"Length
:2m"
for now I do not know how to do it.
Please Log in or Create an account to join the conversation.
You just need to increase the colspan in this code by the number of columns you add :
Please Log in or Create an account to join the conversation.