Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Disable 'Add to cart' for $0 products

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 09-09-2009, 05:42 PM
 
Richardl Richardl is offline
 

Advanced Member
  
Join Date: May 2009
Location: Australia
Posts: 42
 

Default Disable 'Add to cart' for $0 products

Wonder how to disable 'add to cart' button for products without a price, for example, the 'add to cart' button remains visible but does nothing onclick when the product is out of stock.

cheers
__________________
Version 4.2.1
Reply With Quote
  #2  
Old 09-10-2009, 10:58 AM
 
ChristineP ChristineP is offline
 

eXpert
  
Join Date: Jul 2008
Posts: 310
 

Default Re: Disable 'Add to cart' for $0 products

Products without a price? Try something like this:
{if $product.price ne 0}{include file="buttons/add_to_cart.tpl" style="button" href="javascript: if(FormValidation()) document.orderform.submit();"}
{else}
{if $product.price eq 0}{$lng.lbl_your_label_that_you_want_displayed}
__________________
______________
version 4.1.9 Gold
Reply With Quote
  #3  
Old 09-10-2009, 12:20 PM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: Disable 'Add to cart' for $0 products

How about...

{if $product.taxed_price ne 0}
{include file="buttons/add_to_cart.tpl" style="button" href="javascript: if(FormValidation()) document.orderform.submit();"}
{/if}
__________________
xcart 5.1.2
Reply With Quote
  #4  
Old 09-10-2009, 03:54 PM
 
Richardl Richardl is offline
 

Advanced Member
  
Join Date: May 2009
Location: Australia
Posts: 42
 

Default Re: Disable 'Add to cart' for $0 products

thanks for both replies,

I copied the code into /customer/main/product.tpl

PHP Code:
{if $product.appearance.buy_now_buttons_enabled}
          {if 
$product.forsale ne "B"}
            <
div class="buttons-row buttons-auto-separator">
              {include 
file="customer/buttons/add_to_cart.tpl" type="input" additional_button_class="main-button"

to

PHP Code:
{if $product.appearance.buy_now_buttons_enabled}
          {if 
$product.forsale ne "B"}
            <
div class="buttons-row buttons-auto-separator">
{if 
$product.taxed_price ne 0}
{include 
file="buttons/add_to_cart.tpl" style="button" href="javascript: if(FormValidation()) document.orderform.submit();"}
{/if} 

This method works well only when there is no product variants. New question now is what template(s) should I edit for those hav variants?

cheers
__________________
Version 4.2.1
Reply With Quote
  #5  
Old 09-10-2009, 04:09 PM
 
Richardl Richardl is offline
 

Advanced Member
  
Join Date: May 2009
Location: Australia
Posts: 42
 

Default Re: Disable 'Add to cart' for $0 products

Currently I set the quantity to 0 for those products without a price to disable add to cart.

However, if the first variant on the list is set to be out of stock, then the rest of variants will appear to be out of stock too even they are stocked.

Vice versa, if the first variant is set to be stocked, then the rest of products will still be able to add to cart even they are out of stock.
__________________
Version 4.2.1
Reply With Quote
  #6  
Old 09-10-2009, 10:09 PM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: Disable 'Add to cart' for $0 products

try this

{if $product.taxed_price ne 0 || $variant_price_no_empty}
__________________
xcart 5.1.2
Reply With Quote
  #7  
Old 09-20-2009, 06:22 PM
 
Richardl Richardl is offline
 

Advanced Member
  
Join Date: May 2009
Location: Australia
Posts: 42
 

Default Re: Disable 'Add to cart' for $0 products

Hi Ashley, thank you for your previous replies, even I replaced the code, the 'add to cart' button still work for variants with no price.
__________________
Version 4.2.1
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:52 PM.

   

 
X-Cart forums © 2001-2020