Answer the question
In order to leave comments, you need to log in
How to implement a different product price tag for different cities in WooCommerce?
There is a site with woocommerce. The site has a select with a choice of cities. Depending on the choice of city, you need to display different prices for the same product.
At the moment, it is implemented using the city record in localStorage + custom fields in woocommerce, displaying the desired price via jquery.
On the page with product cards "how to buy" everything is buzzing, but when adding an item to the cart, the price (of course) is taken from the "base price" field. How to be?
I would be very grateful for any help! Thanks in advance!
Answer the question
In order to leave comments, you need to log in
The price in woocommerce goes through a filter. Write the selected city to the session or cookie and write your own filter that checks the cookie/session and pulls out the desired price.
public function get_price() {
return apply_filters( 'woocommerce_get_price', $this->price, $this );
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question