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

Outputting Extra Fields on Cart & Checkout Pages

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 05-25-2008, 07:48 AM
  chamberinternet's Avatar 
chamberinternet chamberinternet is offline
 

X-Wizard
  
Join Date: Sep 2005
Location: Lancashire, UK
Posts: 1,471
 

Default Outputting Extra Fields on Cart & Checkout Pages

Hello ...

I need to get a specific extra field from the product data and output on the Shopping Cart & Checkout Page for each product.

Has anyone done this before ? Any pointers towards the right direction?

Can anyone help ?

Thanks & Regards

Shafiq :sK
__________________
Developing in 4.7.x now (Dipping into v5 - Slowly!)
Have used 4.1.x, 4.2.x, 4.4.x, 4.5.x, 4.6.x & 4.7.x
Multiple Instances of X-Cart
MySQL 5.6.37
CentOS 7.4


Chamber Internet
- Lancashire, United Kingdom
http://www.chamberelancs.co.uk
Reply With Quote
  #2  
Old 06-12-2008, 07:35 AM
 
mikalou mikalou is offline
 

Advanced Member
  
Join Date: Jun 2005
Posts: 71
 

Default Re: Outputting Extra Fields on Cart & Checkout Pages

I needed to do the same thing. The following procedure works for me. I'm using Xcart 4.1.9.

Modified files: (BACKUP YOUR FILES BEFORE YOU MAKE CHANGES)
1. include/func/func.cart.php
2. skin1/customer/main/cart.tpl

Step 1:
You'll need to modify the "select" query statement that Xcart uses to get the field values for the products that have been added to the cart so that it will also include fields from the "xcart_extra_field_values" table. This select query statement is located within the function "func_products_from_scratch" within the file include/func/func.cart.php.

At approximately line 1718, you'll see the following query statement. The changes you need to make are in bold text: (note: I'm using "live" as a pseudonym for the field name but you can use whatever name you want)

$products_array = func_query_first("SELECT $sql_tbl[products].*, MIN($sql_tbl[pricing].price) as price, IF($sql_tbl[images_T].id IS NULL, '', 'Y') as is_thumbnail, $sql_tbl[images_T].image_path, $sql_tbl[images_T].image_x, $sql_tbl[images_T].image_y, IF($sql_tbl[images_P].id IS NULL, '', 'P') as is_pimage, $sql_tbl[images_P].image_path as pimage_path, $sql_tbl[images_P].image_x as pimage_x, $sql_tbl[images_P].image_y as pimage_y, $sql_tbl[extra_field_values].value as live FROM $sql_tbl[pricing],$sql_tbl[products] LEFT JOIN $sql_tbl[images_T] ON $sql_tbl[images_T].id = $sql_tbl[products].productid LEFT JOIN $sql_tbl[extra_field_values] ON $sql_tbl[extra_field_values].productid = $sql_tbl[products].productid LEFT JOIN $sql_tbl[images_P] ON $sql_tbl[images_P].id = $sql_tbl[products].productid WHERE $sql_tbl[products].productid=$sql_tbl[pricing].productid AND $sql_tbl[products].forsale != 'N' AND $sql_tbl[products].productid='$productid' AND $avail_condition ".(empty($active_modules['Wholesale_Trading']) ? "$sql_tbl[pricing].quantity = 1" : "$sql_tbl[pricing].quantity<='$amount'")." AND $sql_tbl[pricing].membershipid IN('$membershipid', '0') AND $sql_tbl[pricing].variantid = '$variantid' GROUP BY $sql_tbl[products].productid ORDER BY $sql_tbl[pricing].quantity DESC");

Step 2:
Modify skin1/customer/cart.tpl to display the value for the extra field.
Locate the section loop "{section name=product loop=$products}" within cart.tpl. Then place the smarty tag {$products[product].live} within that section loop to display the extra field value.
__________________
X-Cart Gold 4.2.2 - 3.1.19
Reply With Quote
  #3  
Old 09-10-2010, 05:12 AM
 
retrtrtrytrutru retrtrtrytrutru is offline
 

Senior Member
  
Join Date: Aug 2007
Posts: 101
 

Default Re: Outputting Extra Fields on Cart & Checkout Pages

Dear mikalou,

Thank you very much for sharing! Just what I needed! I applied your changes to func.cart.php but use a different code for cart.tpl since I had no loop in there. It has a foreach statement instead (v4.2). I simply use in cart.tpl:

Code:
{$product.live}
Does the trick for me
__________________
www.qualitylamps.eu
X-Cart Gold 4.1.8, PHP 5.2.6, MySQL 5.0.51a, Apache 2.2.9

www.vervangjelamp.nl
X-Cart Gold 4.2.0, PHP 5.2.6, MySQL 5.0.37-standard, Apache/2

Sorry for the weird user name, I registered it by mistake
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 03:53 PM.

   

 
X-Cart forums © 2001-2020