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)
-   -   Hiding the Add to Cart button for certain parts (https://forum.x-cart.com/showthread.php?t=58722)

cflsystems 04-15-2011 10:14 AM

Re: Hiding the Add to Cart button for certain parts
 
Quote:

Originally Posted by duke57
I basically created an extra field with the service name: NO_ADD_CART, and the field name: "No Add To Cart Button", for every product.

This is the code that I placed in the template common_files/customer/buttons/add_to_cart.tpl which is making the add to cart button dissappear for every product on the site.

{*
$Id: add_to_cart.tpl,v 1.1 2010/05/21 08:32:02 joy Exp $
vim: set ts=2 sw=2 sts=2 et:
*}
{if $extra_fields.field eq "NO_ADD_CART" and $extra_fields.field_value ne "no"}
{include file="customer/buttons/button.tpl" button_title=$lng.lbl_add_to_cart additional_button_class=$additional_button_class|c at:' add-to-cart-button'}
{/if}


$extra_fields is an array, you have to loop through it or use the exact array element #, you can't use $extra_fields.field as there is no such thing

{foreach from=$extra_field item=ef}
{if $ef.service_name eq "NO_ADD_CART" && $ef.field_value ne ""}
YOUR CODE HERE
{/if}
{/foreach}

duke57 04-18-2011 06:53 AM

Re: Hiding the Add to Cart button for certain parts
 
Thanks for the pointers with the code. I was thinking of these variables the wrong way. I'll be changing it now.


All times are GMT -8. The time now is 01:11 AM.

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