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

Detect that session is viewing the Shopping Cart in home.tpl

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-13-2013, 09:22 PM
 
strimpf strimpf is offline
 

Newbie
  
Join Date: Feb 2013
Posts: 4
 

Default Detect that session is viewing the Shopping Cart in home.tpl

I can tell if I am on a Category page by using this in home.tpl:

{if $meta_page_type eq 'C'...}{/if}

The same goes for a product page (replace 'C' with 'P' above)

However, I am unable to figure out how to detect I am on the shopping cart page.

It would also be helpful to know how to examine the first item in the shopping cart. Particularly the SKU or the Name.

Update: my profile says 4.5.2 but I am working on a client site that is version 4.2.2.
__________________
4.5.2
Reply With Quote
  #2  
Old 02-13-2013, 09:26 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Detect that session is viewing the Shopping Cart in home.tpl

Don't use this. Use $main to determine the page. You can look in home_main.tpl and common_templates.tpl to see different $main values

$main eq "product" for example is product page
$main eq "cart" is cart page ....
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
strimpf (02-13-2013)
  #3  
Old 02-13-2013, 09:34 PM
 
strimpf strimpf is offline
 

Newbie
  
Join Date: Feb 2013
Posts: 4
 

Default Re: Detect that session is viewing the Shopping Cart in home.tpl

Thanks, Steve. That is exactly what I was looking for with the first part of my question.

I am still working on trying to look in the cart to determine the sku or name of the first item for comparison. Probably should have issued 2 separate posts.

I am sure with the correct amount of time and persistance, I will stumble across it. However, it would be nice to have a nudge in the right direction...
__________________
4.5.2
Reply With Quote
  #4  
Old 02-13-2013, 10:09 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Detect that session is viewing the Shopping Cart in home.tpl

Do a foreach loop through products array on cart page
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #5  
Old 02-13-2013, 11:36 PM
 
strimpf strimpf is offline
 

Newbie
  
Join Date: Feb 2013
Posts: 4
 

Default Re: Detect that session is viewing the Shopping Cart in home.tpl

I have been looking at this for a little while now and I am not getting it.

In home.tpl, I would like to check if $main = 'cart' or 'checkout' and if so, check the first 3 chars of the name of the first item [0] in the cart(could be the first 3 chars of the SKU which might be better) to see if it matches the string 'SLC'. If it does, I am going to change the css used to render the header and some other features in the home.tpl template. I have this working based on Category and Product, but can't seem to get a handle on the first product in the cart and check values on it.

I think I don't understand the scope of $cart. It is a php variable so I don't think I can use it directly in Smarty code. I will put a snippet of my busted code below so you can see the depths of my ignorance.

Code:
{$item_is_special = ""} {if $main eq "cart" or $main eq "checkout" or $main eq "order_message"} {if $products ne ""} {*foreach from=$products item=product*} {if $product[0].producttitle|substr:0:3 eq "SLC"} {$item_is_special = "Y"} {/if} {/if} {/if}

I don't think I even declared the local variable $item_is_special correctly.

UPDATE: (ok, nevermind about the question below. Found the answer here)
Also, is there documentation for XCart that shows the structure of the $cart object and $product object?


Thanks in advance for your time.
__________________
4.5.2
Reply With Quote
  #6  
Old 02-14-2013, 11:15 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Detect that session is viewing the Shopping Cart in home.tpl

I think you need to get some knowledge on the XC files structure and what loads what first before doing this. Also you can use the debug console to see what is available on each page you load and the structure of the variables - turn it on form admin general settings
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:14 PM.

   

 
X-Cart forums © 2001-2020