MultivendorX Pro
-
AuthorPosts
-
-
July 23, 2024 at 11:04 AM #221853PicflickParticipant
Hi,
You previously provided the following piece of code to assist with validating Required fields when a Vendor Adds a New Product:add_action( 'wcmp_before_post_update', 'required_wcmp_product_field' ); function required_wcmp_product_field(){ $required_regular_price = isset( $_POST['_regular_price'] ) ? $_POST['_regular_price'] : ''; $required_feature_image = isset( $_POST['featured_img'] ) ? $_POST['featured_img'] : ''; $required_post_title = isset( $_POST['post_title'] ) ? $_POST['post_title'] : ''; $required_product_excerpt = isset($_POST['product_excerpt']) ? trim($_POST['product_excerpt']) : ''; if (!$required_regular_price || !$required_feature_image || !$required_post_title || !$required_product_excerpt) { wc_add_notice( __('Please ensure you have added a Product Title, Image, Short Description, and Price', 'dc-woocommerce-multi-vendor'), 'error' ); //redirect to main page wp_redirect( apply_filters( 'wcmp_vendor_save_product_redirect_url', wcmp_get_vendor_dashboard_endpoint_url( get_wcmp_vendor_settings( 'wcmp_edit_product_endpoint', 'vendor', 'general', 'edit-product' ), $_POST['post_ID'] ) ) ); exit; } }
CopyBut now suddenly, the wp_redirect is not working and it redirects the user to https://picflick.co.za/dashboard/. I need them to be redirected to the post that they were editing (either a new or existing one) – e.g. https://picflick.co.za/dashboard/edit-product/18218/.
Please assist with editing the wp_redirect().
Thanks, PicFlick -
July 23, 2024 at 11:50 AM #221858Sangita Support SquadKeymaster
Hello there, Please update your previously shared code snippet by replacing “wcmp” with “mvx” in the code and check if it works as needed to fulfill your requirement.
Let us know if you need any further assistance.
-
July 23, 2024 at 11:49 PM #221890PicflickParticipant
Thanks. This did not work.
It redirected the user to https://picflick.co.za/dashboard/general/18218 -
July 24, 2024 at 4:34 PM #221923Sangita Support SquadKeymaster
Hello @Picflick, kindly add the below code in the functions.php file of your current active theme and check on your end –
add_action( 'mvx_before_post_update', 'required_mvx_product_field' ); function required_mvx_product_field() { $required_regular_price = isset( $_POST['_regular_price'] ) ? $_POST['_regular_price'] : ''; $required_feature_image = isset( $_POST['featured_img'] ) ? $_POST['featured_img'] : ''; $required_post_title = isset( $_POST['post_title'] ) ? $_POST['post_title'] : ''; $required_product_excerpt = isset($_POST['product_excerpt']) ? trim($_POST['product_excerpt']) : ''; if ( !$required_regular_price || !$required_feature_image || !$required_post_title || !$required_product_excerpt ) { wc_add_notice( __('Please ensure you have added a Product Title, Image, Short Description, and Price', 'dc-woocommerce-multi-vendor'), 'error' ); // Redirect to main page wp_redirect( apply_filters( 'mvx_vendor_save_product_redirect_url', mvx_get_vendor_dashboard_endpoint_url(get_mvx_vendor_settings('mvx_edit_product_endpoint', 'seller_dashbaord', 'edit-product'), $_POST['post_ID'] ) ) ); exit; } }
CopyLet us know if you need any further assistance from our end.
-
July 27, 2024 at 6:48 PM #221997PicflickParticipant
Thanks Sangita – I used your code and the same thing happened (see: https://ibb.co/61KG3dg).
-
July 27, 2024 at 6:57 PM #221998Sangita Support SquadKeymaster
Sorry to hear that the earlier shared code did not work for you. However, let me share this with the dev team and once I hear back from them I will keep you posted regarding the same.
Thanks for your understanding. -
August 3, 2024 at 12:40 PM #222075PicflickParticipant
Hi. Following up on this request please
-
August 3, 2024 at 5:21 PM #222078Sangita Support SquadKeymaster
Apologies for the delay. Our development team has been occupied with their preassigned tasks and hasn’t had the chance to address your issue with the custom code yet. However, rest assured that as soon as they are available, they will look into your issue with the code and we will update you promptly. Thank you for your patience.
-
August 7, 2024 at 4:04 PM #222157Sangita Support SquadKeymaster
Hello @Picflick, We have checked the code shared in the reply #221923 and it is working absolutely fine on our end. You can check the same here https://www.awesomescreenshot.com/video/30276325?key=0729150c5cc59846cea86b21ab2d1369.
Now can you please share how the flow is working on your end with the updated code. So that we can look into it and understand it better.
-
August 8, 2024 at 12:12 PM #222174PicflickParticipant
Thank you very much. This code was key:
wp_redirect( apply_filters( ‘mvx_vendor_save_product_redirect_url’, mvx_get_vendor_dashboard_endpoint_url(get_mvx_vendor_settings(‘mvx_edit_product_endpoint’, ‘seller_dashbaord’, ‘edit-product’), $_POST[‘post_ID’] ) ) );
All working now! – appreciate it 🙂
Post closed -
August 8, 2024 at 12:24 PM #222175Sangita Support SquadKeymaster
@Picflick, Thanks for the update.
We are closing this thread. If you need help or face issues in future please do create a new support ticket.
-
-
AuthorPosts
The topic ‘Required fields for Add Product’ is closed to new replies.