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

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

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-11-2008, 07:44 PM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default 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
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #2  
Old 02-11-2008, 08:17 PM
  wjbrewer's Avatar 
wjbrewer wjbrewer is offline
Banned
 

X-Adept
  
Join Date: Feb 2005
Location: Pittsburgh, PA
Posts: 504
 

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

Code:
{if $order.login|strpos:'customer-'===0} Do this. {/if}
Reply With Quote
  #3  
Old 02-11-2008, 08:31 PM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default 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
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #4  
Old 02-11-2008, 09:46 PM
  DezineJunkie's Avatar 
DezineJunkie DezineJunkie is offline
 

Senior Member
  
Join Date: Jan 2008
Posts: 174
 

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

hey thanks



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
__________________
X-CART Pro V.4.3.0
PHP version 5.2.11
MySQL version 5.0.81
Architecture x86_64
Apache version 2.2.14 (Unix)mod_ssl/2.2.14
Operating System: Linux
Dedicated Ip
cPanel Pro 1.0 (RC1)
cPanel Version 11.24.5-RELEASE
Modules: DL Expander, DL Products, One Page Checkout, Dynamic Images,
Multicolumn Recommends, Narrow by Search, Random Products Tabs.
X-AOM, SALES-N-STATS 1.3 , X-Offers-4.1.9, X-Magnifier41x, X-Fancy Categories,
X-RSS Feeds, Static Meta Tags , X-AJAX Rating System v4.1


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 04:15 PM.

   

 
X-Cart forums © 2001-2020