Jump to content

Setting Order Minimums


bbtil

Recommended Posts

thanks i don't know a lot of  that but i;m getting an error...

PHP Syntax Check: Parse error: syntax error, unexpected 'smarty' (T_STRING) in your code on line 5

  • $GLOBALS['smarty']->assign('DISABLE_CHECKOUT_BUTTON', true);

I didn't touch that part of the code

 

Link to comment
Share on other sites

Please chack any preceding lines of code that have been edited. Specifically, look for phrases that may be missing quote marks at the start or at the end of the phrase.

Also, check to make sure the type of quote mark is the same: an apostrophe to start the text phrase (called a string) but a double quote to end it.

Also, check for any statement that may be missing a trailing semi-colon.

Link to comment
Share on other sites

<?php
$min_order_value = 25;
if($GLOBALS['cart']->basket['total'] < $min_order_value) {
    $GLOBALS['gui']->setError('Sorry but we are unable to process orders under £'.$min_order_value.');
    $GLOBALS['smarty']->assign('DISABLE_CHECKOUT_BUTTON', true);
}
?>

 

Link to comment
Share on other sites

In the argument for the GUI->setError:

('Sorry but we are unable to process orders under £'.$min_order_value.')

The apostrophe starts a string, another apostrophe ends it after the currency symbol,
the period is a string concatenation, the value of the $min_order_value variable
is concatenated, the period is a string concatenation, the apostrophe starts a string,
and we are now missing what should follow, perhaps an actual period followed by the
apostrophe that ends the string.

So, the entire statement should probably look like:
$GLOBALS['gui']->setError('Sorry but we are unable to process orders under £' . $min_order_value . '.');

 

Link to comment
Share on other sites

After many hours of trial and error, I wrote a hook which has worked well for two years or more.

Just modify the PHP code to the minimum  order value (in my case £15.00)

 

Go to manage hooks/code snippets and then choose add a code snippet.

Insert the data below in to the appropriate fields, ensure the snippet is enabled.

 

Unique ID:                         minimum-order-value@cubecart

Execution Order:             1

Description:                      Disable checkout until Min-Max order Value is reached

Trigger:                              class.cubecart.display_basket

 

PHP Code:                       

<?php
$upper_val=15.00;
$lower_val=0;
$value = number_format($upper_val, 2);
if($GLOBALS['cart']->basket['subtotal'] > $lower_val && $GLOBALS['cart']->basket['subtotal'] < $value) {
$GLOBALS['gui']->setError ('Our minimum net order value is '.$value.'.');
$GLOBALS['smarty']->assign('DISABLE_CHECKOUT_BUTTON', true);
}
?>

 

 

Version:                          2.0

Author:                            Keat

Edited by keat
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...