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

Can't access custom variable

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-10-2011, 05:49 AM
  JeanB's Avatar 
JeanB JeanB is offline
 

eXpert
  
Join Date: Oct 2009
Location: Worcestershire, UK
Posts: 217
 

Default Can't access custom variable

Hi All,

I have a modified mini-cart. I want to also input a text line, such as "Only ё3.40 until FREE SHIPPING!"

To do this, I have created a variable that looks at my shipping tables. I want to make sure that my minicart always reads whatever value is in a certain shipping method, that qualifies them for free shipping. If we ever changed the threshold, I won't have to change the template.

Bearing that in mind, the variable does now appear in "Webmaster Mode"

{$free_shipping_subtotal_requirement}Array (1)0 => Array (1) mintotal => "25.00"


I want to be able to access the "mintotal" value.

However, even as a starting point, I can't reference it in a template - It just comes out as blank

Have I missed something fundamental that will allow me to get to that? Or, should I just be able to call it, if it's populated - Which it is doing - And contains the correct value?

Any help will be hugely appreciated!

Thank you!
__________________
4.2.3
X-Cart Gold
BCSE Address Book | XCartMods QuickFind | X-RMA | X-Offers
-------[installed]----------------------[installed]--------------[installed]----[installed]--



5: in development
Reply With Quote
  #2  
Old 03-10-2011, 07:07 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Can't access custom variable

You have to assign it to smarty form the php file before you can access it in template

$smarty->assign("variable_name_in_template", $variable_name_in_php);
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
JeanB (03-14-2011)
  #3  
Old 03-10-2011, 07:09 AM
  JeanB's Avatar 
JeanB JeanB is offline
 

eXpert
  
Join Date: Oct 2009
Location: Worcestershire, UK
Posts: 217
 

Default Re: Can't access custom variable

I have this in the .php file - ?

$smarty->assign("free_shipping_subtotal_requirement",$free _shipping_subtotal_requirement);
__________________
4.2.3
X-Cart Gold
BCSE Address Book | XCartMods QuickFind | X-RMA | X-Offers
-------[installed]----------------------[installed]--------------[installed]----[installed]--



5: in development
Reply With Quote
  #4  
Old 03-10-2011, 07:16 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Can't access custom variable

Does $free _shipping_subtotal_requirement holds the array or is it just a text?
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #5  
Old 03-10-2011, 07:36 AM
  JeanB's Avatar 
JeanB JeanB is offline
 

eXpert
  
Join Date: Oct 2009
Location: Worcestershire, UK
Posts: 217
 

Default Re: Can't access custom variable

It's the result of:

$query = "SELECT mintotal FROM `xcart_shipping_rates` where rate = '0' and shippingid = '173'";

But that's as much as I know ... ?
__________________
4.2.3
X-Cart Gold
BCSE Address Book | XCartMods QuickFind | X-RMA | X-Offers
-------[installed]----------------------[installed]--------------[installed]----[installed]--



5: in development
Reply With Quote
  #6  
Old 03-10-2011, 08:02 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Can't access custom variable

FYI, there's a couple similar mods already available on here..
http://forum.x-cart.com/showthread.php?t=28275
http://forum.x-cart.com/showthread.php?t=17500
__________________
xcartmods.co.uk
Reply With Quote

The following user thanks PhilJ for this useful post:
JeanB (03-14-2011)
  #7  
Old 03-10-2011, 08:09 AM
  JeanB's Avatar 
JeanB JeanB is offline
 

eXpert
  
Join Date: Oct 2009
Location: Worcestershire, UK
Posts: 217
 

Default Re: Can't access custom variable

Hi Phil,

Thanks for those - Seems I am sort of on the right track.

I have already modified the minicart to do this, with a fixed value of "25" - Only when the user is delivering to the UK.

However, I don't want to fix the 25 in the template - The likelihood is, with everything else that I have to do, I will forget that it's there in a couple of years - If we ever change our rules - I want to eliviate this.

The 25, as above, comes from our horrendous 485 line shipping table - When the delivery method is Royal Mail & the charge is 0. This will give us an accurate reading of the "free postage" threshold - Without any other manual intervention.

Our shipping table is a direct sync from our backoffice setup, so if it changes there, it will change in x-cart.
__________________
4.2.3
X-Cart Gold
BCSE Address Book | XCartMods QuickFind | X-RMA | X-Offers
-------[installed]----------------------[installed]--------------[installed]----[installed]--



5: in development
Reply With Quote
  #8  
Old 03-10-2011, 11:03 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Can't access custom variable

Since the only value you need is mintotal you can do this
Code:
$mintotal = func_query_first_cell("select mintotal from $sql_tbl[xcart_shipping_rates] where rate = '0' and shippingid = '173'"); $smary->assign("mintotal",$mintotal);
Then use $mintotal in the template to calculate whatever you need
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
JeanB (03-14-2011)
  #9  
Old 03-14-2011, 12:24 AM
  JeanB's Avatar 
JeanB JeanB is offline
 

eXpert
  
Join Date: Oct 2009
Location: Worcestershire, UK
Posts: 217
 

Default Re: Can't access custom variable

Strangely, my xcart didn't like calling the table name ...?

I've popped this in instead and it seems to work?

$mintotal = func_query_first_cell("SELECT mintotal FROM `xcart_shipping_rates` where rate = '0' and shippingid = '173'");
$smarty->assign("mintotal",$mintotal);



Dropped it into the equation and it works perfectly! Faaaaantastic! Whoop! Thank you, Steve!

__________________
4.2.3
X-Cart Gold
BCSE Address Book | XCartMods QuickFind | X-RMA | X-Offers
-------[installed]----------------------[installed]--------------[installed]----[installed]--



5: in development
Reply With Quote
  #10  
Old 03-14-2011, 05:39 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Can't access custom variable

My bad, sorry, the table must be without "xcart_"
Code:
$mintotal = func_query_first_cell("select mintotal from $sql_tbl[shipping_rates] where rate = '0' and shippingid = '173'"); $smary->assign("mintotal",$mintotal);
__________________
Steve Stoyanov
CFLSystems.com
Web Development
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 11:48 PM.

   

 
X-Cart forums © 2001-2020