Skip Navigation

[Resolved] Quantity says the same no matter what

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 1.81 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#1909355

Hi Waqar,

You helped me combine the 2 forms that we use to create a camp into 1 form which is amazing. Problem is, that the quantity shows the number 23 no matter what i type in. When i want to change the quantity number via the frontend "Edit camp" or in danish "Rediger camp" it still does not affect the number 23.

Quantity is called "Antal ledige pladser".

#1910173

Hi Mai,

I've checked the form "Host - edit your product" and the "Product In Stock Status" is not the right field for the stock quantity.

Please remove this field and instead add a numeric generic field "pladser", similar to the one you've added in the form "Create camp".

Once this field has been added, you'll need to attach another custom function to update this "pladser" field's value in the product's "_stock" field:


add_action('cred_save_data', 'edit_product_post_action',10,2);
function edit_product_post_action($post_id, $form_data)
{
    // if a specific form
    if ($form_data['id']==1005)
    {
        // update the stock field from pladser field value
        update_post_meta( $post_id, '_stock', $_POST['pladser'] );
    }
}

Note: You can include the above code in the active theme's "functions.php" file.

regards,
Waqar

#1912939

Hi Waqar,

It seems to work! Thank you! Just to make sure - does the quantity change when you buy the camp? So if there are 10 available spots on the camp, and i buy one - does the quantity then change to 9 on the template as we talked about earlier?

#1914079

Thanks for the update and glad that it works.

Yes, the quantity/stock should change with the orders, because we are not saving this value with the Camp posts, it is being saved in the "_stock" custom field in the related Product post, which is managed by WooCommerce.

#1915659

Okay cool - i will mark this as resolved then.

I still have trouble with the emails data - i will just write a comment on that ticket so it won't close.

#1917111

Thank you and I'll follow up on the other tickets, shortly.