zambetti
Forum Replies Created
-
Forum: Plugins
In reply to: [Price Based on Country for WooCommerce] Prices Not Showing In ShopI removed my alteration to put WCPBC back to it’s original state, and set a default price for my products (putting a number in the woocommerce price field), and it just simply showed the default price as if WCPBC was not installed. I’ve just put my fix in again and my site is working fine.
I’ve been looking through the WCPBC code for a couple hours now, and can’t understand where geolocation is being done. (nb. I am not using AJAX)
Here’s an updated version of my patch. The version I posted above doesn’t respect the wc_price_based_country_based_on option (I’m not using that option though, but noticed a flaw in my patch posted a few minutes ago)
function wcpbc_get_woocommerce_country()
{
$result = false;
if (wcpbc_is_woocommerce_frontend())
{
$billingDetails = wc()->customer->get_billing();
$shippingDetails = wc()->customer->get_shipping();
if (
array_key_exists(‘city’, $shippingDetails) && array_key_exists(‘country’, $shippingDetails) &&
(0 == strcasecmp(‘shipping’, get_option(‘wc_price_based_country_based_on’, ‘billing’)))
) {
$result = $shippingDetails[‘country’];
}
else if (array_key_exists(‘city’, $billingDetails) && array_key_exists(‘country’, $billingDetails)) {
$result = $billingDetails[‘country’];
}
else {
$geolocation = new WC_Geolocation();
$geolocationResult = $geolocation->geolocate_ip($geolocation->get_ip_address());
if (array_key_exists(‘country’, $geolocationResult)) {
$result = $geolocationResult[‘country’];
}
}
}
return $result;
}Forum: Plugins
In reply to: [Price Based on Country for WooCommerce] Prices Not Showing In ShopHi Oscar. I am not using any add-ons. I did just make a change to wcpbc-core-functions.php and now it seems to be working fine again (see below). I just saw your comment, and I will now try to remove my change and set a default price to see if that was causing this.
/*
function wcpbc_get_woocommerce_country() {$country = false;
if ( wcpbc_is_woocommerce_frontend() ) {
$country = wcpbc_get_prop_value( wc()->customer, ‘billing_country’ );
$shipping_county = wc()->customer->get_shipping_country();
if ( $country !== $shipping_county && ‘shipping’ === get_option( ‘wc_price_based_country_based_on’, ‘billing’ ) ) {
$country = $shipping_county;
}
}return $country;
}
*/function wcpbc_get_woocommerce_country()
{
$result = false;
if (wcpbc_is_woocommerce_frontend())
{
$billingDetails = wc()->customer->get_billing();
$shippingDetails = wc()->customer->get_shipping();
if (array_key_exists(‘city’, $billingDetails) && array_key_exists(‘country’, $billingDetails)) {
$result = $billingDetails[‘country’];
}
else if (array_key_exists(‘city’, $shippingDetails) && array_key_exists(‘country’, $shippingDetails)) {
if (0 == strcasecmp(‘shipping’, get_option(‘wc_price_based_country_based_on’, ‘billing’))) {
$result = $shippingDetails[‘country’];
}
}
else {
$geolocation = new WC_Geolocation();
$geolocationResult = $geolocation->geolocate_ip($geolocation->get_ip_address());
if (array_key_exists(‘country’, $geolocationResult)) {
$result = $geolocationResult[‘country’];
}
}
}
return $result;
}Forum: Plugins
In reply to: [Price Based on Country for WooCommerce] Prices Not Showing In Shopanother typo
wcpbc-core-functions.php…
$shipping_county = wc()->customer->get_shipping_country();“county” should be “country”
Forum: Plugins
In reply to: [Price Based on Country for WooCommerce] Prices Not Showing In Shop“leave the theme activated” > ” leave the plugin activated”
Forum: Plugins
In reply to: [Price Based on Country for WooCommerce] Prices Not Showing In ShopIn fact, when I just set regular prices and leave the theme activated, it just uses my regular prices (not the wcpbc variation prices), it seems the plugin does not work at all anymore
Forum: Plugins
In reply to: [Price Based on Country for WooCommerce] Prices Not Showing In ShopWhen I deactivate the plugin and use regular prices in woocommerce, the site works fine, so I conclude it is not a problem with my theme.
Forum: Plugins
In reply to: [Price Based on Country for WooCommerce] Prices Not Showing In ShopDigging more, I found this strange behavior when trying to find out why my “current_zone” is “US”…
function wcpbc_get_zone_by_country( $country = ” ) {
if ( ! class_exists( ‘WCPBC_Pricing_Zones’ ) ) {
return false;
}
// here $country is empty string “”
$country = empty( $country ) ? wcpbc_get_woocommerce_country() : $country;
// here $country is “US” but US is not one of my zones
return WCPBC_Pricing_Zones::get_zone_by_country( $country );
}Forum: Plugins
In reply to: [Price Based on Country for WooCommerce] Prices Not Showing In ShopI see that get_regions() now just returns array(), so it is not helpful for debugging anymore.
I also noticed a typo in wcpbc-core-functions.php … “wcpbc_princing_input” should be “wcpbc_pricing_input”