| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Extra Fields in Cart using 4.2.2 | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Extra Fields in Cart using 4.2.2
Hi,
I have been using an extra product field to apply some logic successfully on product list and product pages, but have now got to try and do the same at the cart stage. I'm OK with the Smarty side of things, but not so up on the PHP side of things. I'm assuming I will need to add an additional query somewhere in a PHP file to make the fields available in a template. If anyone has done this and can provide any advice and examples of what to add, where and how to pick it up in the template, it would be very much appreciated. Thanks very much Ian Last edited by icooper : 10-29-2009 at 07:06 AM. Reason: Solved |
|||||||
#2
|
|||||||
|
|||||||
Re: Extra Fields in Cart using 4.2.2
All sorted with many thanks to mikalou's reply in this thread.
http://forum.x-cart.com/showthread.php?t=40018&highlight=outputting+extra+ fields+on+cart I was initially looking to retrieve all key fields and select the field I wanted in the template using smarty, but I changed the suggested SQL mod to func.cart.php to also include the extra_fields table, allowing me to retrieve the specific value by service name. |
|||||||
#3
|
|||||||
|
|||||||
Re: Extra Fields in Cart using 4.2.2
I'm having trouble getting this to work in 4.2. Extra field has been created, made the php changes and added info to cart.tpl, but nothing shows. Could you possibly point me in the right direction? Where exactly did you add the info in cart.tpl to make it show?
__________________
hollaratbear Xcart Gold 4.2.1 Newbie |
|||||||
#4
|
|||||||
|
|||||||
Re: Extra Fields in Cart using 4.2.2
The solution outlined did not work for me as I needed more than one extra field, actually a set of them. You'll have to know a little about smarty, php and SQL to "understand and adapt" though
Here's my mod, it works for 4.3 but ymmv. Look into module /xcart/include/func/func.cart.php (on 4.3) around line 1775 you will find the following, add the following code (the one that starts with //@willy PHP Code:
Then on skin1/customer/main/cart.tpl you could access the extra fields (all of them) like this: PHP Code:
Change 0 by the index number of your field, which you could find on the extra fields section on the admin side. You could loop them also. Of course $product is a variable inside a loop on the cart that represents a product of the cart. Look in cart.tpl it's straighforward.
__________________
Willie |
|||||||
#5
|
|||||||||
|
|||||||||
Re: Extra Fields in Cart using 4.2.2
Quote:
Care to share how you did it? I have been trying to make this work in 4.2.3 to no avail :-/ |
|||||||||
#6
|
|||||||
|
|||||||
Re: Extra Fields in Cart using 4.2.2
Hi,
I joined the extra_fields table to the query that created the products array in func.cart.php. The query is in the func_products_from_scratch function, and the query is around line 1710 in version 4.2.2. Quote:
I've indicated the parts you'll have to modify to suite your requirements. This allowed me to access the value of the extra field in cart.tpl using '$product.extra_field_value'. I've not tried it in 4.2.3, so can't vouch for it there I'm afraid, but hope it helps. Ian |
|||||||
|
|||
X-Cart forums © 2001-2020
|