• Resolved maddoctor

    (@maddoctor)


    Hello!
    I’m using a MySQL connector to get woocommerce data for my application and I’m trying to edit my prices from my application instead of from inside woocommerce. Most of the products I want to change prices of are variable products.

    I query the table postmeta for the meta_key: “_price” using the product id and get the meta_value, which contains the current price of the variable product. I verify that the price data is correct by checking the website prices and the values reported in my application. I make changes to the woocommerce product, save the product, and when I refresh my application form it updates the price data.

    My problem is when I try to do the opposite, I change the price in the application, and expect to see the changes when I refresh the product, but no there is no change. Since the form does use the new values, I assume woocommerce is using some sort of cache for the product prices and is not reading from the postmeta directly.

    How can I force woocommerce to accept my new prices from my application? I need the correct table that holds the live price data, or a way to force that table to get the data from postmeta. I understand this might be complicated support issue but maybe someone from woocommerce team can help as I’m really close.

    PS: The application is using microsoft access as a front end

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @maddoctor

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Have you tried changing the price in the postmeta table directly with PHPMyAdmin to check if WooCommerce is reading the correct value? That will tell you if you are targeting the correct field

    Thread Starter maddoctor

    (@maddoctor)

    You are right. I changed the value of the meta field “_price” in PHPMyAdmin and nothing changed in wordpress, but if I change the product value in wordpress, it changes the value in PHPMyAdmin. I found two more price fields, “min_price” and “max_price” in the table wc_product_meta_lookup but no luck with those either.

    @margaretwporg Thank you for the links, I’m doing some further search on the subject now.

    Just did a quick test – added a product and gave it a distinctive price: 12345.67!

    Found 2 instances in post_meta:

    _price
    _regular_price

    If I change _price in PHPMyAdmin it doesn’t change in the product.
    But if I change _regular_price it does!

    But if I change it in the WooCommerce admin it changes them both again.

    Thread Starter maddoctor

    (@maddoctor)

    Thank you! That was it, _regular_price is the one I needed.
    Woocommerce has 3 keys for price, “_price”, “_regular_price” and “_sale_price”, they are given in the variation/product settings. The regular price is the price the product is set to sell at, sale price is the price when there is a scheduled sale. Changing “_regular_price” from PHPMyAdmin sets the regular price as expected. I assume the “_price” meta key is for the display price and it picks one of the two other ones, based on whether it’s a sale or not.
    Now it all works, and if I want to change the sale price from my frontend I can do that too.

    Plugin Support nathvi V. a11n

    (@nathvi)

    Hi @maddoctor

    Glad to know the recommendations posted previously worked for you!

    Thanks @seank123 for your input here!

    I will close this thread as resolved for now.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘changing prices outside of the website’ is closed to new replies.