Home Forums Plugin Support WP User Frontend Pro changing status and price of a woocommerce product after submitting

This topic is: not resolved

This topic contains 1 reply, has 2 voices, and was last updated by  towhid 4 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #36604

    Maur1350
    Member

    Hello,

    I don't have a lot of experience in wordpress/php
    So I'd like ask to you for solve this question

    Registered users can submit products by WPUF in woocommerce.
    I want that the status of product is set to ‘publish' and its price to 0, if
    users select the meta value ‘Free” for the meta key ‘project_type'.

    I've tried adding this code in functions.php

    /function to update product status to ‘publish'
    // and set the price to 0 for ‘free' products
    function change_post_status($post_id){

    $project_type = get_post_meta($post->ID, ‘project_type', true);

    if ($project_type == ‘Free')
    {

    update_post_meta( $post_id, ‘_regular_price', 0);
    $current_post = get_post( $post_id, ‘ARRAY_A' );
    $current_post[‘post_status'] = ‘publish';
    wp_update_post($current_post);
    }
    }

    add_action(‘wpuf_add_post_after_insert', ‘change_post_status');

    but nothing happens.
    have I forgotten to declare same variable?
    Can you suggest me the correct way to code it?
    Thank you

    #36993

    towhid
    Participant
    Post count: 4505

    Hello Maur1350,

    I am really sorry to say we do not provide any customization services. If you need this urgent you can make it yourself or you can hire a developer.

    Thank You ๐Ÿ™‚

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

The topic ‘changing status and price of a woocommerce product after submitting’ is closed to new replies.