Wer schon einmal nach dem Schlüsselwort price in einem Datenbankdump von Woocommerce und WordPress gesucht hat, weil er seine Artikelpreise gerne auf einen Schlag ändern möchte, der wird einfach nur verzweifeln.
Es gibt allein in wp_post_meta 12 Möglichkeiten, Preise einzugeben. Und das ist noch nicht einmal alles.
Annahme: Wir wollen unsere Preise einer Inflation von 2 Prozent anpassen. Wie geht man vor?
Tabelle wp_postmeta
UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_regular_price' AND meta_value != '' UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_sale_price' AND meta_value != '' UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_price' AND meta_value != '' UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_regular_price_tmp' AND meta_value != '' UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_sale_price_tmp' AND meta_value != '' UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_price_tmp' AND meta_value != '' UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_min_variation_price' AND meta_value != '' UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_max_variation_price' AND meta_value != '' UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_min_variation_regular_price' AND meta_value != '' UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_max_variation_regular_price' AND meta_value != '' UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_min_variation_sale_price' AND meta_value != '' UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_max_variation_sale_price' AND meta_value != ''
Tabelle wp_options
DELETE FROM wp_options WHERE (option_name LIKE '_transient_wc_var_prices_%' OR option_name LIKE '_transient_timeout_wc_var_prices_%')
Die letzte Zeile ist besonders wichtig, da Woocommerce einen Transient-Cache nutzt, um Seiten schneller darstellen zu können. Indem man diesen Speicher auf einen Schlag löscht, wird er automatisch beim nächsten Aufruf eines Produktes neu generiert.