Adding a "Please select" to variants

  • Posts: 100
  • Thank you received: 1
11 years 1 week ago #94858

HI

I have created a characteristic called TimeSlots and created two value : 2pm - 4pm and 6pm - 8pm.

I have created two variant products and displayed them in a drop down box.

I would like to be able to display a "please select" in the combo box rather than the first variant product.




Thanks


Patrick

Attachments:

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

  • Posts: 12953
  • Thank you received: 1778
11 years 1 week ago #94966

Hi Patrick,

My solution would be to :
- Go to "Hikashop->Display->Views"
- Edit the show_block_characteristic file of the product view of your front-end template
- Change these lines :

<?php


if (!empty ($this->element->characteristics)) {
?>
by :
<?php


if (!empty ($this->element->characteristics)) {
echo "Please select";
?>

Hope this will help you a little :).

Last edit: 11 years 1 week ago by Mohamed Thelji.

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

  • Posts: 100
  • Thank you received: 1
11 years 1 week ago #95026

HI Mohamed

I tried that but it did not seem to work.

I would have thought I would needed to append the "Please select" as a sql query with a union join to the query that retrieves the variant data. Could you tell me which file the sql for the variant date is called from.

Thanks

Patrick

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

  • Posts: 2334
  • Thank you received: 403
11 years 1 week ago #95215

Hi there,

The Mohamed solution wasn't the best for your case.
I think you should simply add a new variant called "Please Select" with no stock and no price.
So this variant would be displayed but people won't be able to buy it and will have to select one of your variants ;)

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

  • Posts: 100
  • Thank you received: 1
11 years 1 week ago #95244

HI Eliot

Thank you for your suggestion. I already thought of doing that. However, this would work, if there are variant products to choose. But once all the variants have been sold/bought, then it would look silly to have a "Please select", with no variants to choose from.

If I can somehow hide this option when there are no variant products to display then your solution would work fine.

Thanks for the suggestion though.

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

  • Posts: 81379
  • Thank you received: 13037
  • MODERATOR
11 years 1 week ago #95256

Hi,

The solution proposed by Eliot is indeed better.

Regarding the hiding of the characteristics if only the default value is left in the dropdown, you can add the code:

if(count($this->values)===1) return 'Out of stock';

before the line:
$html = JHTML::_('select.'.$characteristic_display.'list', $this->values, $map, 'class="inputbox" size="1"'.$this->options, 'value', 'text', (int)$value,$id );

in the file administrator/components/com_hikashop/types/characteristic.php

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

  • Posts: 356
  • Thank you received: 7
  • Hikashop Business
5 years 1 month ago #303787

Hi,

What if you had the notify of when back in stack feature on? Then adding a "please select" variant wouldn't work as it would look like the product is out of stock when actually you've just set the "please select" variant with no stock. Anyway around this?

Cheers.

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

  • Posts: 81379
  • Thank you received: 13037
  • MODERATOR
5 years 1 month ago #303790

Hi,

Instead of using the stock of the variant, you could set the "sale date" start value in the remote future or the end value in the past. It would do the same but with a different message (that you can customize with a translation override), but the "notify me" button wouldn't display for the "please select" choice.

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

Time to create page: 0.113 seconds
Powered by Kunena Forum