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

Add text to cart / checkout if cart contains certain product?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-10-2012, 05:00 PM
 
Tye Tye is offline
 

eXpert
  
Join Date: Nov 2002
Location: Australia
Posts: 284
 

Default Add text to cart / checkout if cart contains certain product?

Is this possible?
__________________
Today is a beautiful day, grab it while you can and live it to the full

Version 4.2.3 UNIX
Reply With Quote
  #2  
Old 01-10-2012, 06:16 PM
  gb2world's Avatar 
gb2world gb2world is offline
 

X-Wizard
  
Join Date: May 2006
Location: Austin, TX
Posts: 1,970
 

Default Re: Add text to cart / checkout if cart contains certain product?

Yes, it should be possible. On the page you want to modify, you can use webmaster mod to find an array that the products are stored in. You can look for the template where that array gets looped though to display the products. You can add a test to see if the product in question is in the array. If it is, you can set a variable that you can use to display the text.

---
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold
(CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module)
Reply With Quote
  #3  
Old 01-11-2012, 09:28 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: Add text to cart / checkout if cart contains certain product?

Should be something like this. Open cart.php

Find:

Code:
# Assign the current location line $smarty->assign("location", $location);

Before add:

Code:
// WCM - Identify product // Change X to your numeric productid if (is_array($cart) AND !empty($cart['products']) foreach($cart['products'] as $k=>$v) if ($v['productid'] == X) $smarty->assign('found_product', 1); // / WCM - Identify product

In your .tpl file of checkout use:

Code:
{* WCM - Identify product *} {if $found_product eq 1} Display my message {/if} {* / WCM - Identify product *}
Reply With Quote

The following 2 users thank Jon for this useful post:
dtgmap (11-14-2012), gb2world (01-11-2012)
  #4  
Old 01-11-2012, 09:13 PM
 
Tye Tye is offline
 

eXpert
  
Join Date: Nov 2002
Location: Australia
Posts: 284
 

Default Re: Add text to cart / checkout if cart contains certain product?

Wow - thanks Jon - I'll test it out
__________________
Today is a beautiful day, grab it while you can and live it to the full

Version 4.2.3 UNIX
Reply With Quote
  #5  
Old 01-12-2012, 10:39 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: Add text to cart / checkout if cart contains certain product?

Let me know!
Reply With Quote
  #6  
Old 11-14-2012, 07:26 AM
 
dtgmap dtgmap is offline
 

Member
  
Join Date: Mar 2012
Posts: 26
 

Default Re: Add text to cart / checkout if cart contains certain product?

For some reason, I couldn't get this to work (in 4.4.5) with the is_array($cart) condition in the if statement - but it seems to work without it just fine. I'm trying to take this a step further and change the user's membership level based on purchasing a certain product (the membership). Thanks for this info.
__________________
X-Cart v4.4.5
********* Power Filter
BCSE Refer-A-Friend
BCSE Auth.Net DPM/CIM
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 06:44 AM.

   

 
X-Cart forums © 2001-2020