| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Hide Add to Cart button when a certain Extra Field has a certain value | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() Working on v4.2.2 here.
I've set up an Extra Field (Special is it's name). The value of this field can be Yes or No. If this field is set to Yes, the Add to Cart button should be hidden so customers cannot purchase the product. I have tried various things on customer/main/product.tpl, but have had no luck. e.g. {if $v.active eq "Y" && $v.field eq "Special" && $v.field_value eq "No"}add to cart code here{/if} Adding this to the product.tpl hides the add to cart button on all product pages, whether the 'Special' extra field is set to Yes or No. Any help would be most appreciated. Thanks |
|||||||
#2
|
|||||||||
|
|||||||||
![]() {if $product.extra_fields[0].value ne "Yes"} button code here {/if}
replace number [0] with your fields number in the array
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#3
|
|||||||
|
|||||||
![]() Thanks Steve, but no luck with that code unfortunately.
The button code is showing on all products still. |
|||||||
#4
|
|||||||||
|
|||||||||
![]() Try {if $product.extra_fields.0.value ne "Yes"} button code here {/if}
again replace 0 with your field number
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#5
|
|||||||
|
|||||||
![]() I've been able to work with Extra fields in v4.1.9 with using the loop through. I haven't upgraded to v4.2, so there may be different variable names needed.
{section name=field loop=$extra_fields} {if $extra_fields[field].service_name eq "Special" && $extra_fields[field].field_value eq "No"} {elseif $extra_fields[field].service_name eq "Special" && $extra_fields[field].field_value eq "Yes"} {include file="buttons/add_to_cart.tpl" style="button" href="javascript: if(FormValidation()) document.orderform.submit();"} {/if} {/section} If this doesn't work, you may need to create a .tpl to place in your Extra_Fields folder and use the include to call out the loop through for the product.tpl.
__________________
______________ version 4.1.9 Gold |
|||||||
#6
|
|||||||
|
|||||||
![]() Thanks for your advice Christine. Unfortunately it is still not working.
I will post back once I have the solution. |
|||||||
#7
|
|||||||
|
|||||||
![]() A checkbox (extra field) will either return content or not, not yes or no -- right?
SO --- try this: {if $extra_fields[field].field eq "special" && $extra_fields[field].field_value eq ""}add to cart code here{/if} that is: if the special filed is not checked (it's empty), show the cart code. if the special box is checked (or has any content) the add to cart code will not display. I use 4.1.9 and this code works for me. I also use a checkbox for an extra field. Try it?
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
|
|||
X-Cart forums © 2001-2020
|