- Posts: 9
- Thank you received: 0
How to add a button below the "add to cart"
15 years 7 months ago #7114
by 49grill
How to add a button below the "add to cart" was created by 49grill
I was wondering if there is a native function within HikaShip to be able to place a "button" that is formated like the "add to cart" button, but have it right below the "add to cart" button.
I want to let my customers download my product, so I was hoping that I could add a button that then upon "click" would launch me into the download page.
Can Hika do this or would I have to add custom code? And if I had to add custom code, where would I need to put it into the template?
Thanks in advance,
49grill
I want to let my customers download my product, so I was hoping that I could add a button that then upon "click" would launch me into the download page.
Can Hika do this or would I have to add custom code? And if I had to add custom code, where would I need to put it into the template?
Thanks in advance,
49grill
Please Log in or Create an account to join the conversation.
15 years 7 months ago #7118
by nicolas
Replied by nicolas on topic Re: How to add a button below the "add to cart"
There is no function within hikashop for that.
If you want to add a button below the "add to cart" button, you can edit the file quantity of the view product.
The button is displayed using the code:
echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$this->row->product_max_per_order);
If you want to use your own link, you can do like this:
echo $this->cart->displayButton(JText::_('MY_BUTTON'),'my_button',$this->params,$link,'window.location = \''.$link.'\';return false;','');
If you want to add a button below the "add to cart" button, you can edit the file quantity of the view product.
The button is displayed using the code:
echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$this->row->product_max_per_order);
If you want to use your own link, you can do like this:
echo $this->cart->displayButton(JText::_('MY_BUTTON'),'my_button',$this->params,$link,'window.location = \''.$link.'\';return false;','');
Please Log in or Create an account to join the conversation.
15 years 7 months ago #7508
by 49grill
Replied by 49grill on topic Re: How to add a button below the "add to cart"
Hello Nicolas,
Thanks for the code, but I have tried several times, however it does not work..below you will sere where I have inserted the 2nd piece of code you provided, but the "My Button" still does not display:
<?php
/**
* @package HikaShop for Joomla!
* @version 1.4.4
* @author hikashop.com
* @copyright (C) 2010 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?>
<?php
if(!$this->params->get('catalogue')){
if(!empty($this->row->has_options)){
echo $this->cart->displayButton(JText::_('CHOOSE_OPTIONS'),'choose_options',$this->params,hikashop::completeLink('product&task=show&product_id='.$this->row->product_id.$this->itemid),'window.location = \''.hikashop::completeLink('product&task=show&product_id='.$this->row->product_id.$this->itemid).'\';return false;','');
}elseif($this->config->get('display_add_to_cart_for_free_products') || !empty($this->row->prices)){
$url = '';
if(empty($this->ajax)){
$this->ajax = 'return hikashopModifyQuantity(\''.$this->row->product_id.'\',field,1,0);';
}
if($this->row->product_sale_end && $this->row->product_sale_end<time()){
?>
<span class="hikashop_product_sale_end">
<?php echo JText::_('ITEM_NOT_SOLD_ANYMORE'); ?>
</span>
<?php
}elseif($this->row->product_sale_start && $this->row->product_sale_start>time()){
?>
<span class="hikashop_product_sale_start">
<?php
echo JText::sprintf('ITEM_SOLD_ON_DATE',hikashop::getDate($this->row->product_sale_start,$this->params->get('date_format','%d %B %Y')));
?>
</span>
<?php
}else{
if($this->row->product_quantity==-1){
?>
<span class="hikashop_product_stock">
<?php
echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$this->row->product_max_per_order);
}elseif($this->row->product_quantity>0){
?>
<?php
echo $this->cart->displayButton(JText::_('MY_BUTTON'),'my_button',$this->params,$link,'window.location = \''.$link.'\';return false;',''); ?>
<span class="hikashop_product_stock">
<?php
echo JText::sprintf('X_ITEMS_IN_STOCK',$this->row->product_quantity);
echo '<br/>';
$config =& hikashop::config();
if($config->get('button_style','normal')=='css'){
echo '<br />';
}
echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$this->row->product_max_per_order);
}else{
?>
<span class="hikashop_product_no_stock">
<?php
echo JText::_('NO_STOCK');
}?>
</span>
<?php
}
}
}
?>
<br/>
Thanks for the code, but I have tried several times, however it does not work..below you will sere where I have inserted the 2nd piece of code you provided, but the "My Button" still does not display:
<?php
/**
* @package HikaShop for Joomla!
* @version 1.4.4
* @author hikashop.com
* @copyright (C) 2010 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?>
<?php
if(!$this->params->get('catalogue')){
if(!empty($this->row->has_options)){
echo $this->cart->displayButton(JText::_('CHOOSE_OPTIONS'),'choose_options',$this->params,hikashop::completeLink('product&task=show&product_id='.$this->row->product_id.$this->itemid),'window.location = \''.hikashop::completeLink('product&task=show&product_id='.$this->row->product_id.$this->itemid).'\';return false;','');
}elseif($this->config->get('display_add_to_cart_for_free_products') || !empty($this->row->prices)){
$url = '';
if(empty($this->ajax)){
$this->ajax = 'return hikashopModifyQuantity(\''.$this->row->product_id.'\',field,1,0);';
}
if($this->row->product_sale_end && $this->row->product_sale_end<time()){
?>
<span class="hikashop_product_sale_end">
<?php echo JText::_('ITEM_NOT_SOLD_ANYMORE'); ?>
</span>
<?php
}elseif($this->row->product_sale_start && $this->row->product_sale_start>time()){
?>
<span class="hikashop_product_sale_start">
<?php
echo JText::sprintf('ITEM_SOLD_ON_DATE',hikashop::getDate($this->row->product_sale_start,$this->params->get('date_format','%d %B %Y')));
?>
</span>
<?php
}else{
if($this->row->product_quantity==-1){
?>
<span class="hikashop_product_stock">
<?php
echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$this->row->product_max_per_order);
}elseif($this->row->product_quantity>0){
?>
<?php
echo $this->cart->displayButton(JText::_('MY_BUTTON'),'my_button',$this->params,$link,'window.location = \''.$link.'\';return false;',''); ?>
<span class="hikashop_product_stock">
<?php
echo JText::sprintf('X_ITEMS_IN_STOCK',$this->row->product_quantity);
echo '<br/>';
$config =& hikashop::config();
if($config->get('button_style','normal')=='css'){
echo '<br />';
}
echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$this->row->product_max_per_order);
}else{
?>
<span class="hikashop_product_no_stock">
<?php
echo JText::_('NO_STOCK');
}?>
</span>
<?php
}
}
}
?>
<br/>
Please Log in or Create an account to join the conversation.
15 years 7 months ago #7511
by nicolas
Replied by nicolas on topic Re: How to add a button below the "add to cart"
You added the my_button code just after the line
}elseif($this->row->product_quantity>0){
which means that it will only be displayed if the stock of your product is not unlimited. You also need to set the variable $link with the link where you want your users to be redirected when clicking on the button.
}elseif($this->row->product_quantity>0){
which means that it will only be displayed if the stock of your product is not unlimited. You also need to set the variable $link with the link where you want your users to be redirected when clicking on the button.
Please Log in or Create an account to join the conversation.
15 years 7 months ago #7518
by 49grill
Replied by 49grill on topic Re: How to add a button below the "add to cart"
Yep. Great.
that totally worked now.
Thank you so much.
However the quantity box with the default "1" and the +/- shows up to the left of the "my button"
Why is that? and how do I remove those two item?
that totally worked now.
Thank you so much.
However the quantity box with the default "1" and the +/- shows up to the left of the "my button"
Why is that? and how do I remove those two item?
Please Log in or Create an account to join the conversation.
15 years 7 months ago #7519
by nicolas
Replied by nicolas on topic Re: How to add a button below the "add to cart"
That's because it's the way it's made on the product page.
What do you mean by "those two item" ?
What do you mean by "those two item" ?
Please Log in or Create an account to join the conversation.
15 years 7 months ago #7523
by 49grill
Replied by 49grill on topic Re: How to add a button below the "add to cart"
remove the "quantity box" and the "+/-" for that row?
Please Log in or Create an account to join the conversation.
15 years 7 months ago #7524
by nicolas
Replied by nicolas on topic Re: How to add a button below the "add to cart"
Ah yes,
You can use that code instead then:
$empty='';
$params = new JParameter($empty);
$this->cart->displayButton(JText::_('MY_BUTTON'),'my_button',$params,$link,'window.location = \''.$link.'\';return false;','');
You can use that code instead then:
$empty='';
$params = new JParameter($empty);
$this->cart->displayButton(JText::_('MY_BUTTON'),'my_button',$params,$link,'window.location = \''.$link.'\';return false;','');
Please Log in or Create an account to join the conversation.
15 years 7 months ago #7543
by 49grill
Replied by 49grill on topic Re: How to add a button below the "add to cart"
Perfect. Thanks so much. Greatly appreciated
Please Log in or Create an account to join the conversation.
Time to create page: 0.200 seconds