[SOLVED] Not defined variants returns free product

  • Posts: 96
  • Thank you received: 14
12 years 1 month ago #69991

Given that you have two characteristics:

#1 Color: Blue, Red
#2 Size: Small, Big

And you have a Product in tree variants:

#1 Product: Blue, Small
#2 Product: Blue, Big
#3 Product: Red, Big

There is something that i think is a problem:

#4 Product: Red, Small is going to be selectable on product page tough it does not actually exists.

I can live with the fact that the variant can be selectable but there's something that i don't understand:

  • The price of that selection (Product: Red, Small in this case) is set to "Free" as default thus creating confusion in the user.
    This can be edited in the language file with changing the "free" field with "The variant you selected is not available" and with some explanation on the product description you can overcome (partially) this situation but this modification means that you're not going to be able to have free products anymore

Despite the fact that the product fortunately gets "Out of stock" message thus making it unavailable to order, the right way to handle this, IMHO, is to have an error message when the user select an unavailable variant, this can replace the "free" price tag.

It could be better to show/hide options based on the selection but this is something that i don't really understand how can be implemented.

So, my question is, how can i override that "free" price with something more coherent when a situation like this occurs without touching language files and loosing the possibility to give products for free?

Thanks in advance.

Last edit: 12 years 2 weeks ago by protorob. Reason: This is a SOLVED Issue

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

  • Posts: 13201
  • Thank you received: 2322
12 years 1 month ago #70100

Hi,

You could edit the view "product / listing_price" and add a check on the variable: "$this->row->product_published".
For example:

if($this->row->product_published == 0){ echo JText::_('NOT_ON_SALE'); ?>

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

  • Posts: 96
  • Thank you received: 14
12 years 1 month ago #70137

This can be an excellent solution.
Could you please help me understanding where exactly in the view "product/listing_price" file should i add the line of code you suggest.
That file is pretty complex.
I don't want to mess everything up.

Thanks in advance

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

  • Posts: 13201
  • Thank you received: 2322
12 years 1 month ago #70143

At the top of the file, replace the lines:

  if(empty($this->row->prices)){
    echo JText::_('FREE_PRICE');
  }else{

By:
  if($this->row->product_published == 0){ 
       echo JText::_('NOT_ON_SALE')
  }
  elseif(empty($this->row->prices)){
    echo JText::_('FREE_PRICE');
  }else{

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

  • Posts: 96
  • Thank you received: 14
12 years 4 weeks ago #70791

You're awesome.
Thanks a lot.

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

  • Posts: 96
  • Thank you received: 14
12 years 3 weeks ago #71924

Excuse me, don't know why but it is not working.

First let me make a little mistake in the code you gave me, there was a semicolon missing at the end of ('NOT_ON_SALE')

so the right one should be:

  if($this->row->product_published == 0){ 
       echo JText::_('NOT_ON_SALE');
  }
  elseif(empty($this->row->prices)){
    echo JText::_('FREE_PRICE');
  }else{

This way the modification makes me open the website, without that semicolon everything crashes.

****

I have made the mod but i still get free price instead of non available....

What am i doing wrong?

Thanks in advance. If you need i can give you access to backoffice/front end

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

  • Posts: 13201
  • Thank you received: 2322
12 years 3 weeks ago #72084

Hi,

My apologize, for the variants you have to edit the view "product / quantity" and replace the line:

echo JText::_('NO_STOCK');
With the code:
$productClass = hikashop_get('class.product');
$variant = $productClass->get($this->row->product_id);
if(isset($variant->product_published) && $variant->product_published == 0 && !empty($this->row->characteristics)){
	echo JText::_('NOT_AVAILABLE');
}else{
        echo JText::_('NO_STOCK');
}

Last edit: 12 years 3 weeks ago by Xavier.

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

  • Posts: 96
  • Thank you received: 14
12 years 3 weeks ago #72095

should i left the mods i made on the product_price view file?

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

  • Posts: 13201
  • Thank you received: 2322
12 years 3 weeks ago #72097

You can remove the previous modifications. It wasn't useful in that case :/

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

  • Posts: 96
  • Thank you received: 14
12 years 3 weeks ago #72100

nope, not working.
I've just got a subscription to the business version, i will update and then we continue talking about this in some minutes, i can send you a PM with access to the front end so you can see what i'm experiencing.

See you later.

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

  • Posts: 82818
  • Thank you received: 13361
  • MODERATOR
12 years 3 weeks ago #72366

Note that Xavier won't be back until Monday. If it can't wait until then, then please use our contact form.

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

  • Posts: 96
  • Thank you received: 14
12 years 2 weeks ago #72384

No problem, i can wait 'till Monday.
Thanks.

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

  • Posts: 13201
  • Thank you received: 2322
12 years 2 weeks ago #72660

Hi,

I tried the solution given again, and for me when a variant is not enabled, the message "Not available" is displayed instead of "No stock".

Could you give us a front & back end access ?

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

  • Posts: 96
  • Thank you received: 14
12 years 2 weeks ago #72793

Hi Xavier, i have sent you a PM with access to the website.

This is my csv

File Attachment:

File Name: Hikashop_I...0-29.csv
File Size:39 KB

Attachments:
Last edit: 12 years 2 weeks ago by protorob.

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

  • Posts: 13201
  • Thank you received: 2322
12 years 2 weeks ago #72801

Hi,

Ok I see from where come the problem.
I was thinking that the variants not available were unpublished, and not "not present" in your shop.

If you only unpublish the variant the modification given should work fine.
Tomorrow I will find another solution to your problem.

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

  • Posts: 96
  • Thank you received: 14
12 years 2 weeks ago #72811

yes, i prefer to wait.
because i have created two characteristic for the whole international category, one for the volume in Lt. of the package and another one for the color palette of that brand, if i simply create all possible variants and then deactivate those ones i don't need my csv's are going to be ten times bigger and mainly full of unavailable variants, and that add a lot of unnecessary data on the database.

I'm following for your answer, I'm preparing a product import for around 5K products and i need to define the characteristics the most efficient and generalist possibly so i can use them in more than one product category and this situation of the non available characteristics is going to happen very frequently.

Have a good day and thanks again for your support.

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

  • Posts: 13201
  • Thank you received: 2322
12 years 2 weeks ago #73040

Hi,

Hope this time it's the good solution :)

Try to replace the code:

echo JText::_('NO_STOCK');
By just:
					if(!isset($variant))
						echo JText::_('NOT_AVAILABLE');
					else
						echo JText::_('NO_STOCK');

In the view "product / quantity".

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

  • Posts: 96
  • Thank you received: 14
12 years 2 weeks ago #73171

Hi Xavier,

The code is not exactly as you write it, it should be:

if(!isset($variant))
	echo JText::_('PRODUCT_NOT_AVAILABLE');
else
	echo JText::_('NO_STOCK');

It actually shows the string in the product quantity part of the product page but it only works if the cart functionality is activated (it does not work if you're in catalog mode) this is not cool because we're still strugglin' with legal paperwork for activate the cart options so we need to open right now only with the button for "ask info" and showing prices.

Is possible to make something similar but with the product>listing_price view?
So i can have the PRODUCT_NOT_AVAILABLE message instead of the FREE_PRICE i have now when i select an non existing variant?

This issue is delaying me to continue the content population and i have a really big quantity of products.
I don't want to find myself creating all my product listing again, i have done this at least 3 times in the last year and when you have 5K products is a real pain so any advice is welcome.

Thanks

Last edit: 12 years 2 weeks ago by protorob.

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

  • Posts: 13201
  • Thank you received: 2322
12 years 2 weeks ago #73311

Hi,

In catalog mode, the view "product / quantity" is loaded.
Try to add the code:

if($this->row->product_published != 1){echo "Not Available";}
At the top of the file, between <?php ?> tags.

If it doesn't work thanks to give me a screenshot of your configuration, by this way I will be able to reproduce the problem on my end.

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

  • Posts: 96
  • Thank you received: 14
12 years 2 weeks ago #73337

Did you receive the PM with the access to my backend?

Whatever, i'll be making this mods in the afternoon, i'll be back to you then.

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

Time to create page: 0.101 seconds
Powered by Kunena Forum