How to create 2 Different Add To Cart Buttons

  • Posts: 24
  • Thank you received: 0
13 years 5 months ago #18678

Hi

I would like to use a different add-to-cart button for each product category or at least have different wordings for the add-to-cart buttons in each category. Hope you can help??

Thanks

Tony

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
13 years 5 months ago #18691

Hi,

You should use a button template override: www.hikashop.com/support/documentation/6...tation.html#override
You will have to get the id of the product on the page (or the id of the category for the products listing on the page) from the request and then load the category of the product ( or the category from the category id of the request ) and then display the button accordingly.

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

  • Posts: 24
  • Thank you received: 0
13 years 2 weeks ago #29460

Hi

I am wanting to show an alternative text for the add to cart link. I currently have an override ADD_TO_CART="Request CA" but would like to show different text for another category. Is this possible in this code?

<?php

if($this->params->get('show_price')){
$this->setLayout('listing_price');
echo $this->loadTemplate();
}
if($this->params->get('add_to_cart')){
?><form action="<?php echo hikashop::completeLink('product&task=updatecart'); ?>" method="post" name="hikashop_product_form_<?php echo $this->row->product_id.'_'.$this->params->get('main_div_name'); ?>"><?php
$this->ajax='';
$this->setLayout('quantity');
echo $this->loadTemplate();
?>
<input type="hidden" name="product_id" value="<?php echo $this->row->product_id; ?>" />
<input type="hidden" name="add" value="1"/>
<input type="hidden" name="ctrl" value="product"/>
<input type="hidden" name="task" value="updatecart"/>
</form><?php
}
?>

Or do I need a programmer to do as you have suggested above?

Thanks

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
13 years 2 weeks ago #29469

Hi,

If you just want to change the text of the button, it can be done without a button template override.

You can change the code :
echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$this->row->product_max_per_order,$this->row->product_min_per_order);

in the file "quantity" of the view "product" via the menu Display->Views.
But that still requires some programming skills to load the category of the current product and change the JText::_('ADD_TO_CART') based on the category...

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

  • Posts: 24
  • Thank you received: 0
13 years 2 weeks ago #29482

Does Hikashop offer a service for this?

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
13 years 2 weeks ago #29496

Sure, you can use our contact form to request a quote. We should be able to do that for you for a small fee.

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

Time to create page: 0.064 seconds
Powered by Kunena Forum