Answer the question
In order to leave comments, you need to log in
How to automatically update each product card?
When editing a product, there are 3 prices:
• In rubles _regular_price
• In dollars using custom fields
• In euros using custom fields
In dollars and euros, this is an additional price. Everything works like this:
1 dollar = 30r
1 euro = 50r
The course is snatched from https://www.cbr-xml-daily.ru/daily_json.js
We write the price of 1000 rubles for the product, update it, 1000r is displayed in the card.
If we now write the product in dollars, for example, 200, and update it, then the price will change to 600 and 600 will be displayed in the card. That is, the main price in rubles is updated. It is updated by querying the database.
global $wpdb;
$resuld = $wpdb->get_results("UPDATE wp_postmeta SET meta_value = $priceuroupdate2 WHERE post_id = $post_id AND meta_key = '_regular_price' ; ");
$resuld2 = $wpdb->get_results("UPDATE wp_postmeta SET meta_value = $priceuroupdate2 WHERE post_id = $post_id AND meta_key = '_price' ; ");
Answer the question
In order to leave comments, you need to log in
in the form in which you asked the question, you need to enter at least one more field in the database to
indicate which of the prices is the base
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question