0

I tried to edit a plugin product price based on country woocommerce-product-price-based-on-countries/includes/class-wcpbc-frontend-pricing.php

I added the below code,in line 36

 add_filter( 'woocommerce_get_price_html', 'country_geolocated_based_hide_price', 10, 2 );
function country_geolocated_based_hide_price( $price, $product ) {
// Get an instance of the WC_Geolocation object class
$geo_instance  = new WC_Geolocation();
// Get geolocated user geo data.
$user_geodata = $geo_instance->geolocate_ip();
// Get current user GeoIP Country
$country = $user_geodata['country'];

return $country == 'GB' ? '' : $price;

In place GB i used a specific country name.

Because i want to hide prices to that country and display prices to other countries

but it throwed me this error,

Parse error: syntax error, unexpected ‘public’ (T_PUBLIC) in /home/hhclothi/camillerimarine.com/wp-content/plugins/woocommerce-product-price-based-on-countries/includes/class-wcpbc-frontend-pricing.php on line 68

can somebody help me to sort this out. Thank you

marine
  • 1
  • **NEVER edit core files!** When WC gets updated, it overwrites the installation with any new updates included in the release. If the core has been chopped up and modified beforehand, it’ll wipe out those changes. That means big sections of the installation will just stop working. Modifying the core can have all kinds of unintended consequences, like preventing updates from working correctly, further screwing up an installation. Even worse is the potential to introduce unintended security vulnerabilities. Messing with core files could easily introduce a hole allowing hackers to take over a site – 7uc1f3r Nov 18 '21 at 10:21
  • Exactly what Lucifer said - except... *NEVER EDIT PLUGIN FILES* When you update them, you will loose the changes... – Stender Nov 18 '21 at 10:26

0 Answers0