Display price per unit but sell per box qty

  • Posts: 14
  • Thank you received: 0
11 years 6 months ago #99438

Hi

I want to be able to sell only whole cartons but display price per unit on initial product display.

e.g.

Producta A. has price per unit of $1 but these come in boxes of 50. So minimum order is by box of 50 and price is $50 per box.

Product B. has price per unit of $2 but come in boxes of 20. So minimum order is by box of 20 and price is $40 per box.

Any ideas?

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

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 6 months ago #99548

Hi,

There are options in the product edition page:
- Minimum quantity per order
- Maximum quantity per order

So you can set a minimum quantity of "50" for Product A and "20" for Product B.

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.

  • Posts: 14
  • Thank you received: 0
11 years 6 months ago #99570

Hi Jerome,

Setting minimum order quantity doesn't work for a couple of reasons.

Lets look at use case A

Producta A. has price per unit of $1 but these come in boxes of 50. So minimum order is by box of 50 and price is $50 per box.


Problem 1. Needs to only be able to order by box.
If I set minimum order qty at 50 then a customer can also order qty 51 in his cart. This is not what we want. The next order qty possible is 100 (i.e. 2 boxes)


Problem 2. Breaks shipping calculation
Am using Australia Post shipping plugin.
So the shipping is calculated on the box dimensions and weight.


Surely my client is not the only one who will only sell by the box but also wants to display price per unit?

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

  • Posts: 13201
  • Thank you received: 2322
11 years 6 months ago #99698

Hi,

I think that the best solution in your case is to do an override of the quantity input.
Add custom fields on your products with packagings (checkboxes), in your case with the values "20 - 40 - 50 - 60 - 80 - 100 - 120 - 140 - 150 - 160 ..."

And for each products select the available quantities, then override the input field to make a single dropdown with the previously checked values.
By this way the customer will be only able to select a "box" quantity.
Here is the documentation for the override:
www.hikashop.com/fr/support/documentatio...tation.html#override

Else you can set the price per box, and use the "Retail price" to display the price per unit with just translation override.

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

  • Posts: 14
  • Thank you received: 0
11 years 6 months ago #100142

here another customer selling box .... :)
I tried to follow the last suggestion by Xavier going to use retail (MSRP) price for unit and override text language.
I tried also the same using a custom product field.
All looks good , no problem in the product listing view (DIV) where I can show the fields I need (thanks again to Nicolas for his help).
Now problem arise since the customer ask to see this field at least in the email notification order.
Would be nice to have it in the order and cart view too.
Is this a big change to do or with some suggestion we could also reach this objective ?
I tried to check the email structure but it seems to me that it take the data (correctly) from the order table , not from Product table .. so before to go ahead I prefer to have your point of view.
I guess If we could at least have this in the notification of order creation , then the data could be taken from product table without take any risk tho have incoherent data if the product field is modified after the order.
thanks in advance for any suggestion

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

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 6 months ago #100302

Hi,

If you want to display a product custom field in the email, you have to edit the email content and display the custom field into (with some PHP).
Same thing for the cart view. But this time you would need to edit the view and not the email.

This is not really big changes, you have to load the full product data (which is done in the cart but not in the email) in order to get the "$product" object (in the email you would have the "order product").
With the product object you could access directly to the custom fields values like: $product->my_custom_field
To load a product, you need the product id (you have this information in the "order product") and load it with the product class:

$product_id = /* ... */;
$productClass = hikashop_get('class.product');
$product = $productClass->get( $product_id );

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.

  • Posts: 14
  • Thank you received: 0
11 years 6 months ago #100434

@ Jerome, gberte67, Xavier

thanks to all for your suggestions. Will experiment with them and let you know how I go.

All the best.

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

  • Posts: 14
  • Thank you received: 0
11 years 6 months ago #101541

Hi Jerome , thanks for your suggestion. I tried to follow your suggestion but unfortunately my current level of knowdledge is still not enough to apply what you clearly exposed as general guidelines.
SO I would ask you if you could give me further help to put in place these modification or if there are other view where this kind of customization (load full data from another table to read its field ) is already in use that I can keep as example to analyze myself and learn the process.
Thanks in advance

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

  • Posts: 13201
  • Thank you received: 2322
11 years 6 months ago #101662

Hi,

As Jerome said you need the product_id which is in the order, for the email the product id is in the var: $item->order_product_name.

So you have to add the code:

$product_id = $item->order_product_name;
$productClass = hikashop_get('class.product');
$product = $productClass->get( $product_id );
echo $product->customfield_name;

Where "customfield_name" is the name of your custom field. You just have to replace that and it will display the content of this custom field.

If you want to display all the custom fields values, you can use:
$product_id = $item->order_product_name;
$productClass = hikashop_get('class.product');
$product = $productClass->get( $product_id );
foreach($product as $key => $value){
    if(!preg_match('/product/',$key) && !empty($value)){
        echo '$key: '.$value;
    }
}

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

  • Posts: 14
  • Thank you received: 0
11 years 6 months ago #102125

Hi Xavier , Jerome ; I tried to apply your code but for the moment still doesn't work (sure I'm doing something wrong :( )
I put this code :

<td>
<?php
$product_id = $item->order_product_name;
$productClass = hikashop_get('class.product');
$product = $productClass->get( $product_id );
echo $product->product_type;
?>
</td>


Just between order product code and price , after the line 147 of the original PHP file.
If I set the debug ON , I can see in the email at the position where the data has to be shown this error :
Notice: Trying to get property of non-object in X:\xampp1-7\htdocs\hika\media\com_hikashop\mail\order_creation_notification.html.modified.php on line 166

(line 166 it's the line I add where there is the statement : echo $product->product_type;

I used a standard field for first check instead of a custom product field but like expected the error is the same.

I have also a question related to the code you suggest :
why you use : $product_id = $item->order_product_name; to identify the product ?
Since in the product table I have sometime more than one product with the same "order_product_name" I thought to use the "order_product_code" that is never used more than one time. Am I wrong ?

Thanks a lot for your help.

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

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 6 months ago #102385

Hi,

Xavier was a bit too fast. The id of the product is not in the column order_product_name but in the column product_id.
So the first line should actually be:
$product_id = $item->product_id;

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

  • Posts: 14
  • Thank you received: 0
11 years 6 months ago #102722

thanks a lot to everybody. Following your suggestion It works like expected for email Order Administration notification , email Order creation notification and cart view.

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

Time to create page: 0.105 seconds
Powered by Kunena Forum