update the product fields
-
hi
when im adding a new product and there is an error the fields not being saved and i have to write all over again.im trying to make a function that will update the product fields when the page is being refreshed and there is an error… where i got wrong ?
this is a basick need that you didnt pay attention to it.
/**
* Update the custom field when the form submits
*
* @param type $post_id
*/
function update_fields( $post_id ) {
if ( isset( $_POST[‘_regular_price’] ) ) {
update_post_meta( $post_id, ‘_regular_price’, $_POST[‘_regular_price’] );
}
if ( isset( $_POST[‘_sale_price’] ) ) {
update_post_meta( $post_id, ‘_sale_price’, $_POST[‘_sale_price’] );
}
if ( isset( $_POST[‘product_cat[]’] ) ) {
update_post_meta( $post_id, ‘product_cat[]’, $_POST[‘product_cat[]’] );
}
if ( isset( $_POST[‘product_tag[]’] ) ) {
update_post_meta( $post_id, ‘product_tag[]’, $_POST[‘product_tag[]’] );
}
if ( isset( $_POST[‘post_content’] ) ) {
update_post_meta( $post_id, ‘post_content’, $_POST[‘post_content’] );
}
}add_action( ‘dokan_product_updated’, ‘update_fields’, 10, 1 );
- The topic ‘update the product fields’ is closed to new replies.