Changeset 1197796
- Timestamp:
- 07/13/2015 09:43:35 AM (10 years ago)
- Location:
- shopp-minimum-order-amount
- Files:
-
- 4 edited
- 1 copied
-
tags/1.3.4 (copied) (copied from shopp-minimum-order-amount/trunk)
-
tags/1.3.4/readme.txt (modified) (2 diffs)
-
tags/1.3.4/shopp-minimum-order.php (modified) (15 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/shopp-minimum-order.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shopp-minimum-order-amount/tags/1.3.4/readme.txt
r1160833 r1197796 5 5 Requires at least: 3.0 6 6 Tested up to: 4.0.1 7 Stable tag: 1.3. 37 Stable tag: 1.3.4 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 47 47 == Changelog == 48 48 49 = 1.3.4 = 50 * Squashed a couple of sneaky (but dumb) bugs. One was hiding the quantity select box on product pages, and the other was just silly. 51 49 52 = 1.3.3 = 50 53 * Squashed a bug preventing minimums from being saved in 1.3.x (at the expense of 1.2.x compatibility). Thanks Thomas Bisshop -
shopp-minimum-order-amount/tags/1.3.4/shopp-minimum-order.php
r1160833 r1197796 5 5 Description: Set a minimum order amount (total items or order total) for Shopp checkout. 6 6 Author: Chris Runnells 7 Version: 1.3. 37 Version: 1.3.4 8 8 Author URI: http://www.chrisrunnells.com 9 9 … … 37 37 38 38 // admin stuff 39 add_action('admin_menu', 'smo_menu', 90); 40 add_action('admin_menu', 'smo_meta', 20); 41 add_filter('plugin_action_links', 'smo_plugin_action_links', 10, 2); 42 43 44 function smo_menu() { 45 // Shopp 1.2 menu position 46 // add_submenu_page('shopp-settings',__('Minimum Order'),__('Minimum Order'),'manage_options','shopp-minimum-order','smo_actions'); 47 39 add_action( 'admin_menu', 'smo_menu', 90 ); 40 add_action( 'admin_menu', 'smo_meta', 20 ); 41 add_filter( 'plugin_action_links', 'smo_plugin_action_links', 10, 2 ); 42 43 44 function smo_menu () { 48 45 // Shopp 1.3 49 // shopp_admin_add_submenu ( string $label, string $page, string $menu = null, $handler = false, string $access = null )50 // shopp_admin_add_submenu( 'Minimum Order', 'shopp-setup-minimum', 'shopp-setup', 'smo_actions', 'shopp_settings' );51 52 46 add_submenu_page( 'shopp-orders', 'Minimum Order', 'Minimum Order', 'manage_options', 'shopp-minimum-order', 'smo_actions' ); 53 47 } 54 48 55 function smo_meta () {49 function smo_meta () { 56 50 add_meta_box( 'smo_metabox', 'Set Minimum', 'smo_sidebar', 'shopp_product', 'side', 'default' ); 57 51 } 58 52 59 function smo_plugin_action_links ($links, $file) {53 function smo_plugin_action_links ( $links, $file ) { 60 54 static $this_plugin; 61 55 62 if (!$this_plugin) { 63 $this_plugin = plugin_basename(__FILE__); 56 if ( ! $this_plugin ) 57 $this_plugin = plugin_basename( __FILE__ ); 58 59 if ( $file == $this_plugin ) { 60 // The "page" query string value must be equal to the slug of the Settings admin page 61 $settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=shopp-minimum-order">Settings</a>'; 62 array_unshift( $links, $settings_link ); 64 63 } 65 64 66 if ($file == $this_plugin) {67 // The "page" query string value must be equal to the slug68 // of the Settings admin page we defined earlier, which in69 // this case equals "myplugin-settings".70 $settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=shopp-minimum-order">Settings</a>';71 array_unshift($links, $settings_link);72 }73 74 65 return $links; 75 66 } 76 67 77 function smo_actions () {78 if ($_POST['action'] == 'update'){68 function smo_actions () { 69 if ( $_POST['action'] == 'update' ) { 79 70 smo_save(); 80 71 } else { … … 83 74 } 84 75 85 function smo_form( $response = false ) { 86 87 $type = get_option('smo_type'); 88 $minimum = get_option('smo_minimum'); 89 90 $selected[0] = ""; 91 $selected[1] = ""; 92 $selected[2] = ""; 93 94 if(isset($type)){ 76 function smo_form ( $response = false ) { 77 78 $type = get_option( 'smo_type' ); 79 $minimum = get_option( 'smo_minimum' ); 80 81 $selected = array( '', '', '' ); 82 83 if ( isset( $type ) ) { 95 84 if($type == "quantity") $selected[0] = ' checked="checked"'; 96 85 if($type == "total") $selected[1] = ' checked="checked"'; … … 100 89 } 101 90 102 if ($response){91 if ( $response ) 103 92 $response = '<div id="message" class="updated fade"><p>'.$response.'</p></div>'; 104 } 105 106 if ('SHOPP_VERSION' < '1.2'){ 107 $response .= '<div id="message" class="updated fade"><p>'. sprintf(__('This plugin has only been tested in Shopp version 1.3 and greater. Your current version is %d and we recommend upgrading.'), SHOPP_VERSION) .'</p></div>'; 108 } 93 94 if ( defined('SHOPP_VERSION') && version_compare(SHOPP_VERSION, "1.3", "<") ) // 1.2 95 $response .= '<div id="message" class="updated fade"><p>'. sprintf(__('This plugin has only been tested in Shopp version 1.3 and greater. Your current version is %d and we recommend upgrading to the latest version of Shopp.'), SHOPP_VERSION) .'</p></div>'; 96 109 97 ?> 110 98 <style type="text/css"> … … 153 141 154 142 155 function smo_save (){143 function smo_save () { 156 144 // sanitize user input 157 145 $type = sanitize_text_field($_POST['smo_type']); … … 165 153 166 154 /* Meta box sidebar on the product page */ 167 function smo_sidebar (){155 function smo_sidebar () { 168 156 global $post; 169 157 … … 180 168 181 169 /* Save data from product page meta box */ 182 function smo_save_postdata ( $Product ) {170 function smo_save_postdata ( $Product ) { 183 171 $minimum = (float) $_POST['smo_min']; 184 172 if ( ! $minimum ) return; … … 186 174 } 187 175 188 function smo_filter_quantity ( $result, $options, $Product ){176 function smo_filter_quantity ( $result, $options, $Product ) { 189 177 // check if this product has a minimum 190 178 $minimum = smo_get_minimum($Product->id); 191 shopp_debug("Check catalog product: " . print_r($minimum, true));179 shopp_debug("Check catalog product: " . print_r($minimum, true)); 192 180 193 181 // if it does, try to set the minimum in the dropdown OR text area input (soon) 194 182 return $result; 195 183 } 196 184 … … 198 186 // check if this item has minimums 199 187 $minimum = smo_get_minimum($Item->product); 200 shopp_debug("Check added item minimum: " . print_r($minimum, true)); 201 202 // if it does, set the quantity to minimum if it's less 203 if ($Item->quantity < $minimum) $Item->quantity = $minimum; 204 205 // drop a cart error to let the customer know what happened 206 // new ShoppError(__('The minimum quantity for this product is:','Shopp'),false,SHOPP_ERR); 188 if ( empty( $minimum ) ) return; 189 190 shopp_debug( "Check added item minimum: " . print_r($minimum, true) ); 191 // set the quantity to the minimum if it's less 192 if ( $Item->quantity < $minimum ) { 193 $Item->quantity = $minimum; 194 // drop a cart error to let the customer know what happened 195 shopp_add_notice('The minimum quantity for ' . $Item->name . ' is ' . $minimum . '. Your cart has been updated.'); 196 } 207 197 } 208 198 … … 220 210 221 211 // drop a cart error to let the customer know what happened 222 new ShoppError(__('The minimum quantity for ' . $Item->name . ' is ' . $minimum . '. Your cart has been updated.', 'Shopp'), false, SHOPP_ERR); 212 // new ShoppError(__('The minimum quantity for ' . $Item->name . ' is ' . $minimum . '. Your cart has been updated.', 'Shopp'), false, SHOPP_ERR); 213 shopp_add_notice('The minimum quantity for ' . $Item->name . ' is ' . $minimum . '. Your cart has been updated.'); 223 214 } 224 215 … … 227 218 } 228 219 229 function smo_check_minimums ( $valid) {220 function smo_check_minimums ( $valid ) { 230 221 global $Shopp; 231 222 … … 234 225 235 226 // if type is "total", check against the order subtotal 236 if ( isset($type) && !empty($type) && shopp_cart_items_count() > 0 ){237 if ( $type == "total" ) {227 if ( isset($type) && !empty($type) && shopp_cart_items_count() > 0 ) { 228 if ( $type == "total" ) { 238 229 $Cart = ShoppOrder()->Cart; 239 230 $subtotal = $Cart->total('order'); … … 241 232 242 233 if ( $subtotal < $minimum ){ 243 if (SHOPP_DEBUG) new ShoppError('Total minimum: '. $minimum . ' sub-total: '. $subtotal, false, SHOPP_DEBUG_ERR);234 shopp_debug('Total minimum: '. $minimum . ' sub-total: '. $subtotal ); 244 235 245 236 new ShoppError('The minimum order amount is ' . money($minimum) . '. Please add more items to complete your order.','cart_validation'); … … 247 238 return false; 248 239 } 249 } else if ( $type == "quantity"){240 } else if ( $type == "quantity" ) { 250 241 251 242 $total_items = shopp('cart', 'get-total-quantity'); 252 243 253 if ($total_items < $minimum){254 if (SHOPP_DEBUG) new ShoppError('Quantity minimum: '. $minimum . ' total items: '. $total_items, false, SHOPP_DEBUG_ERR);244 if ( $total_items < $minimum ) { 245 shopp_debug('Quantity minimum: '. $minimum . ' total items: '. $total_items); 255 246 new ShoppError('You must have at least '. $minimum .' items in your cart to check out. You currently have '. $total_items .' items.', 'cart_validation'); 256 247 return false; … … 264 255 } 265 256 266 // Checks during checkout if minimum ahas been met 267 function smo_cart_minimums (){ 268 global $Shopp; 257 // Checks during checkout if minimum has been met 258 function smo_cart_minimums () { 269 259 270 260 $minimum = get_option('smo_minimum'); 271 261 272 if (SHOPP_DEBUG) new ShoppError('minimum: '. $minimum . ' total: '. shopp('cart','get-total'),false,SHOPP_DEBUG_ERR); 273 274 if ( floatval( shopp('cart','get-total') ) < $minimum ){ 275 276 if (SHOPP_DEBUG) new ShoppError("Minimum is " . money($minimum) . ", total is " . shopp('cart','get-total'),false,SHOPP_DEBUG_ERR); 277 278 new ShoppError(__("Cart total does not exceed minimum order amount.","Shopp")); 262 shopp_debug('minimum: '. $minimum . ' total: ' . shopp('cart.get-total')); 263 264 if ( floatval( shopp('cart.get-total') ) < $minimum ){ 265 266 shopp_debug("Minimum is " . money($minimum) . ", total is " . shopp('cart.get-total')); 267 268 // new ShoppError(__("Cart total does not exceed minimum order amount.","Shopp")); 269 shopp_add_error("Cart total does not exceed minimum order amount."); 279 270 } 280 271 } -
shopp-minimum-order-amount/trunk/readme.txt
r1160833 r1197796 5 5 Requires at least: 3.0 6 6 Tested up to: 4.0.1 7 Stable tag: 1.3. 37 Stable tag: 1.3.4 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 47 47 == Changelog == 48 48 49 = 1.3.4 = 50 * Squashed a couple of sneaky (but dumb) bugs. One was hiding the quantity select box on product pages, and the other was just silly. 51 49 52 = 1.3.3 = 50 53 * Squashed a bug preventing minimums from being saved in 1.3.x (at the expense of 1.2.x compatibility). Thanks Thomas Bisshop -
shopp-minimum-order-amount/trunk/shopp-minimum-order.php
r1160833 r1197796 5 5 Description: Set a minimum order amount (total items or order total) for Shopp checkout. 6 6 Author: Chris Runnells 7 Version: 1.3. 37 Version: 1.3.4 8 8 Author URI: http://www.chrisrunnells.com 9 9 … … 37 37 38 38 // admin stuff 39 add_action('admin_menu', 'smo_menu', 90); 40 add_action('admin_menu', 'smo_meta', 20); 41 add_filter('plugin_action_links', 'smo_plugin_action_links', 10, 2); 42 43 44 function smo_menu() { 45 // Shopp 1.2 menu position 46 // add_submenu_page('shopp-settings',__('Minimum Order'),__('Minimum Order'),'manage_options','shopp-minimum-order','smo_actions'); 47 39 add_action( 'admin_menu', 'smo_menu', 90 ); 40 add_action( 'admin_menu', 'smo_meta', 20 ); 41 add_filter( 'plugin_action_links', 'smo_plugin_action_links', 10, 2 ); 42 43 44 function smo_menu () { 48 45 // Shopp 1.3 49 // shopp_admin_add_submenu ( string $label, string $page, string $menu = null, $handler = false, string $access = null )50 // shopp_admin_add_submenu( 'Minimum Order', 'shopp-setup-minimum', 'shopp-setup', 'smo_actions', 'shopp_settings' );51 52 46 add_submenu_page( 'shopp-orders', 'Minimum Order', 'Minimum Order', 'manage_options', 'shopp-minimum-order', 'smo_actions' ); 53 47 } 54 48 55 function smo_meta () {49 function smo_meta () { 56 50 add_meta_box( 'smo_metabox', 'Set Minimum', 'smo_sidebar', 'shopp_product', 'side', 'default' ); 57 51 } 58 52 59 function smo_plugin_action_links ($links, $file) {53 function smo_plugin_action_links ( $links, $file ) { 60 54 static $this_plugin; 61 55 62 if (!$this_plugin) { 63 $this_plugin = plugin_basename(__FILE__); 56 if ( ! $this_plugin ) 57 $this_plugin = plugin_basename( __FILE__ ); 58 59 if ( $file == $this_plugin ) { 60 // The "page" query string value must be equal to the slug of the Settings admin page 61 $settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=shopp-minimum-order">Settings</a>'; 62 array_unshift( $links, $settings_link ); 64 63 } 65 64 66 if ($file == $this_plugin) {67 // The "page" query string value must be equal to the slug68 // of the Settings admin page we defined earlier, which in69 // this case equals "myplugin-settings".70 $settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=shopp-minimum-order">Settings</a>';71 array_unshift($links, $settings_link);72 }73 74 65 return $links; 75 66 } 76 67 77 function smo_actions () {78 if ($_POST['action'] == 'update'){68 function smo_actions () { 69 if ( $_POST['action'] == 'update' ) { 79 70 smo_save(); 80 71 } else { … … 83 74 } 84 75 85 function smo_form( $response = false ) { 86 87 $type = get_option('smo_type'); 88 $minimum = get_option('smo_minimum'); 89 90 $selected[0] = ""; 91 $selected[1] = ""; 92 $selected[2] = ""; 93 94 if(isset($type)){ 76 function smo_form ( $response = false ) { 77 78 $type = get_option( 'smo_type' ); 79 $minimum = get_option( 'smo_minimum' ); 80 81 $selected = array( '', '', '' ); 82 83 if ( isset( $type ) ) { 95 84 if($type == "quantity") $selected[0] = ' checked="checked"'; 96 85 if($type == "total") $selected[1] = ' checked="checked"'; … … 100 89 } 101 90 102 if ($response){91 if ( $response ) 103 92 $response = '<div id="message" class="updated fade"><p>'.$response.'</p></div>'; 104 } 105 106 if ('SHOPP_VERSION' < '1.2'){ 107 $response .= '<div id="message" class="updated fade"><p>'. sprintf(__('This plugin has only been tested in Shopp version 1.3 and greater. Your current version is %d and we recommend upgrading.'), SHOPP_VERSION) .'</p></div>'; 108 } 93 94 if ( defined('SHOPP_VERSION') && version_compare(SHOPP_VERSION, "1.3", "<") ) // 1.2 95 $response .= '<div id="message" class="updated fade"><p>'. sprintf(__('This plugin has only been tested in Shopp version 1.3 and greater. Your current version is %d and we recommend upgrading to the latest version of Shopp.'), SHOPP_VERSION) .'</p></div>'; 96 109 97 ?> 110 98 <style type="text/css"> … … 153 141 154 142 155 function smo_save (){143 function smo_save () { 156 144 // sanitize user input 157 145 $type = sanitize_text_field($_POST['smo_type']); … … 165 153 166 154 /* Meta box sidebar on the product page */ 167 function smo_sidebar (){155 function smo_sidebar () { 168 156 global $post; 169 157 … … 180 168 181 169 /* Save data from product page meta box */ 182 function smo_save_postdata ( $Product ) {170 function smo_save_postdata ( $Product ) { 183 171 $minimum = (float) $_POST['smo_min']; 184 172 if ( ! $minimum ) return; … … 186 174 } 187 175 188 function smo_filter_quantity ( $result, $options, $Product ){176 function smo_filter_quantity ( $result, $options, $Product ) { 189 177 // check if this product has a minimum 190 178 $minimum = smo_get_minimum($Product->id); 191 shopp_debug("Check catalog product: " . print_r($minimum, true));179 shopp_debug("Check catalog product: " . print_r($minimum, true)); 192 180 193 181 // if it does, try to set the minimum in the dropdown OR text area input (soon) 194 182 return $result; 195 183 } 196 184 … … 198 186 // check if this item has minimums 199 187 $minimum = smo_get_minimum($Item->product); 200 shopp_debug("Check added item minimum: " . print_r($minimum, true)); 201 202 // if it does, set the quantity to minimum if it's less 203 if ($Item->quantity < $minimum) $Item->quantity = $minimum; 204 205 // drop a cart error to let the customer know what happened 206 // new ShoppError(__('The minimum quantity for this product is:','Shopp'),false,SHOPP_ERR); 188 if ( empty( $minimum ) ) return; 189 190 shopp_debug( "Check added item minimum: " . print_r($minimum, true) ); 191 // set the quantity to the minimum if it's less 192 if ( $Item->quantity < $minimum ) { 193 $Item->quantity = $minimum; 194 // drop a cart error to let the customer know what happened 195 shopp_add_notice('The minimum quantity for ' . $Item->name . ' is ' . $minimum . '. Your cart has been updated.'); 196 } 207 197 } 208 198 … … 220 210 221 211 // drop a cart error to let the customer know what happened 222 new ShoppError(__('The minimum quantity for ' . $Item->name . ' is ' . $minimum . '. Your cart has been updated.', 'Shopp'), false, SHOPP_ERR); 212 // new ShoppError(__('The minimum quantity for ' . $Item->name . ' is ' . $minimum . '. Your cart has been updated.', 'Shopp'), false, SHOPP_ERR); 213 shopp_add_notice('The minimum quantity for ' . $Item->name . ' is ' . $minimum . '. Your cart has been updated.'); 223 214 } 224 215 … … 227 218 } 228 219 229 function smo_check_minimums ( $valid) {220 function smo_check_minimums ( $valid ) { 230 221 global $Shopp; 231 222 … … 234 225 235 226 // if type is "total", check against the order subtotal 236 if ( isset($type) && !empty($type) && shopp_cart_items_count() > 0 ){237 if ( $type == "total" ) {227 if ( isset($type) && !empty($type) && shopp_cart_items_count() > 0 ) { 228 if ( $type == "total" ) { 238 229 $Cart = ShoppOrder()->Cart; 239 230 $subtotal = $Cart->total('order'); … … 241 232 242 233 if ( $subtotal < $minimum ){ 243 if (SHOPP_DEBUG) new ShoppError('Total minimum: '. $minimum . ' sub-total: '. $subtotal, false, SHOPP_DEBUG_ERR);234 shopp_debug('Total minimum: '. $minimum . ' sub-total: '. $subtotal ); 244 235 245 236 new ShoppError('The minimum order amount is ' . money($minimum) . '. Please add more items to complete your order.','cart_validation'); … … 247 238 return false; 248 239 } 249 } else if ( $type == "quantity"){240 } else if ( $type == "quantity" ) { 250 241 251 242 $total_items = shopp('cart', 'get-total-quantity'); 252 243 253 if ($total_items < $minimum){254 if (SHOPP_DEBUG) new ShoppError('Quantity minimum: '. $minimum . ' total items: '. $total_items, false, SHOPP_DEBUG_ERR);244 if ( $total_items < $minimum ) { 245 shopp_debug('Quantity minimum: '. $minimum . ' total items: '. $total_items); 255 246 new ShoppError('You must have at least '. $minimum .' items in your cart to check out. You currently have '. $total_items .' items.', 'cart_validation'); 256 247 return false; … … 264 255 } 265 256 266 // Checks during checkout if minimum ahas been met 267 function smo_cart_minimums (){ 268 global $Shopp; 257 // Checks during checkout if minimum has been met 258 function smo_cart_minimums () { 269 259 270 260 $minimum = get_option('smo_minimum'); 271 261 272 if (SHOPP_DEBUG) new ShoppError('minimum: '. $minimum . ' total: '. shopp('cart','get-total'),false,SHOPP_DEBUG_ERR); 273 274 if ( floatval( shopp('cart','get-total') ) < $minimum ){ 275 276 if (SHOPP_DEBUG) new ShoppError("Minimum is " . money($minimum) . ", total is " . shopp('cart','get-total'),false,SHOPP_DEBUG_ERR); 277 278 new ShoppError(__("Cart total does not exceed minimum order amount.","Shopp")); 262 shopp_debug('minimum: '. $minimum . ' total: ' . shopp('cart.get-total')); 263 264 if ( floatval( shopp('cart.get-total') ) < $minimum ){ 265 266 shopp_debug("Minimum is " . money($minimum) . ", total is " . shopp('cart.get-total')); 267 268 // new ShoppError(__("Cart total does not exceed minimum order amount.","Shopp")); 269 shopp_add_error("Cart total does not exceed minimum order amount."); 279 270 } 280 271 }
Note: See TracChangeset
for help on using the changeset viewer.