X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Detect that session is viewing the Shopping Cart in home.tpl (https://forum.x-cart.com/showthread.php?t=66115)

strimpf 02-13-2013 09:22 PM

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.

cflsystems 02-13-2013 09:26 PM

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 ....

strimpf 02-13-2013 09:34 PM

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...:)

cflsystems 02-13-2013 10:09 PM

Re: Detect that session is viewing the Shopping Cart in home.tpl
 
Do a foreach loop through products array on cart page

strimpf 02-13-2013 11:36 PM

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.

cflsystems 02-14-2013 11:15 AM

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


All times are GMT -8. The time now is 10:30 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.