Display variant options on product listing

  • Posts: 7
  • Thank you received: 0
13 years 8 months ago #10827

Hi there,

I've been searching for an answer to my question on the forum, and haven't quite found a solution yet. However, I do apologize if this question is redundant in any way, and if I have missed any documentation or help.

Also, if it's necessary to help, I'm using the "Essentials" version.

Basically what I'm trying to do is cut out the product page from the entire purchasing process. I'm using {loadposition} to load only one product in each article, and each product will require variants. As of now, in the article, it displays the "Show Options" button which then takes them to the product page, which then displays the "Add to Cart" button. My products are so simple in nature, that the product page does not show the customer any new information, except the ability to choose their option/variant. To save the customer time, and to reduce this process, I'm hopeful that I can get the variants to display on the product listing, and that the button would no longer say "Show Options," but would say "Add to Cart" and take them directly to the cart, much like products that don't have variants.

I read another post here on the forum, where you gave this response:

Variants options aren't displayed on the listing of products so if you have products with variants you should indeed have the user go in the product page so that he can select the variant before adding to the cart.

I understand what you want to do but we wanted to avoid loading all the variants data with all the processing behind for each product of the listing because if you start having a lot of products displayed and a lot of variants for each, it's just too much. So we decided to just do it on the product page. It's not really a bug, that's just the way it is.


This makes sense to me, especially if you are loading many products on one page, but like I mentioned, I will only ever have one product on one page. And I understand based on your response above, that what I'm asking for seems to go against the grain of HikaShop, but I'm extremely hopeful you can help me achieve a solution.

A couple of theories I have are below, but honestly, I'm no PHP expert so I don't know if this is even possible.

1) Display the product page in the {loadposition} rather than the product listing. (Because both the product listing and product page have the exact same info except the variants & quantity, it makes sense logically to me, to remove the product listing from the entire process, instead of the product page).

2) Rework what the module displays. For instance, there are options in the module to display Random Items, 'Add to Cart' button, Link to product page, and Display price. Could we have an option to display variants? If this is possible, could we change the "Show Options" button to "Add to Cart" and direct to the cart, rather than the product page? I understand this would take quite a bit of code rework, and my guess for a place to start would be to change/add these things:
  • Add something like this to the modules/zzparams.php view, perhaps?
    <td>
    <?php echo $this->orderType->display($this->control.'[characteristics]',$this->characteristics,'product');?>
    </td>
  • Add something like this to the product listing view:
    <?php
    		}
    		if(!empty($this->element->characteristics)){
    			?><span id="hikashop_product_characteristics" class="hikashop_product_characteristics"><?php 
    			echo $this->characteristic->displayFE($this->element,$this->params);
    			?></span><br /><?php 
    		}
    		$form = '';
    		?>
  • Somehow change the "Show Options" text and destination?? Not sure where to do this.

Obviously, these are my wild guesses, but I honestly have no idea where to start and how much I'm asking really requires. If possible, could you detail what code needs to be added or changed to make this possible? I'd really appreciate it!

Thanks for all of your hard work -- your product is amazing!

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

  • Posts: 7
  • Thank you received: 0
13 years 8 months ago #10828

It appears the PHP code was stripped from my original post above. I'll try again to use the code tags, and see if it works.

<td>
<?php echo $this->orderType->display($this->control.'[characteristics]',$this->characteristics,'product');?>
</td>
<?php
		}
		if(!empty($this->element->characteristics)){
			?><span id="hikashop_product_characteristics" class="hikashop_product_characteristics"><?php 
			echo $this->characteristic->displayFE($this->element,$this->params);
			?></span><br /><?php 
		}
		$form = '';
		?>

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
13 years 8 months ago #10849

Hi,

Option 1 would be in the realm of possibilities. You could just create a new hikashop content module and change the code in it in order to display the file show of the view product.
Right now, you have that line:
echo hikashop::getLayout($params->get('content_type'),'listing',$params,$js);

that you would replace by:
echo hikashop::getLayout('product','show',$params,$js);

Before that, you would have to add something like this:
JRequest::setVar('cid',XXX);
where XXX is the id of your product so that the system knows which product to load.

Option 2 is not possible. Just adding a few lines in the views to display the data is not enough because the data itself is not loaded. That would require a big chunk of code to be added...

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

Time to create page: 0.059 seconds
Powered by Kunena Forum