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)
-   -   Smarty help please, "if a string begins with xyz..."? (https://forum.x-cart.com/showthread.php?t=37506)

carpeperdiem 02-11-2008 07:44 PM

Smarty help please, "if a string begins with xyz..."?
 
I want to include usernames in the order_invoice.tpl

This thread shows how.

Now, I need to exclude the "anonymous" checkouts, which for my store, all start with "customer".

customer-392
customer-1048
customer-21864

etc...

How do I ask smarty to look for the phrase "customer-XYZ" and if it sees a username that begins with "customer" to let me know...

{if $order.login BEGINS WITH 'customer'}
do this
{/if}

Smarty experts?

Thank you in advance.

Jeremy

wjbrewer 02-11-2008 08:17 PM

Re: Smarty help please, "if a string begins with xyz..."?
 
Code:

{if $order.login|strpos:'customer-'===0}

Do this.

{/if}


carpeperdiem 02-11-2008 08:31 PM

Re: Smarty help please, "if a string begins with xyz..."?
 
Bill,

That's just brilliant! Thank you.

If anyone's interested...

file: skin1/mail/html/order_invoice.tpl

FIND:
Code:

{foreach from=$_userinfo.additional_fields item=v}
{if $v.section eq 'S'}
                <tr>
                        <td><b>{$v.title}:</b></td>
                <td>{$v.value}</td>
                </tr>
        {/if}
{/foreach}

AFTER, insert:
Code:

{if $order.login|strpos:'customer-'===0}
{else}
<tr>
<td><strong>Username:</strong></td><td>{$order.login}</td>
</tr>
{/if}


Replace 'customer' with whatever you've named your anonymous customers... in config.php

$anonymous_username_prefix="customer";

Another very nice addition to the customer invoice.

Thanks Bill!

Jeremy

DezineJunkie 02-11-2008 09:46 PM

Re: Smarty help please, "if a string begins with xyz..."?
 
hey thanks
:mrgreen:


Quote:

Originally Posted by carpeperdiem
I want to include usernames in the order_invoice.tpl

This thread shows how.

Now, I need to exclude the "anonymous" checkouts, which for my store, all start with "customer".

customer-392
customer-1048
customer-21864

etc...

How do I ask smarty to look for the phrase "customer-XYZ" and if it sees a username that begins with "customer" to let me know...

{if $order.login BEGINS WITH 'customer'}
do this
{/if}

Smarty experts?

Thank you in advance.

Jeremy



All times are GMT -8. The time now is 02:01 PM.

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