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".
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
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?
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.
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.
Thank you and I'll follow up on the other tickets, shortly.