Variants and Prices

  • Posts: 250
  • Thank you received: 7
10 years 3 months ago #202289

-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.1

Using variants of products a lot and have found that if I set a price for variants these aren't listed if the parent product doesn't have a price.

The parent product isn't a real product so there isn't a valid price for it, if I then give a the parent a price and a variant doesn't have a price listed it assumes the price of the parent. This is wrong in my case and prevents me listing variants without a price, for example variants that we don't currently stock but would like to stock so that a customer may pre-order.

The behaviour that would work best in my situation ...

If variants have prices these are listed, regardless of whether the parent has a price, and if the variant doesn't have a price the "price on request" notice is shown.

Thanks,

Ian

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

  • Posts: 13201
  • Thank you received: 2322
10 years 3 months ago #202296

Hi,

By default, if the main product doesn't have price, and the variants does, we use the variant price automatically.
Please give us screenshots of the settings of one of these products.

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

  • Posts: 250
  • Thank you received: 7
10 years 3 months ago #202418

If the parent product doesn't have a price none of the variant prices are displayed.

This is parent product with a price ...



Variants with all prices displayed ...


Now delete parent price ....


Variant prices no longer displayed...


Now set a price for the parent again....


And delete the price for a variant....


Now the variant displays the price of the parent (which is wrong) ...


Regards,

Ian





If a variant doesn't have a price, it uses the price of the parent product, which is wrong, it should show an "ask for price" message.

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

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 3 months ago #202429

Hi,

Thank you for the details and screenshots.

No, it is not wrong that the variant uses the parent price if you don't configure a price in the variant.
That's how it should be to avoid the merchant to enter the price in each variant when the price is the same for all of them.
And actually, when you set no price on the main product, the prices still display on the product page. However, this is not the case with the "list" display method of characteristics and we didn't know about that. We've check the code and indeed, we could reproduce the issue which comes from the code:

if(!empty($this->element->main->prices)) {
			foreach($variant->prices as $price) {
which should actually be:
if(!empty($variant->prices)) {
			foreach($variant->prices as $price) {
in the file "show_block_characteristic that you can edit via the menu Display>Views.
Then, simply don't set a price in the main product and only to the variants with a price and it will work like you want.

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

  • Posts: 250
  • Thank you received: 7
10 years 3 months ago #202714

Hi Nicolas,

In your scenario I agree the behaviour is not wrong, but in mine it is as the variants do not all have the same price.

I have made the change you suggest and am nearly there, so if I don't have a main price set I do see the variant prices listed. However if a variant doesn't have a price it is now shown as "free", which is logical, but is there a way I can get an "ask for price" message without losing the ability to also list free products?

What I am trying to do is show products that we don't currently stock and so haven't fixed a price, then if there is customer interest we can order the product and quote a price. The alternative is to not list the product at all and then we won't know if there is actually any demand for it.

Many thanks for all the help.

Ian

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

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 3 months ago #202733

Hi,

Normally, I would recommend to use a translation override in order to change that "free" text by a "ask for price" text:
hikashop.com/download/languages.html#modify

But in that case it will also affect the other products where you do want to display "free" and not "ask for price".
So the solution would be to edit the file "listing_price" of the view "product" via the menu Display>views and change the code:

echo JText::_('FREE_PRICE');
to something like for example:
if($this->row->product_type=='variant'){
 echo "Ask for price";
}else{
 echo JText::_('FREE_PRICE');
}
That way, when variants don't have a price, it will appear as "ask for price" and when main products don't have a price, it will appear as "free".

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

Time to create page: 0.112 seconds
Powered by Kunena Forum