Urs channel is a gem for web developers... so many good wordpress tutorials..
@dhruv9963
3 жыл бұрын
Hi Victor, Thank you for sharing valuable knowledge, and please make more tutorials on woocommerce development, Many Thanks 😊
@software_engineer_semh
3 жыл бұрын
hi, really very excellent lesson and this plugin is not work to *variable products* , how to add this to variable product type also
@Ankit-pm2tm
3 жыл бұрын
Thanks for video
@dulangaweerasuriya
Жыл бұрын
Hi, @VicodeMedia I need to only show the file name, how can I do it
@emranurrahman1359
2 жыл бұрын
Hi victor, one of my worries with this method is could it potentially be used as a vulnerability point to upload files with malicious code.
@tollarandras9659
3 жыл бұрын
Hi Victor! If I don't display the file upload field on the product page (that is, if I leave the field blank when editing the product) and click the Add to Cart button, I still get an error message when uploading the image, as if I didn't upload an image, but it's a product where there is no file upload option. There is something wrong with the code and I can't figure out where. Thanks
@VicodeMedia
3 жыл бұрын
Hi, Tollar! I don't remember exactly but you can add an if statement that would check if the upload field has any data assignment and if it doesn't then you don't fire the upload validation.
@tollarandras9659
3 жыл бұрын
@@VicodeMedia Thanks for the quick response. I tried this but it didn't work. // custom input validation if($title){ function vicode_field_validation( $passed, $product_id, $quantity ) { if( empty($_FILES['vicode-file-field']["name"])) { // Fails validation $passed = false; wc_add_notice( __( 'Please attach an image to your product.', 'vicode' ), 'error' ); } return $passed; } add_filter( 'woocommerce_add_to_cart_validation', 'vicode_field_validation', 10, 3 ); }
@arrodrigues
2 жыл бұрын
Hello Tollar!!! I had the same problem. I'm used to write JS, not PHP, but I looked at the code and made some guesses based on the syntaxe and I came up with a solution that worked here. Hope it can help you! //////////////////////////////////////// // custom input validation function vicode_field_validation( $passed, $product_id, $quantity ) { $title = $_FILES['vicode-file-field']; if( empty($_FILES['vicode-file-field']["name"]) && isset($title) ) { // Fails validation $passed = false; wc_add_notice( __( 'Please attach an image to your product.', 'vicode' ), 'error' ); } return $passed; } add_filter( 'woocommerce_add_to_cart_validation', 'vicode_field_validation', 10, 3 );
Пікірлер: 10