I’m going to go with Plan B, as above. The reason being that I don’t want the price being potentially manipulated by using JS in the browser. Also, I have no idea how to set the price with JS from the browser!
The plan is have a cron job periodically run a script which loops through products and update_post_meta()
on each. Something like:
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => -1
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
global $product;
$value = 840;
update_post_meta($product->get_id(), '_regular_price', (float)$value);
update_post_meta($product->get_id(), '_price', (float)$value);
endwhile;
}
wp_reset_query();
The only question marks which remain are that of performance, but I’m all out of ideas. If anyone can see anything I may have missed, please do chime in!
Related Posts:
- WooCommerce – buying as well as selling
- wc_get_template_part( ‘content’, ‘product’ ) | Where is this file located?
- how to get woocommerce product attribute slug
- How to build a plugin that supports authenticated POST requests to the REST API from external servers?
- Create WooCommerce custom stock option that is non-purchasable
- How do I add a text input field for customers to leave a note on a single WooCommerce product page?
- Where can I find a single item template
- Get Woocommerce Subscription Product
- Change “Shipping” text to “Delivery” everywhere I appears in woocommerce
- Customize WooCommerce orders displayed shipping
- WooCommerce pages accessible to logged in members only
- paypal not showing on woocommerce payments
- Target WooCommerce Product Gallery Image (rather than Featured Image) for og:image
- Save and display selected product option and cost as cart item data in WooCommerce
- How to update the WooCommerce cart Icon to show new products added with JavaScript
- How to remove product base from WooCommerce product permalinks
- Remove the link from the thumbnail and product title on woocommerce
- How to configure Woocommerce Payment Methods programmatically?
- woocommerce_package_rates not fired everytime
- how to change woocommerce shop archive description? [closed]
- How to display the result of a custom metabox in the frontend [closed]
- Quantity on the product card and subtotal disappear [closed]
- Admin access for custom user capabilities
- Display product category taxonomy terms in WooCommerce shop loop
- Products Shortcode is Displaying Single Product Page Price for all Products [closed]
- Subscription on Checkout
- Woocommerce – display product in page but in list format with excerpt
- how to show store name when I add a product on cart in woocommerce(woocommerce multi store)?
- When Free shipping is available hide other shipping methods except Local pickup in WooCommerce [closed]
- Woocommerce Moving Review Below add to cart breaks button
- Create archive page for woocommerce attribute
- Refund from wooCommerce with stripe [closed]
- WooCommerce Hook: Content get’s displayed twice and not AFTER the order total
- How to increase execution time out limit in WordPress dashboard?
- Setting an attribute as variation in woo commerce via php [duplicate]
- WooCommerce – Conditionally enable shipping for virtual products
- get_the_post_thumbnail_url does not return anything if image size is set
- Add to Cart button displaying twice on Shop Page Woocommerce
- How to exclude a taxonomy from shop & search page wooCommerce?
- How to remove unwanted text bug in wordpress site
- get woocommerce product image url and price from database [closed]
- Trying to style Woocommerce sidebar Cart Widget [closed]
- Cancelled orders move to Trash automatically in Woocommerce – how to disable?
- How can I compel alphanumeric entries for username textbox on woocommerce registration form
- Help me to intergrate product database to WordPress
- WooCommerce how to checkout a product without adding it to the cart
- How can i access woocommerce order variables inside shortcode?
- Conditional logic – if product has a parent category, echo this
- WooCommerce set default product sort to product description (content) [closed]
- How to add a “buy now” button below “add to cart” button [closed]
- Cart page displays the price and amount as zero regardless of price entered [closed]
- Custom action not working in Woocommerce
- Display list of only specific tags on product
- Change the “Register” headline in Woocommerce
- How to display customer mobile number in woocommerce customers page
- How to alter taxes amounts when updating an order
- Woocommerce variable product’s total amount by javascript
- Prices showed without decimals separator on BACKEND. Weight/price not working on Wocommerce
- add the attribute value above the english product title
- Get all categories inside a Product Tag archive page
- Save product short description in order (without updating in order details if it is updated in product)
- Can I create categories or attribute contain more than 70,000?
- Combine one action and one filter
- How to run code when cookie is added?
- Return product list based on current product attribute
- woocommerce add button underneath order details
- Where do I remove admin order fields (unset doesn’t work)
- How to Get WooCommerce Product Price
- How to trace errors in debug.log for WooCommerce 3.0?
- Auto set Woocommerce product ID as SKU on save
- I want to show always 4 category boxes everytime in woocommerce
- Change the customer’s name to a link on an order management page
- Applying pre-production modifications
- WooCommerce – Remove automaticly added membership product if user remove regular product from cart
- Possible to have multiple Authorize.net accounts on the same site?
- Allow HTML in product attributes for WooCommerce
- Use woocomerce shop filters on other pages
- Product related to post by title
- Woocommerce – change image issue
- Woocommerce: relevancy based related products
- How to change the link of product menu from wordpress admin panel
- Same WooComerce shop for different WP sites?
- Custom Shipping Method: need non-instance settings and non-global settings
- how to query single product in woocommerce? [closed]
- woocommerce-how can i get all products by their groups! [closed]
- Anchor link to every product
- Plugin could not be activated because it triggered a fatal error
- Woocommerce custom product with JS script, can’t understand how it works [closed]
- Rename woocommerce button [closed]
- Woocommerce 404 after chang default language
- When creating a new order (on the dashboard) how can I get the ID of the selected customer
- Setup WooCommerce to properly handle inventory with variable product?
- Link Back to Parent Category – Woocommerce
- Create templates from attributes for categories
- How do I get slug of term by his name?
- Send data to external websites when there is an update or create a post
- Disable duplicate WC product category URLs
- how should i get products based on tags in woocommerce
- Add custom text to product category page
- Woocommerce permalink URL change in DB