wcpbc_set_woocommerce_country

Set WooCommerce customer country.

Description

wcpbc_set_woocommerce_country( (number) $country ); 

Parameters (1)

0. $country (number)
The country.

Usage

  1. if ( !function_exists( 'wcpbc_set_woocommerce_country' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-product-price-based-on-countries/includes/wcpbc-functions.php'; 
  3.  
  4. // The country. 
  5. $country = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wcpbc_set_woocommerce_country($country); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wcpbc-functions.php  
  1. function wcpbc_set_woocommerce_country( $country ) { 
  2.  
  3. $ship_to_different_address = get_option( 'woocommerce_ship_to_destination' ) === 'shipping' ? 1 : 0; 
  4.  
  5. if (  
  6. WC()->customer->get_country() !== WC()->customer->get_shipping_country() &&  
  7. 'shipping' === get_option('wc_price_based_country_based_on', 'shipping') &&  
  8. '1' == apply_filters( 'woocommerce_ship_to_different_address_checked', $ship_to_different_address )  
  9. )  
  10. WC()->customer->set_shipping_country( $country ); 
  11. } else { 
  12. WC()->customer->set_country( $country ); 
  13. WC()->customer->set_shipping_country( $country ); 
  14.