bbtil Posted May 30, 2018 Share Posted May 30, 2018 Is there a way to set an order total minimum? Do I need to get an extension? Quote Link to comment Share on other sites More sharing options...
Al Brookbanks Posted May 30, 2018 Share Posted May 30, 2018 If you have basic coding skills you could adapt this: https://www.cubecart.com/extensions/code-snippets/maximum-order-value Quote Link to comment Share on other sites More sharing options...
bbtil Posted May 30, 2018 Author Share Posted May 30, 2018 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 Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 30, 2018 Share Posted May 30, 2018 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. Quote Link to comment Share on other sites More sharing options...
bbtil Posted May 30, 2018 Author Share Posted May 30, 2018 <?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); } ?> Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 30, 2018 Share Posted May 30, 2018 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 . '.'); Quote Link to comment Share on other sites More sharing options...
Noodleman Posted May 31, 2018 Share Posted May 31, 2018 There is also this extension: https://www.cubecart.com/extensions/plugins/minimum-order-values-plugin Quote Link to comment Share on other sites More sharing options...
keat Posted May 31, 2018 Share Posted May 31, 2018 (edited) 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 May 31, 2018 by keat Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.