Home Forums Plugin Support WP User Frontend (Free Version) Edit not updating custom fields

This topic is: resolved

Tagged: 

This topic contains 14 replies, has 4 voices, and was last updated by  bigtom 4 years, 9 months ago.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #9475

    pasturesmoo
    Participant
    Post count: 9

    Hey,

    I've got wpuf creating products in woocommerce and it works a treat! The only thing is when creating or editing a product post I need to go to the product in the wordpress admin and publish it to get the pricing data to show up.

    The data is getting passed correctly as the woocommerce Regular Price (_regular_price) and Sale Price (_sale_price) fields are populated by the wpuf form. Any idea what I might explore for a fix?

    Thanks in advance for any help provided and awesome plugin ๐Ÿ™‚

    #9478

    Tareq Hasan
    Keymaster
    Post count: 2831

    The right meta key should be _price. _regular_price and _sale_price is only used when you are giving a discount on a product.

    #9480

    pasturesmoo
    Participant
    Post count: 9

    There isn't a price field anymore in the woocommerce backend product view. Only Regular Price and Sale Price. The form does work it just doesn't register the prices until opened and saved in the wp admin.

    #9483

    Tareq Hasan
    Keymaster
    Post count: 2831

    I know the label in the product page is Regular Price and Sale price, but still when using the single price, it uses the _price meta key. Can you try using that?

    #9485

    pasturesmoo
    Participant
    Post count: 9

    Yeah I've tried _price on its own but nothing gets passed to the woocommerce product. The only ones that do pass into the product are _regular_price and _sale_price.

    _regular_price and _sale_price only appear in the live published product if I manually go in an open it then publish it from wp-admin. The values are there ready but not shown in the table view of the products until I've republished them if that's any help with figuring it out. If they didn't need the manual publishing I'd be golden! It's more of an issue with editing products really as we review them when they're created anyway, but I guess it's the same issue.

    Thanks

    #9562

    pasturesmoo
    Participant
    Post count: 9

    When creating a new product directly in the admin here's the pricing options I can set.

    Woocommerce Product Defaults

    Is it possible to set both the Regular Price & Price at the same time? Would that let the prices be added automatically when the post is created and updated automatically when it's edited?

    Regards
    Paul

    #9563

    pasturesmoo
    Participant
    Post count: 9
    #9564

    Tareq Hasan
    Keymaster
    Post count: 2831

    Paste this code snippet to your themes functions.php, use _price in your form and this code will also copy that price to _regular_price field.

    [php]
    function wpufe_update_post_price( $post_id ) {
    $price = get_post_meta( $post_id, ‘_price', true );

    update_post_meta( $post_id, ‘_regular_price', $price );
    }

    add_action( ‘wpuf_add_post_after_insert', ‘wpufe_update_post_price' );
    add_action( ‘wpuf_edit_post_after_update', ‘wpufe_update_post_price' );
    [/php]

    BTW, are you using any plugin for setting prices in specific country?

    #9567

    pasturesmoo
    Participant
    Post count: 9

    Thanks I'll try that.

    Yes I am using WooCommerce Currency Switcher, by Aelia.

    #9576

    pasturesmoo
    Participant
    Post count: 9

    The code snippet did add the price and regular price but I still had to go into the wp-admin and re-publish the changes for them to take effect. To confirm in the form I do have the edit settings configured to ‘Set Post Status to: Published'.

    Anything else I might be able to try?

    Thanks for your time on this.

    #9578

    pasturesmoo
    Participant
    Post count: 9

    Actually, it's doing something weird now. The custom field in the wp-admin product view for price (which uses _price) is being populated with the _sale_price after I've re-published it.

    #9585

    Tareq Hasan
    Keymaster
    Post count: 2831

    If you want to use _sale_price, change codes _regular_price to this. And also add a hidden field with meta key _visibility and set the value to visible.

    #14306

    TheBigFish
    Member
    Post count: 1

    Hi Guys, I was wondering if you have figured this issue out or have any updates on it at all.

    I was dealing with the exact the same issue as pasturesmoo above with other form frontend editor.

    What happens is this :

    I create 2 fields in my form. 1 field is for the regular price and I give it a meta _regular_price and the second filed is for Sale Price with the meta _sale_price

    I am creating regular price and sale price because I am willing to display the sale / discount on my product.

    What happens after I submit the form is that both values will get correctly input in the edit post / product in admin, so I can see both values there taken from the form, however when I go to preview the product page, these values just do not display in the output.

    Only after I update the edit post / product page from the admin ( without doing any changes at all ) both values will now display on the output.

    The other frontend form editor was partly solving the issue for me by doing the following :

    I would create another HIDDEN field and give it a meta _price.

    I would then hook this field to calculate the default values from the Regular Price input.

    And voila, I would achieve my regular price now being displayed on the product detail page automatically, straight after submitting the form.

    That means that if I create another hidden field, give it another _price meta and set it to calculate the default values from the Sale Price output, I would achieve both Regular and Sale Price to automatically display on the product preview page.

    The bad thing here is that the other form editor doesn't allow me to have 2 _price metakeys.

    I'm quite interested in WPUF, but this feature is essential for the frontend product posting.

    Any Ideas ?? Does WPUF work this way ?

    #20379

    bigtom
    Member
    Post count: 74

    I am had this same issue and the supplied code works fine.

    #20416

    bigtom
    Member
    Post count: 74

    I take it back. with the supplied code the regular price works, but the sale price will not show unless I go to the product in admin and update without making any changes.

Viewing 15 posts - 1 through 15 (of 15 total)

The topic ‘Edit not updating custom fields’ is closed to new replies.