public function vtmin_controller_init() { global $vtmin_setup_options; load_plugin_textdomain('vtmin', null, dirname(plugin_basename(__FILE__)) . '/languages'); require VTMIN_DIRNAME . '/core/vtmin-backbone.php'; require VTMIN_DIRNAME . '/core/vtmin-rules-classes.php'; require VTMIN_DIRNAME . '/woo-integration/vtmin-parent-functions.php'; require VTMIN_DIRNAME . '/woo-integration/vtmin-parent-cart-validation.php'; //moved here v1.07 if (get_option('vtmin_setup_options')) { $vtmin_setup_options = get_option('vtmin_setup_options'); //put the setup_options into the global namespace } vtmin_debug_options(); //v1.07 if (is_admin()) { //fix 02-132013 - register_activation_hook now at bottom of file, after class instantiates require VTMIN_DIRNAME . '/admin/vtmin-setup-options.php'; if (defined('VTMIN_PRO_DIRNAME')) { require VTMIN_PRO_DIRNAME . '/admin/vtmin-rules-ui.php'; require VTMIN_PRO_DIRNAME . '/admin/vtmin-rules-update.php'; } else { require VTMIN_DIRNAME . '/admin/vtmin-rules-ui.php'; require VTMIN_DIRNAME . '/admin/vtmin-rules-update.php'; } require VTMIN_DIRNAME . '/admin/vtmin-checkbox-classes.php'; require VTMIN_DIRNAME . '/admin/vtmin-rules-delete.php'; //v1.09.2 begin if (defined('VTMIN_PRO_DIRNAME') && version_compare(VTMIN_PRO_VERSION, VTMIN_MINIMUM_PRO_VERSION) < 0) { //'<0' = 1st value is lower add_action('admin_notices', array(&$this, 'vtmin_admin_notice_version_mismatch')); } //v1.09.2 end } //unconditional branch for these resources needed for WOOCommerce, at "place order" button time require VTMIN_DIRNAME . '/core/vtmin-cart-classes.php'; if (defined('VTMIN_PRO_DIRNAME')) { require VTMIN_PRO_DIRNAME . '/core/vtmin-apply-rules.php'; } else { require VTMIN_DIRNAME . '/core/vtmin-apply-rules.php'; } wp_enqueue_script('jquery'); }
public function vtmin_woo_apply_checkout_cntl() { //v1.0.9.4 added passed value //v1.09.5 begin if (is_admin()) { return; } //v1.09.5 end global $vtmin_cart, $vtmin_cart_item, $vtmin_rules_set, $vtmin_rule, $vtmin_info, $woocommerce, $vtmin_setup_options; vtmin_debug_options(); //v1.09 //input and output to the apply_rules routine in the global variables. // results are put into $vtmin_cart /* v1.09.1 cart not there yet... if ( $vtmin_cart->error_messages_processed == 'yes' ) { wc_add_notice( __('Minimum Purchase error found.', 'vtmin'), $notice_type = 'error' ); //supplies an error msg and prevents payment from completing v1.09 return; } */ //v1.0.9.4 begin $vtmin_info['woo_cart_url'] = $this->vtmin_woo_get_url('cart'); $vtmin_info['woo_checkout_url'] = $this->vtmin_woo_get_url('checkout'); $vtmin_info['currPageURL'] = $this->vtmin_currPageURL(); if ($vtmin_setup_options['show_errors_on_all_pages'] == 'yes' && isset($woocommerce) && sizeof($woocommerce->cart->get_cart()) > 0) { //only process on woo pages - "is_woocommerce()" doesn't do the job $carry_on; } else { $currPageURL = $vtmin_info['currPageURL']; $woo_cart_url = $vtmin_info['woo_cart_url']; $woo_checkout_url = $vtmin_info['woo_checkout_url']; // if an ITEM HAS BEEN REMOVED, url is apemnded to (&...) , can't look for equality - look for a substring // (if CUSTOM MESSAGE not used, JS message does NOT come across in the situation where all was good, and then an item is removed) if (strpos($currPageURL, $woo_cart_url) !== false || strpos($currPageURL, $woo_checkout_url) !== false) { //BOOLEAN == true... //v1.09.5 end $carry_on; } else { return; } //v1.0.9.4 end } $vtmin_apply_rules = new VTMIN_Apply_Rules(); //ERROR Message Path if (sizeof($vtmin_cart->error_messages) > 0) { //v1.08 changes begin switch ($vtmin_cart->error_messages_are_custom) { case 'all': $this->vtmin_display_custom_messages(); break; case 'some': $this->vtmin_display_custom_messages(); $this->vtmin_display_standard_messages(); break; default: //'none' / no state set yet $this->vtmin_display_standard_messages(); //v1.09.1 begin //v1.09.5 REMOVED /* $current_version = WOOCOMMERCE_VERSION; if( (version_compare(strval('2.1.0'), strval($current_version), '>') == 1) ) { //'==1' = 2nd value is lower $woocommerce->add_error( __('Minimum Purchase error found.', 'vtmin') ); //supplies an error msg and prevents payment from completing } else { */ //added in woo 2.1 // wc_add_notice( __('Minimum Purchase error found.', 'vtmin'), 'error' ); //supplies an error msg and prevents payment from completing // wc_add_notice( __('Minimum Purchase error found.', 'vtmin'), $notice_type = 'error' ); //supplies an error msg and prevents payment from completing // } //v1.09.5 REMOVED //v1.09.1 end break; } //v1.08 changes end } }