public function vtprd_do_loaded_housekeeping() { //error_log( print_r( 'Function begin - vtprd_do_loaded_housekeeping', true ) ); //v1.1.1 begin - if (is_admin()) { return; } // "do_no_actions" set/unset in function vtprd_build_product_price_array if (!isset($_SESSION)) { session_start(); header("Cache-Control: no-cache"); header("Pragma: no-cache"); } if (isset($_SESSION['do_no_actions']) && $_SESSION['do_no_actions']) { return; } //v1.1.1 end global $woocommerce, $current_user, $vtprd_setup_options, $vtprd_info; vtprd_debug_options(); //v1.1 //******************** //v1.1.0.7 begin if ($vtprd_setup_options['wholesale_products_display'] == '' || $vtprd_setup_options['wholesale_products_display'] == 'noAction') { $skip_this = true; } else { if (defined('VTPRD_PRO_DIRNAME')) { add_filter('woocommerce_product_is_visible', array(&$this, 'vtprd_maybe_woocommerce_is_visible'), 10, 2); } } //v1.1.0.7 end //******************** //******************** //v1.1.1 begin if ($vtprd_setup_options['wholesale_products_price_display'] == '' || $vtprd_setup_options['wholesale_products_price_display'] == 'noAction') { $skip_this = true; } else { if (defined('VTPRD_PRO_DIRNAME')) { add_filter('woocommerce_is_purchasable', array(&$this, 'vtprd_maybe_woocommerce_is_purchasable'), 10, 2); } } //v1.1.1 end //******************** //------------ //v1.1.1 begin //***************************************************** // PLUGIN:: woocommerce-measurement-price-calculator // PLUGIN:: woocommerce-product-addons //***************************************************** //ONLY way to get the price to the faux variations for CATALOG rules... ADDS a lot of processing time //ONLY DO GET_PRICE FOR THese PLUGINs!!!! //************************************************************************************************************************************************ //ACTIVATED externally by the client, or internally for the Addons or Calculator plugins //the apply_filter is done twice - once in parent-cart-validation in housekeeping, and once in parent-functions in vtprd_get_current_active_price //************************************************************************************************************************************************ $do_get_price = apply_filters('vtprd_do_compatability_pricing', false); /* sample execution for CLIENT // *** add to bottom of Theme Functions file //allows Pricing Deals to pick up current product pricing from other plugins // --- more resource intensive --- add_filter('vtprd_do_compatability_pricing', 'do_compatability_pricing', 10, 1); function do_compatability_pricing ($return_status) { return true; } */ if (class_exists('WC_Measurement_Price_Calculator') || class_exists('WC_Product_Addons') || $do_get_price) { if (!is_admin()) { $filter_added = false; //only needed for CATALOG rules if (class_exists('WC_Product_Addons') && get_option('vtprd_ruleset_has_a_display_rule') == 'yes') { add_filter('woocommerce_get_price', array(&$this, 'vtprd_maybe_get_price'), 10, 2); //only way to get the price to the faux variations... $filter_added = true; } //needed for ALL rules - but this logic prevents double add_filter... if (class_exists('WC_Measurement_Price_Calculator') && !$filter_added) { add_filter('woocommerce_get_price', array(&$this, 'vtprd_maybe_get_price'), 10, 2); //only way to get the price to the faux variations... $filter_added = true; } //THIS IS TO ALLOW compatability with other plugins that need to use get_price for single_product and Cart pricing // (all other filters are SHUT OFF during this call, and the get_price call to Pricing Deals is just returned....) if ($do_get_price && !$filter_added) { add_filter('woocommerce_get_price', array(&$this, 'vtprd_maybe_get_price'), 10, 2); //allows single_product call to use get_price //NOT NEEDED?????????????????? //add_filter('vtprd_get_price_always_reflects_back_input', 'vtprd_get_price_always_reflects_back_input', 10, 1); $filter_added = true; } /* //CURRENTLY INACTIVE (for now Bolt-ons only allow Coupon Discounting) if (class_exists('WC_Measurement_Price_Calculator')) { add_filter('woocommerce_cart_subtotal', array(&$this, 'vtprd_maybe_cart_subtotal'), 10, 3); //only way to get the price to the faux variations... } */ } } //v1.1.1 end //---------- if (!is_object($woocommerce->customer) || empty($woocommerce->customer) || $woocommerce->customer->is_vat_exempt()) { return; } // check user-level tax exemption (plugin-specific checkbox on user screen) //USER LEVEL TAX EXEMPTION = ALL TRANSACTIONS TAX EXEMPT if (get_user_meta($current_user->ID, 'vtprd_user_is_tax_exempt', true) == 'yes') { $woocommerce->customer->is_vat_exempt == true; return; } if (!$current_user) { $current_user = wp_get_current_user(); } //check role-level tax exemption (plugin-specific role capability) if (current_user_can('buy_tax_free')) { $woocommerce->customer->is_vat_exempt = true; } return; }
public function vtprd_controller_init() { global $vtprd_setup_options; //$product->get_rating_count() odd error at checkout... woocommerce/templates/single-product-reviews.php on line 20 // (Fatal error: Call to a member function get_rating_count() on a non-object) global $product; load_plugin_textdomain('vtprd', null, dirname(plugin_basename(__FILE__)) . '/languages'); //v1.0.8.4 moved here above defs //v1.0.9.3 info not avail here //if ($vtprd_setup_options['discount_taken_where'] == 'discountCoupon') { //v1.0.9.0 doesn't apply if 'discountUnitPrice' //v1.0.8.5 begin // instead of translation, using filter to allow title change!!!!!!!! // this propagates throughout all plugin code execution through global... $coupon_title = apply_filters('vtprd_coupon_code_discount_title', ''); if ($coupon_title) { global $vtprd_info; $vtprd_info['coupon_code_discount_deal_title'] = $coupon_title; } // } //v1.0.9.0 /* // Sample filter execution ==>> put into your theme's functions.php file, so it's not affected by plugin updates function coupon_code_discount_title() { return 'different coupon title'; //<<== Change this text to be the title you want!!! } add_filter('vtprd_coupon_code_discount_title', 'coupon_code_discount_title', 10); */ //v1.0.8.5 end //Split off for AJAX add-to-cart, etc for Class resources. Loads for is_Admin and true INIT loads are kept here. //require_once ( VTPRD_DIRNAME . '/core/vtprd-load-execution-resources.php' ); require_once VTPRD_DIRNAME . '/core/vtprd-backbone.php'; require_once VTPRD_DIRNAME . '/core/vtprd-rules-classes.php'; require_once VTPRD_DIRNAME . '/admin/vtprd-rules-ui-framework.php'; require_once VTPRD_DIRNAME . '/woo-integration/vtprd-parent-functions.php'; require_once VTPRD_DIRNAME . '/woo-integration/vtprd-parent-theme-functions.php'; require_once VTPRD_DIRNAME . '/woo-integration/vtprd-parent-cart-validation.php'; // require_once ( VTPRD_DIRNAME . '/woo-integration/vtprd-parent-definitions.php'); //v1.0.8.4 moved above require_once VTPRD_DIRNAME . '/core/vtprd-cart-classes.php'; //************ //changed for AJAX add-to-cart, removed the is_admin around these resources => didn't work, for whatever reason... if (defined('VTPRD_PRO_DIRNAME')) { require_once VTPRD_PRO_DIRNAME . '/core/vtprd-apply-rules.php'; require_once VTPRD_PRO_DIRNAME . '/woo-integration/vtprd-lifetime-functions.php'; } else { require_once VTPRD_DIRNAME . '/core/vtprd-apply-rules.php'; } $vtprd_setup_options = get_option('vtprd_setup_options'); //put the setup_options into the global namespace //************************** //v1.0.9.0 begin //************************** switch (true) { case is_admin(): //absolutely REQUIRED!!! $do_nothing; break; case $vtprd_setup_options['discount_taken_where'] == 'discountCoupon': $do_nothing; break; case $vtprd_setup_options['discount_taken_where'] == 'discountUnitPrice': //turn off switches not allowed for "discountUnitPrice" ==> done on the fly, rather than at update time... $vtprd_setup_options['show_checkout_purchases_subtotal'] = 'none'; $vtprd_setup_options['show_checkout_discount_total_line'] = 'no'; $vtprd_setup_options['checkout_new_subtotal_line'] = 'no'; $vtprd_setup_options['show_cartWidget_purchases_subtotal'] = 'none'; $vtprd_setup_options['show_cartWidget_discount_total_line'] = 'no'; $vtprd_setup_options['cartWidget_new_subtotal_line'] = 'no'; break; default: // supply default for new variables as needed for upgrade v1.0.8.9 => v1.0.9.0 as needed $vtprd_setup_options['discount_taken_where'] = 'discountCoupon'; $vtprd_setup_options['give_more_or_less_discount'] = 'more'; $vtprd_setup_options['show_unit_price_cart_discount_crossout'] = 'yes'; //v1.0.9.3 ==> for help when switching to unit pricing... $vtprd_setup_options['show_unit_price_cart_discount_computation'] = 'no'; //v1.0.9.3 update_option('vtprd_setup_options', $vtprd_setup_options); //v1.0.9.1 break; } //v1.0.9.0 end if (function_exists('vtprd_debug_options')) { vtprd_debug_options(); //v1.0.5 } /* ********************************** Set GMT time zone for Store Since Web Host can be on a different continent, with a different *Day* and Time, than the actual store. Needed for Begin/end date processing ********************************** */ vtprd_set_selected_timezone(); if (is_admin()) { add_filter('plugin_action_links_' . VTPRD_PLUGIN_SLUG, array($this, 'vtprd_custom_action_links')); require_once VTPRD_DIRNAME . '/admin/vtprd-setup-options.php'; require_once VTPRD_DIRNAME . '/admin/vtprd-rules-ui.php'; if (defined('VTPRD_PRO_DIRNAME')) { require_once VTPRD_PRO_DIRNAME . '/admin/vtprd-rules-update.php'; require_once VTPRD_PRO_DIRNAME . '/woo-integration/vtprd-lifetime-functions.php'; } else { require_once VTPRD_DIRNAME . '/admin/vtprd-rules-update.php'; } require_once VTPRD_DIRNAME . '/admin/vtprd-show-help-functions.php'; require_once VTPRD_DIRNAME . '/admin/vtprd-checkbox-classes.php'; require_once VTPRD_DIRNAME . '/admin/vtprd-rules-delete.php'; $this->vtprd_admin_init(); //v1.0.7.1 begin /* v1.1.0.1 replaced with new notification at admin_init if ( (defined('VTPRD_PRO_DIRNAME')) && (version_compare(VTPRD_PRO_VERSION, VTPRD_MINIMUM_PRO_VERSION) < 0) ) { //'<0' = 1st value is lower add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_version_mismatch') ); } */ //v1.0.7.1 end /* //v1.0.9.3 moved to functions to be run at admin-init time if ($vtprd_setup_options['discount_taken_where'] == 'discountCoupon') { //v1.0.9.3 doesn't apply if 'discountUnitPrice' //v1.0.7.4 begin //**************************************** //INSIST that coupons be enabled in woo, in order for this plugin to work!! //**************************************** //always check if the manually created coupon codes are there - if not create them. vtprd_woo_maybe_create_coupon_types(); $coupons_enabled = get_option( 'woocommerce_enable_coupons' ) == 'no' ? false : true; if (!$coupons_enabled) { add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_coupon_enable_required') ); } } */ // don't have to do this EXCEPT at install time.... // $this->vtprd_maybe_add_wholesale_role(); //v1.0.9.0 //v1.0.7.4 end } else { add_action("wp_enqueue_scripts", array(&$this, 'vtprd_enqueue_frontend_scripts'), 1); //priority 1 to run 1st, so front-end-css can be overridden by another file with a dependancy } /* if (is_admin()){ //LIFETIME logid cleanup... // LogID logic from wpsc-admin/init.php if(defined('VTPRD_PRO_DIRNAME')) { switch( true ) { case ( isset( $_REQUEST['wpsc_admin_action2'] ) && ($_REQUEST['wpsc_admin_action2'] == 'purchlog_bulk_modify') ) : vtprd_maybe_lifetime_log_bulk_modify(); break; case ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'delete_purchlog') ) : vtprd_maybe_lifetime_log_roll_out_cntl(); break; } if (version_compare(VTPRD_PRO_VERSION, VTPRD_MINIMUM_PRO_VERSION) < 0) { //'<0' = 1st value is lower add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_version_mismatch') ); } } //**************************************** //INSIST that coupons be enabled in woo, in order for this plugin to work!! //**************************************** $coupons_enabled = get_option( 'woocommerce_enable_coupons' ) == 'no' ? false : true; if (!$coupons_enabled) { add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_coupon_enable_required') ); } } */ return; }
function vtprd_check_for_page() { if (!isset($_SESSION)) { session_start(); header("Cache-Control: no-cache"); header("Pragma: no-cache"); } vtprd_debug_options(); //v1.1 global $wp_query; $postID = $wp_query->post->ID; global $vtprd_info; //have to set these at init time - accessed in ajax, and is_page not available there if ($postID == get_option("woocommerce_cart_page_id") || $postID == get_option("woocommerce_checkout_page_id")) { $_SESSION['on_cart_or_checkout_page'] = true; } else { $_SESSION['on_cart_or_checkout_page'] = false; } }
public function vtprd_controller_init() { //error_log( print_r( 'Function begin - vtprd_controller_init', true ) ); global $vtprd_setup_options; //$product->get_rating_count() odd error at checkout... woocommerce/templates/single-product-reviews.php on line 20 // (Fatal error: Call to a member function get_rating_count() on a non-object) global $product; load_plugin_textdomain('vtprd', null, dirname(plugin_basename(__FILE__)) . '/languages'); //v1.0.8.4 moved here above defs //v1.0.9.3 info not avail here //if ($vtprd_setup_options['discount_taken_where'] == 'discountCoupon') { //v1.0.9.0 doesn't apply if 'discountUnitPrice' //v1.0.8.5 begin // instead of translation, using filter to allow title change!!!!!!!! // this propagates throughout all plugin code execution through global... $coupon_title = apply_filters('vtprd_coupon_code_discount_title', ''); if ($coupon_title) { global $vtprd_info; $vtprd_info['coupon_code_discount_deal_title'] = $coupon_title; } // } //v1.0.9.0 /* // Sample filter execution ==>> put into your theme's functions.php file, so it's not affected by plugin updates function coupon_code_discount_title() { return 'different coupon title'; //<<== Change this text to be the title you want!!! } add_filter('vtprd_coupon_code_discount_title', 'coupon_code_discount_title', 10); */ //v1.0.8.5 end //Split off for AJAX add-to-cart, etc for Class resources. Loads for is_Admin and true INIT loads are kept here. //require_once ( VTPRD_DIRNAME . '/core/vtprd-load-execution-resources.php' ); require_once VTPRD_DIRNAME . '/core/vtprd-backbone.php'; require_once VTPRD_DIRNAME . '/core/vtprd-rules-classes.php'; require_once VTPRD_DIRNAME . '/admin/vtprd-rules-ui-framework.php'; require_once VTPRD_DIRNAME . '/woo-integration/vtprd-parent-functions.php'; require_once VTPRD_DIRNAME . '/woo-integration/vtprd-parent-theme-functions.php'; require_once VTPRD_DIRNAME . '/woo-integration/vtprd-parent-cart-validation.php'; // require_once ( VTPRD_DIRNAME . '/woo-integration/vtprd-parent-definitions.php'); //v1.0.8.4 moved above require_once VTPRD_DIRNAME . '/core/vtprd-cart-classes.php'; require_once VTPRD_DIRNAME . '/core/vtprd-cron-class.php'; //v1.1.6 //*************** //v1.1.5 begin // Licensing and Phone Home ONLY occurs when the purchased PRO version is installed //*************** require_once VTPRD_DIRNAME . '/admin/vtprd-license-options.php'; global $vtprd_license_options; $vtprd_license_options = get_option('vtprd_license_options'); $this->vtprd_init_update_license(); if ($vtprd_setup_options['debugging_mode_on'] == 'yes') { error_log(print_r('Begin FREE plugin, vtprd_license_options= ', true)); error_log(var_export($vtprd_license_options, true)); } /* //********************************************************* VTPRD_PRO_DIRNAME trigger for Pro functionality... ONLY if PRO is active if fatal status, deactivate PRO if pending status and ADMIN, load PRO stuff if pending status and EXECUTION, load FREE stuff Otherwise, load FREE //********************************************************* */ //v1.1.6 begin /* NOW DO IN A CRON JOB //moved here if (is_admin) { $test_done_elsewhere = true; } else { //error_log( print_r( 'vtprd_maybe_recheck_license_activation CART ', true ) ); vtprd_maybe_recheck_license_activation(); //v1.1.6 added 1/12hr license recheck to SHOP function too. } */ //v1.1.6 end $avanti = false; //v1.1.5 //VTPRD_PRO_VERSION only exists if PRO version is installed and active if (defined('VTPRD_PRO_VERSION')) { switch (true) { //if fatal status, set Pro to deactivate during admin_init /* v1.1.6.3 version_status issues are NO LONger a deactivation action! case ( ($vtprd_license_options['state'] == 'suspended-by-vendor') || ( ($vtprd_license_options['pro_plugin_version_status'] != 'valid') && ($vtprd_license_options['pro_plugin_version_status'] != null)) ) : //null = default */ case $vtprd_license_options['state'] == 'suspended-by-vendor': //set up deactivate during admin_init - it's not available yet! done out of vtprd_maybe_pro_deactivate_action $vtprd_license_options['pro_deactivate'] = 'yes'; update_option('vtprd_license_options', $vtprd_license_options); break; //if admin and (good or warning status) //if admin and (good or warning status) case is_admin(): define('VTPRD_PRO_DIRNAME', VTPRD_PRO_DIRNAME_IF_ACTIVE); $avanti = true; //v1.1.5 if ($vtprd_setup_options['debugging_mode_on'] == 'yes') { error_log(print_r('is_admin, VTPRD_PRO_DIRNAME defined ', true)); } break; //if frontend execution and all good status //if frontend execution and all good status default: if ($vtprd_license_options['status'] == 'valid' && $vtprd_license_options['state'] == 'active' && $vtprd_license_options['pro_plugin_version_status'] == 'valid') { define('VTPRD_PRO_DIRNAME', VTPRD_PRO_DIRNAME_IF_ACTIVE); $avanti = true; //v1.1.5 if ($vtprd_setup_options['debugging_mode_on'] == 'yes') { error_log(print_r('During Execution, VTPRD_PRO_DIRNAME defined ', true)); } //so CRON JOB ONLY RUN if PRO is active //v1.1.6.3 Refactored. Demo no longer available, due to HACKING add_action('vtprd_twice_daily_scheduled_events', 'vtprd_recheck_license_activation'); /* //v1.1.6.1 begin if ($vtprd_license_options['prod_or_test'] == 'demo') { add_action( 'vtprd_thrice_daily_scheduled_events', 'vtprd_recheck_license_activation' ); } else { //for a non-demo, only do twice per day remove_action( 'vtprd_thrice_daily_scheduled_events', 'vtprd_recheck_license_activation' ); add_action( 'vtprd_twice_daily_scheduled_events', 'vtprd_recheck_license_activation' ); } //v1.1.6.1 end */ //v1.1.6.3 end } break; } } //*************** //v1.1.5 end //*************** $vtprd_setup_options = get_option('vtprd_setup_options'); //put the setup_options into the global namespace //************************** //v1.0.9.0 begin //************************** switch (true) { case is_admin(): //absolutely REQUIRED!!! $do_nothing; break; case $vtprd_setup_options['discount_taken_where'] == 'discountCoupon': $do_nothing; break; case $vtprd_setup_options['discount_taken_where'] == 'discountUnitPrice': //turn off switches not allowed for "discountUnitPrice" ==> done on the fly, rather than at update time... $vtprd_setup_options['show_checkout_purchases_subtotal'] = 'none'; $vtprd_setup_options['show_checkout_discount_total_line'] = 'no'; $vtprd_setup_options['checkout_new_subtotal_line'] = 'no'; $vtprd_setup_options['show_cartWidget_purchases_subtotal'] = 'none'; $vtprd_setup_options['show_cartWidget_discount_total_line'] = 'no'; $vtprd_setup_options['cartWidget_new_subtotal_line'] = 'no'; break; default: // supply default for new variables as needed for upgrade v1.0.8.9 => v1.0.9.0 as needed $vtprd_setup_options['discount_taken_where'] = 'discountCoupon'; $vtprd_setup_options['give_more_or_less_discount'] = 'more'; $vtprd_setup_options['show_unit_price_cart_discount_crossout'] = 'yes'; //v1.0.9.3 ==> for help when switching to unit pricing... $vtprd_setup_options['show_unit_price_cart_discount_computation'] = 'no'; //v1.0.9.3 update_option('vtprd_setup_options', $vtprd_setup_options); //v1.0.9.1 break; } //v1.0.9.0 end if (function_exists('vtprd_debug_options')) { vtprd_debug_options(); //v1.0.5 } /* ********************************** Set GMT time zone for Store Since Web Host can be on a different continent, with a different *Day* and Time, than the actual store. Needed for Begin/end date processing ********************************** */ vtprd_set_selected_timezone(); if (is_admin()) { add_filter('plugin_action_links_' . VTPRD_PLUGIN_SLUG, array($this, 'vtprd_custom_action_links')); require_once VTPRD_DIRNAME . '/admin/vtprd-setup-options.php'; require_once VTPRD_DIRNAME . '/admin/vtprd-rules-ui.php'; //if ((defined('VTPRD_PRO_DIRNAME')) ) { //v1.1.5 if ($avanti) { //v1.1.5 require_once VTPRD_PRO_DIRNAME . '/admin/vtprd-rules-update.php'; require_once VTPRD_PRO_DIRNAME . '/woo-integration/vtprd-lifetime-functions.php'; } else { require_once VTPRD_DIRNAME . '/admin/vtprd-rules-update.php'; } require_once VTPRD_DIRNAME . '/admin/vtprd-show-help-functions.php'; require_once VTPRD_DIRNAME . '/admin/vtprd-checkbox-classes.php'; require_once VTPRD_DIRNAME . '/admin/vtprd-rules-delete.php'; $this->vtprd_admin_process(); //v1.1.5 //v1.0.7.1 begin /* v1.1.0.1 replaced with new notification at admin_init if ( (defined('VTPRD_PRO_DIRNAME')) && (version_compare(VTPRD_PRO_VERSION, VTPRD_MINIMUM_PRO_VERSION) < 0) ) { //'<0' = 1st value is lower add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_version_mismatch') ); } */ //v1.0.7.1 end /* //v1.0.9.3 moved to functions to be run at admin-init time if ($vtprd_setup_options['discount_taken_where'] == 'discountCoupon') { //v1.0.9.3 doesn't apply if 'discountUnitPrice' //v1.0.7.4 begin //**************************************** //INSIST that coupons be enabled in woo, in order for this plugin to work!! //**************************************** //always check if the manually created coupon codes are there - if not create them. vtprd_woo_maybe_create_coupon_types(); $coupons_enabled = get_option( 'woocommerce_enable_coupons' ) == 'no' ? false : true; if (!$coupons_enabled) { add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_coupon_enable_required') ); } } */ // don't have to do this EXCEPT at install time.... // $this->vtprd_maybe_add_wholesale_role(); //v1.0.9.0 //v1.0.7.4 end //******************************************************************************* //v1.1.6 BEGIN //v1.1.6 Commented the else, and CHANGED for below - apply-rules CAN be executed in ADMIN, if pricing is called. need the resources, so put back into MAINLINE! //************** /* } else { add_action( "wp_enqueue_scripts", array(&$this, 'vtprd_enqueue_frontend_scripts'), 1 ); //priority 1 to run 1st, so front-end-css can be overridden by another file with a dependancy //v1.1.5 BEGIN // the 'plugin_version_valid' switches are set in ADMIN, but only used in the Front End //if (defined('VTPRD_PRO_DIRNAME')) { //v1.1.5 if ($avanti) { //v1.1.5 require_once ( VTPRD_PRO_DIRNAME . '/core/vtprd-apply-rules.php' ); require_once ( VTPRD_PRO_DIRNAME . '/woo-integration/vtprd-lifetime-functions.php' ); if ( $vtprd_setup_options['debugging_mode_on'] == 'yes' ){ error_log( print_r( 'Free Plugin begin, Loaded PRO plugin apply-rules', true ) ); } } else { require_once ( VTPRD_DIRNAME . '/core/vtprd-apply-rules.php' ); if ( $vtprd_setup_options['debugging_mode_on'] == 'yes' ){ error_log( print_r( 'Free Plugin begin, Loaded PFREE plugin apply-rules', true ) ); } } //v1.1.5 End } */ } add_action("wp_enqueue_scripts", array(&$this, 'vtprd_enqueue_frontend_scripts'), 1); //priority 1 to run 1st, so front-end-css can be overridden by another file with a dependancy //v1.1.5 BEGIN // the 'plugin_version_valid' switches are set in ADMIN, but only used in the Front End //if (defined('VTPRD_PRO_DIRNAME')) { //v1.1.5 if ($avanti) { //v1.1.5 require_once VTPRD_PRO_DIRNAME . '/core/vtprd-apply-rules.php'; require_once VTPRD_PRO_DIRNAME . '/woo-integration/vtprd-lifetime-functions.php'; if ($vtprd_setup_options['debugging_mode_on'] == 'yes') { error_log(print_r('Free Plugin begin, Loaded PRO plugin apply-rules, settings= ', true)); error_log(var_export($vtprd_setup_options, true)); } } else { require_once VTPRD_DIRNAME . '/core/vtprd-apply-rules.php'; if ($vtprd_setup_options['debugging_mode_on'] == 'yes') { error_log(print_r('Free Plugin begin, Loaded PFREE plugin apply-rules', true)); } } //v1.1.5 End //******************************************************************************* //v1.1.6 END //******************************************************************************* /* if (is_admin()){ //LIFETIME logid cleanup... // LogID logic from wpsc-admin/init.php if(defined('VTPRD_PRO_DIRNAME')) { switch( true ) { case ( isset( $_REQUEST['wpsc_admin_action2'] ) && ($_REQUEST['wpsc_admin_action2'] == 'purchlog_bulk_modify') ) : vtprd_maybe_lifetime_log_bulk_modify(); break; case ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'delete_purchlog') ) : vtprd_maybe_lifetime_log_roll_out_cntl(); break; } if (version_compare(VTPRD_PRO_VERSION, VTPRD_MINIMUM_PRO_VERSION) < 0) { //'<0' = 1st value is lower add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_version_mismatch') ); } } //**************************************** //INSIST that coupons be enabled in woo, in order for this plugin to work!! //**************************************** $coupons_enabled = get_option( 'woocommerce_enable_coupons' ) == 'no' ? false : true; if (!$coupons_enabled) { add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_coupon_enable_required') ); } } */ //v1.1.5 BEGIN ==>> shifted down here! //********************************* //don't run in admin, this is ONLY for executions //********************************* /* if (is_admin() ) { $skip_this = true; } else { // the 'plugin_version_valid' switches are set in ADMIN, but only used in the Front End if (defined('VTPRD_PRO_DIRNAME')) { require_once ( VTPRD_PRO_DIRNAME . '/core/vtprd-apply-rules.php' ); require_once ( VTPRD_PRO_DIRNAME . '/woo-integration/vtprd-lifetime-functions.php' ); if ( $vtprd_setup_options['debugging_mode_on'] == 'yes' ){ error_log( print_r( 'Free Plugin begin, Loaded PRO plugin apply-rules', true ) ); } } else { require_once ( VTPRD_DIRNAME . '/core/vtprd-apply-rules.php' ); if ( $vtprd_setup_options['debugging_mode_on'] == 'yes' ){ error_log( print_r( 'Free Plugin begin, Loaded PFREE plugin apply-rules', true ) ); } } } */ //v1.1.5 end return; }
public function vtprd_set_woo_customer_tax_exempt() { global $woocommerce, $current_user; vtprd_debug_options(); //v1.1 if (!is_object($woocommerce->customer) || empty($woocommerce->customer) || $woocommerce->customer->is_vat_exempt()) { return; } // check user-level tax exemption (plugin-specific checkbox on user screen) //USER LEVEL TAX EXEMPTION = ALL TRANSACTIONS TAX EXEMPT if (get_user_meta($current_user->ID, 'vtprd_user_is_tax_exempt', true) == 'yes') { $woocommerce->customer->is_vat_exempt == true; return; } if (!$current_user) { $current_user = wp_get_current_user(); } //check role-level tax exemption (plugin-specific role capability) if (current_user_can('buy_tax_free', $user_id)) { $woocommerce->customer->is_vat_exempt == true; } return; }
function vtprd_move_vtprd_single_product_to_session($product_id) { global $post, $wpdb, $woocommerce, $vtprd_cart, $vtprd_cart_item, $vtprd_info, $vtprd_setup_options, $vtprd_rules_set; vtprd_debug_options(); //v1.0.9.4 $short_msg_array = array(); $full_msg_array = array(); $msg_already_done = 'no'; $show_yousave_one_some_msg = ''; //v1.0.8.0 //auditTrail keyed to rule_id, so foreach is necessary foreach ($vtprd_cart->cart_items[0]->cartAuditTrail as $key => $row) { //parent product vargroup on sale, individual product variation may not be on sale. // send an additional sale msg for the varProd parent group... $show_yousave_one_some_msg = ''; if ($vtprd_setup_options['show_yousave_one_some_msg'] == 'yes') { if (!$show_yousave_one_some_msg) { $rulesetKey = $row['ruleset_occurrence']; switch ($vtprd_rules_set[$rulesetKey]->inPop_varProdID_parentLit) { case 'one': $show_yousave_one_some_msg = __('One of these are on Sale', 'vtprd'); break; case 'some': $show_yousave_one_some_msg = __('Some of these are on Sale', 'vtprd'); break; case 'all': //all are on sale, handled as normal. break; default: //handled as normal. break; } } } if ($row['rule_short_msg'] > ' ') { $short_msg_array[] = $row['rule_short_msg']; $full_msg_array[] = $row['rule_full_msg']; } } /* if $vtprd_cart->cart_level_status == 'rejected' no discounts found how to handle yousave display, etc.... If no yousave, return 'false' */ if ($vtprd_cart->cart_level_status == 'rejected') { $vtprd_cart->cart_items[0]->discount_price = 0; $vtprd_cart->cart_items[0]->yousave_total_amt = 0; $vtprd_cart->cart_items[0]->yousave_total_pct = 0; } //needed for wp-e-commerce!!!!!!!!!!! // if = 'yes', display of 'yousave' becomes 'save FROM' and doesn't change!!!!!!! // $product_variations_sw = vtprd_test_for_variations($product_id); $product_variations_sw = ''; //v1.0.9.0 begin $number_of_times = 1; vtprd_get_cart_html_prices($number_of_times, 'catalog'); //************************* //v1.0.9.0 begin refactored //************************* if ($vtprd_cart->cart_items[0]->yousave_total_amt > 0) { $list_price = $vtprd_cart->cart_items[0]->db_unit_price_list; //v1.0.8.8 begin //if taxation should be applied to list price, do so here if (get_option('woocommerce_calc_taxes') == 'yes' && get_option('woocommerce_prices_include_tax') == 'no' && get_option('woocommerce_tax_display_cart') == 'incl') { $list_price = vtprd_get_price_including_tax($product_id, $list_price); //error_log( print_r( 'vtprd_get_price_including_tax 001, price= ' .$list_price , true ) ); } //v1.0.8.8 end $vtprd_cart->cart_items[0]->product_list_price_html_woo = woocommerce_price($list_price); } //v1.0.9.0 end //v1.0.9.3 begin //load info for old_price used later if ($vtprd_cart->cart_items[0]->yousave_total_amt > 0 && $vtprd_setup_options['show_catalog_price_crossout'] == 'yes') { switch (true) { //v1.1.0.4 begin case $vtprd_cart->cart_items[0]->product_is_on_special == 'yes': /* case ( ($vtprd_cart->cart_items[0]->db_unit_price_special > 0 ) && ($vtprd_cart->cart_items[0]->db_unit_price_special < $vtprd_cart->cart_items[0]->db_unit_price_list ) ) : //there is a discount... */ //v1.1.0.4 end $product_orig_price = $vtprd_cart->cart_items[0]->db_unit_price_special; //special_price needs formatting ... break; default: $product_orig_price = $vtprd_cart->cart_items[0]->db_unit_price_list; break; } $product_orig_price_html_woo = wc_price($product_orig_price); if (get_option('woocommerce_calc_taxes') == 'yes') { if (get_option('woocommerce_prices_include_tax') == 'yes') { if (get_option('woocommerce_tax_display_shop') == 'excl') { $product = get_product($product_id); $product_orig_price_excl_tax = vtprd_get_price_excluding_tax_forced($product_id, $product_orig_price, $product); $product_orig_price_html_woo = wc_price($product_orig_price_excl_tax); } } else { if (get_option('woocommerce_tax_display_shop') == 'incl') { $product = get_product($product_id); $product_orig_price_incl_tax = vtprd_get_price_including_tax_forced($product_id, $product_orig_price, $product); $product_orig_price_html_woo = wc_price($product_orig_price_incl_tax); } } } /* switch (true) { case ( (get_option( 'woocommerce_tax_display_shop' ) == 'excl' ) : $oldprice = $vtprd_cart_item->product_catalog_price_displayed_incl_tax_woo; break; case ( (get_option( 'woocommerce_tax_display_shop' ) == 'incl' ) && (get_option( 'woocommerce_tax_display_cart' ) == 'excl') ) : $oldprice = $vtprd_cart_item->product_catalog_price_displayed_excl_tax_woo; break; default: $oldprice = $vtprd_cart_item->product_catalog_price_displayed; break; } $product = get_product( $product_id ); $product_orig_price_incl_tax = vtprd_get_price_including_tax_forced($product_id, $product_orig_price, $product); $product_orig_price_html_woo = wc_price($product_orig_price_incl_tax); $product = get_product( $product_id ); $product_orig_price_incl_tax = vtprd_get_price_including_tax_forced($product_id, $product_orig_price, $product); $product_orig_price_incl_tax_html_woo = wc_price($product_orig_price_incl_tax); $product_orig_price_excl_tax = vtprd_get_price_excluding_tax_forced($product_id, $product_orig_price, $product); $product_orig_price_excl_tax_html_woo = wc_price($product_orig_price_excl_tax); */ } //v1.0.9.3 end $vtprd_info['product_session_info'] = array('product_list_price' => $vtprd_cart->cart_items[0]->db_unit_price_list, 'product_list_price_html_woo' => $vtprd_cart->cart_items[0]->product_list_price_html_woo, 'product_unit_price' => $vtprd_cart->cart_items[0]->db_unit_price, 'product_special_price' => $vtprd_cart->cart_items[0]->db_unit_price_special, 'product_discount_price' => $vtprd_cart->cart_items[0]->product_discount_price_woo, 'product_discount_price_html_woo' => $vtprd_cart->cart_items[0]->product_discount_price_html_woo, 'product_discount_price_incl_tax_woo' => $vtprd_cart->cart_items[0]->product_discount_price_incl_tax_woo, 'product_discount_price_excl_tax_woo' => $vtprd_cart->cart_items[0]->product_discount_price_excl_tax_woo, 'product_discount_price_incl_tax_html_woo' => $vtprd_cart->cart_items[0]->product_discount_price_incl_tax_html_woo, 'product_discount_price_excl_tax_html_woo' => $vtprd_cart->cart_items[0]->product_discount_price_excl_tax_html_woo, 'product_discount_price_suffix_html_woo' => $vtprd_cart->cart_items[0]->product_discount_price_suffix_html_woo, 'product_catalog_yousave_total_amt_incl_tax_woo' => $vtprd_cart->cart_items[0]->product_catalog_yousave_total_amt_incl_tax_woo, 'product_catalog_yousave_total_amt_excl_tax_woo' => $vtprd_cart->cart_items[0]->product_catalog_yousave_total_amt_excl_tax_woo, 'product_orig_price_html_woo' => $product_orig_price_html_woo, 'product_is_on_special' => $vtprd_cart->cart_items[0]->product_is_on_special, 'product_yousave_total_amt' => $vtprd_cart->cart_items[0]->yousave_total_amt, 'product_yousave_total_pct' => $vtprd_cart->cart_items[0]->yousave_total_pct, 'product_rule_short_msg_array' => $short_msg_array, 'product_rule_full_msg_array' => $full_msg_array, 'product_has_variations' => $product_variations_sw, 'session_timestamp_in_seconds' => time(), 'user_role' => vtprd_get_current_user_role(), 'product_in_rule_allowing_display' => $vtprd_cart->cart_items[0]->product_in_rule_allowing_display, 'show_yousave_one_some_msg' => $show_yousave_one_some_msg, 'this_is_a_parent_product_with_variations' => $vtprd_cart->cart_items[0]->this_is_a_parent_product_with_variations, 'pricing_by_rule_array' => $vtprd_cart->cart_items[0]->pricing_by_rule_array, 'product_id' => $product_id); //v1.0.9.0 end /* error_log( print_r( 'product_session_info= ' , true ) ); error_log( var_export($vtprd_info['product_session_info'], true ) ); error_log( print_r( '$vtprd_cart->cart_items[0]= ' , true ) ); error_log( var_export($vtprd_cart->cart_items[0], true ) ); */ if (!isset($_SESSION)) { session_start(); header("Cache-Control: no-cache"); header("Pragma: no-cache"); } //store session id 'vtprd_product_session_info_[$product_id]' $_SESSION['vtprd_product_session_info_' . $product_id] = $vtprd_info['product_session_info']; //initialize vtprd_cart to clear all discount values... //v1.0.7.8 $vtprd_cart = new vtprd_Cart(); //v1.0.7.8 }