Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi kosmikkreeper,

    Can you explain how you resolved this?

    Thread Starter dezio1900

    (@dezio1900)

    I understand. I will try alternative methods. Thanks for your support.

    Thread Starter dezio1900

    (@dezio1900)

    Auto optimize doesn’t set the order of the files as I want it, and as a result it produce errors. So auto optimize is not an option in my case.

    I cannot understand why this is not yet fixed if this is a “known issue”. It makes minify useless in my case, and its a shame, because this plugin is labeled as one of the top cache plugin.

    Thread Starter dezio1900

    (@dezio1900)

    In the dev/ folder its combined(shows error in console), and on a live site I disabled CSS minify for now, because of that bug.

    Thread Starter dezio1900

    (@dezio1900)

    I placed there a full URL:
    http://goldenhikes.ca/dev/wp-content/themes/goldenhikes/style.css

    but when I click save, its automatically changed again to relative URL:
    dev/wp-content/themes/goldenhikes/style.css

    So it appears that there is no other way but to change relative URLs in CSS file directly, and thats not an option for me unfortunately, because there are plugins using relative URLs in their CSS etc.

    This is making Minify useless and I don’t know why its not fixed if its a known issue :S

    dezio1900

    (@dezio1900)

    oscargare, check this code I used. Basically you need this part to add to the code:

    if( ! WC()->session->has_session() ){
    					WC()->session->set_customer_session_cookie(true);
    add_action( 'plugins_loaded', function(){
    
    		if( class_exists('WCPBC_Frontend') ){
    
    			add_action( 'woocommerce_init', function(){
    
    				// CREATE SESSION IF ITS NOT ALREADY THERE. WE NEED IT IN ORDER TO SAVE COUNTRY SELECTION
    				if( ! WC()->session->has_session() ){
    					WC()->session->set_customer_session_cookie(true);
    				}
    
    				// SET NEW VALUE FOR THE COUNTRY IF $_POST['bi-country'] IS THERE (USER MANUALLY SUBMITTED THE FORM WITH A NEW COUNTRY)
    				if( ! empty( $GLOBALS['wcpbc_frontend'] ) && ! empty( $_POST['bi-country'] ) ){
    
    					// IF USER SELECTED THE "INTERNATIONAL" COUNTRY...
    					if( $_POST['bi-country'] == 'INT' ){
    
    						// SET THE COUNTRY BY USER IP
    						//$_POST['bi-country'] = $GLOBALS['wcpbc_frontend']->default_customer_country(null);
    
    						// OR SET THE COUNTRY BY FIRST AVAILABLE IN ALLOWED COUNTRIES LIST
    						foreach( WC()->countries->get_allowed_countries() as $key => $value ){
    
    							if( $key != 'CA' && $key != 'US' ){
    
    								$_POST['bi-country'] = $key;
    								break;
    
    							}
    
    						}
    
    					}
    
    					// ENSURE THAT CART MUST BE EMPTY ON SWITCHING THE COUNTRIES
    					WC()->cart->empty_cart();
    
    					// ITS A SHAME WE CANT ACCESS THE CUSTOMER OBJECT DIRECTLY, LIKE THIS: $this->customer->set_country( $_POST['bi-country'] );
    					// SO BECAUSE WCPBC PLUGIN ONLY ACCEPTS $_POST['country'] AS COUNTRY, GIVE IT TO HIM.
    					$_POST['country'] = $_POST['bi-country'];
    					$GLOBALS['wcpbc_frontend']->checkout_country_update(null);
    					unset( $_POST['country'] );
    
    					// WHEN WE ARE CHANGING THE COUNTRY IN WCPBC PLUGIN, WE MUST DO THE SAME IN WOOCOMMERCE
    					WC()->customer->set_country( $_POST['bi-country'] );
    					WC()->customer->set_shipping_country( $_POST['bi-country'] );
    
    					// ADD COOKIE TO REMEMBER THE VISITOR's CHOICE FROM THE LANDING PAGE COUNTRY SELECTOR POPUP
    					if( ! isset( $_COOKIE['bi-initial-country'] ) ){
    						setcookie( 'bi-initial-country', $_POST['bi-country'], (time()+60*60*24*365*5), '/' );
    						$_COOKIE['bi-initial-country'] = $_POST['bi-country'];
    					}
    
    				}
    
    			}, 200);
    
    			// ADD SCRIPT AND STYLE TO PAGE OUTPUT
    			add_action( 'wp_enqueue_scripts', function(){
    
    			    $plugin_url = plugins_url( '', __FILE__ );
    
    			    wp_enqueue_style( 'bi-prices-by-country-style-fancybox', "$plugin_url/fancybox/jquery.fancybox.css" );
    			    wp_enqueue_style( 'bi-prices-by-country-style', "$plugin_url/style.css" );
    
    			    wp_enqueue_script( 'bi-prices-by-country-script-fancybox', "$plugin_url/fancybox/jquery.fancybox.js", array( 'jquery' ), false, true );
    			    wp_enqueue_script( 'bi-prices-by-country-script', "$plugin_url/script.js", array( 'jquery' ), false, true );
    
    			});
    
    			// ADD HTML ELEMENTS TO PAGE OUTPUT
    			add_action( 'wp_footer', function(){ require_once 'html-output.php'; });
    
    			//
    			add_action( 'woocommerce_before_checkout_billing_form', 'bi_woocommerce_before_checkout_billing_form');
    			add_action( 'woocommerce_after_checkout_billing_form', 'bi_woocommerce_before_checkout_billing_form');
    			function bi_woocommerce_before_checkout_billing_form(){
    
    				static $allowed_countries;
    				static $current_country;
    				static $already_called = false;
    
    				if( is_null( $allowed_countries ) )
    					$allowed_countries = WC()->countries->get_allowed_countries();
    
    				if( is_null( $current_country ) )
    					$current_country = WC()->customer->get_country();
    
    				if( ! $already_called ){
    
    					$already_called = true;
    
    					if( $current_country != 'CA' && $current_country != 'US' )
    						unset( WC()->countries->countries['CA'], WC()->countries->countries['US'] );
    					else
    						WC()->countries->countries = array( $current_country => WC()->countries->countries[$current_country] );
    
    				}
    				else
    					WC()->countries->countries = $allowed_countries;
    
    			}
    
    		}
    
    	}, 11);

    dezio1900

    (@dezio1900)

    Thanks, good job oscargare!

    Only thing, you should change protected $customer to public $customer in order to allow advanced customization.

    Hi,

    Firstly, great plugin oscargare. I developed a country selector which you can find here: https://strikt.ca

    What I am missing, is that customer object should be set as PUBLIC. I want to alter it but there is no way because you set it to protected. Please include that in next version. WC also included customer object as public. I want to be able to do something like this:
    $GLOBALS['wcpbc_frontend']->customer->set_country('NEW_COUNTRY');

    I see the same problem in my site.

Viewing 9 replies - 1 through 9 (of 9 total)