X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Disable 'Add to cart' for $0 products (https://forum.x-cart.com/showthread.php?t=49613)

Richardl 09-09-2009 05:42 PM

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

ChristineP 09-10-2009 10:58 AM

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}

ARW VISIONS 09-10-2009 12:20 PM

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}

Richardl 09-10-2009 03:54 PM

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

Richardl 09-10-2009 04:09 PM

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.

ARW VISIONS 09-10-2009 10:09 PM

Re: Disable 'Add to cart' for $0 products
 
try this

{if $product.taxed_price ne 0 || $variant_price_no_empty}

Richardl 09-20-2009 06:22 PM

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.


All times are GMT -8. The time now is 04:32 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.