MultivendorX
-
AuthorPosts
-
-
September 14, 2023 at 10:20 PM #196199
l.gan
ParticipantHello, please tell me, is there a way to manage the emails that are sent to the buyer when the order status changes?
I need:
1. Disable parent letters that are created from Woo (but leave those that are sent by the Multivendor plugin for suborders)
Order statuses:Delivered – (My custom order status) ‘delivery’ (I used the hook) woocommerce_order_status_changed
Refunded – ‘refunded’2. Disable letters from Multivendor for suborders, leave only from Woo.
Order statuses:Completed: ‘completed’
-
September 15, 2023 at 5:51 PM #196246
Sangita Support Squad
Keymaster@l.gan We will provide you code for order status being refunded and completed. But as you have created the custom order status delivered, hence you will have to implement the same flow for delivered status from our code.
The reply might get delayed due to weekend. -
September 18, 2023 at 4:40 PM #196373
Sangita Support Squad
KeymasterOur replies are inline –
1. Disable parent letters that are created from Woo (but leave those that are sent by the Multivendor plugin for suborders)
Order statuses:
Delivered – (My custom order status) ‘delivery’ (I used the hook) woocommerce_order_status_changed
Refunded – ‘refunded’
>> You can add the below code in the functions.php file of your current active theme to disable the parent order mail from the customers –add_filter( 'woocommerce_email_recipient_customer_refunded_order', 'disable_email_for_parent_order', 10,3 ); function disable_email_for_parent_order( $recipient, $order, $object ){ if( wp_get_post_parent_id( $order->get_id() ) ){ return $recipient; } else{ return; } }
CopyYou can implement the same for order status delivered.
2. Disable letters from Multivendor for suborders, leave only from Woo.
Order statuses:
Completed: ‘completed’
>>You can add the below code in the functions.php file of your current active theme to disable emails for suborders for the order status – completed –/*** Disable suborder email to customer ****/ add_filter( 'woocommerce_email_recipient_customer_completed_order', 'disable_email_for_sub_order', 10,3 ); function disable_email_for_sub_order( $recipient, $order, $object ){ if( wp_get_post_parent_id( $order->get_id() ) ){ return; } else { return $recipient; } }
Copy -
September 18, 2023 at 9:43 PM #196392
l.gan
ParticipantThank you very much for your answer, it really works.
Please tell me, I still have a custom status, with which I add my custom status. There is also an event that we send by email to the client’s email. Everything works, but 2 emails are sent. (For parent order and for suborder).
Please tell me how to correct this code so that it only sends to the suborder?
Perhaps there is an option to disable synchronization of the parent order with the suborder, only for a certain order status? For example, in my case: for custom order status ‘readytocollect’?
I triedadd_filter( ‘woocommerce_email_recipient_customer_readytocollect_order’, ‘disable_email_for_parent_order’, 10,3 );
function disable_email_for_parent_order( $recipient, $order, $object ){
if( wp_get_post_parent_id( $order->get_id() ) ){
return $recipient;
} else{
return;
}
}But it didn’t help me. As before, 2 emails are sent for the parent order and for the suborder.
Please help me, below is my code for adding custom status.
// Enable custom statuses for WooCommerce Orders
add_action(‘init’, ‘register_custom_order_statuses’);
function register_custom_order_statuses() {
register_post_status(‘wc-readytocollect’, array(
‘label’ => __( ‘The order is being collected’, ‘woocommerce’ ),
‘public’ => true,
‘exclude_from_search’ => false,
‘show_in_admin_all_list’ => true,
‘show_in_admin_status_list’ => true,
‘label_count’ => _n_noop(‘The order is being collected <span class=”count”>(%s)</span>’, ‘The order is being collected<span class=”count”>(%s)</span>’)
));
}// Add a custom order status to list of WC Order statuses
add_filter(‘wc_order_statuses’, ‘add_custom_order_statuses’);
function add_custom_order_statuses($order_statuses) {
$new_order_statuses = array();
// add new order status before processing
foreach ($order_statuses as $key => $status) {
$new_order_statuses[$key] = $status;
if (‘wc-processing’ === $key) {
$new_order_statuses[‘wc-readytocollect’] = __(‘The order is being collected’, ‘woocommerce’ );
}
}
return $new_order_statuses;
}// event for sending email
add_action(‘woocommerce_order_status_changed’, ‘my_notification_readytocollect’);
function my_notification_readytocollect ($order_id) {
global $woocommerce;
$order = new WC_Order( $order_id );
if($order->status === ‘readytocollect’ ) {
//HERE IS THE ISSUE
$order->get_order_number();
// Create a mailer
$mailer = $woocommerce->mailer();
$message_body = ”
<html>
<head>
<style>
.h1 {
max-width: 620px;
font-family: ‘Roboto’,Helvetica,Arial,sans-serif;
}
</style>
</head>
<body>
<h1>The order is being collected</h1>
<h2></h2>
</body>
</html> “;
$message = $mailer->wrap_message(
// Message head and message body.
sprintf( __( ‘The order is being collected’ ), $order->get_order_number() ), $message_body );
// Send email
$mailer->send( $order->billing_email, sprintf( __( ‘The order is being collected’ ), $order->get_order_number() ), $message );
}
} -
September 19, 2023 at 4:44 PM #196425
Sangita Support Squad
KeymasterKindly add the below code to disable parent order mails for your custom order status –
add_filter( 'woocommerce_email_recipient_wc-readytocollect', 'disable_email_for_parent_order', 10,3 ); function disable_email_for_parent_order( $recipient, $order, $object ){ if( wp_get_post_parent_id( $order->get_id() ) ){ return $recipient; } else{ return; } }
Copy -
September 19, 2023 at 8:13 PM #196442
Sangita Support Squad
KeymasterAs the status you have created by adding custom code hence we need the access of a staging site that will be an exact replica of your live site so that we can check the flow there and help you accordingly.
So kindly share the staging site url ,temporary admin and ftp access with us.
While sharing the access don’t forget to mark the reply as private. -
September 20, 2023 at 5:45 PM #196473
Sangita Support Squad
Keymaster@l.gan We have checked by enabling the Suborder mail option from the settings submenu and when a user places an order from multiple vendors the orders are splitted into suborders in the mail. Kindly check https://watch.screencastify.com/v/AgoEOypDKl32xPQzaaM5.
-
September 20, 2023 at 10:12 PM #196481
l.gan
ParticipantSangeeta Hello,
Yes, I saw how it should work.
1. This is really very cool, please tell me, I created my email layout, but in the child folder along the path ../woodmart-child/MultiVendorX/templates/woocommerce/emails/email-order-details.php does not respond to changes. Editing is only visible in the plugin’s parent folder. Please tell me how can I correctly put my modified file in a child theme?
2. The same goes for the trash file. I tried to override it, due to the fact that my Woodmart theme breaks the code if you enable the excellent function “add_filter(‘mvx_display_multiple_vendor_notice_at_cart_chekout_page’, ‘__return_false’);” . (please see photo).
The bottom line is that if there is 1 vendor in the cart, everything is ok.
If there is 2 vendors, a breakdown occurs.Perhaps I could, in theory, try to override the cart file and merge the settings, but the changes also do not appear in the child theme to override ../public_html/wp-content/themes/woodmart-child/woocommerce/cart/cart.php. Editing is only visible in the plugin’s parent folder. Can you please tell me which path to the file should be correct?
3. Is there information on custom order statuses and duplication cancellation?
-
-
September 21, 2023 at 6:26 PM #196520
Sangita Support Squad
Keymaster@l.gan Our replies are inline with your queries –
1. This is really very cool, please tell me, I created my email layout, but in the child folder along the path ../woodmart-child/MultiVendorX/templates/woocommerce/emails/email-order-details.php does not respond to changes. Editing is only visible in the plugin’s parent folder. Please tell me how can I correctly put my modified file in a child theme?
>>The overriding path for the email-order-details.php template file is yourtheme/woocommerce/emails/email-order-details.php
. We have checked this on our end and overriding is working fine. So you can override this template file following the path stated above to add changes accordingly.
2. The same goes for the trash file. I tried to override it, due to the fact that my Woodmart theme breaks the code if you enable the excellent function “add_filter(‘mvx_display_multiple_vendor_notice_at_cart_chekout_page’, ‘__return_false’);” . (please see photo).
The bottom line is that if there is 1 vendor in the cart, everything is ok.
If there is 2 vendors, a breakdown occurs.
Perhaps I could, in theory, try to override the cart file and merge the settings, but the changes also do not appear in the child theme to override ../public_html/wp-content/themes/woodmart-child/woocommerce/cart/cart.php.
Editing is only visible in the plugin’s parent folder. Can you please tell me which path to the file should be correct?
>>We provided the code earlier because in your theme our layout was looking broken so with the code we stopped the vendor wise split in the cart. Kindly let us know if the code is not working properly on your end and the cart page is still looking broken?
As I can see that you want to override/edit the woocommerce cart page. So kindly let us know how this overriding is connected to our plugin. Because both the template overriding are working fine on our end. If that does not work properly for you it might be some issue in your theme.
3. Is there information on custom order statuses and duplication cancellation?
>> We follow the woocommerce order status. So if you have followed the flow of woocommerce to create the custom status then the above mentioned code to remove emails for order statuses should have worked fine. But it is not possible for us to debug your custom code as this debugging requires a lot of time.
If you need help for this you can hire our service team https://multivendorx.com/custom-development/. They can help you with this.
Let us know if you need any further help. -
September 22, 2023 at 8:34 PM #196551
l.gan
ParticipantThis reply has been marked as private. -
September 23, 2023 at 12:28 PM #196566
Sangita Support Squad
Keymaster@l.gan Our replies are inline with your queries –
1. I recorded a video for you, where you can clearly see that a template in a multivendor plugin is used for a new order. And for invoicing – a template from a child theme. Please look. https://drive.google.com/file/d/1Zl48Oqre6mC68S7xzDjzueG3xjsZ7UxT/view?usp=sharing
You still have access to testing.
>>You just need to follow the overriding path given in the template file to override the template file and add that in your child theme and then make the modifications in the template file. We have checked this again and the modifications in the child theme are getting saved correctly.
Kindly check if there is some issue on your child theme or not.
2. Yes, this is a conflict with the theme, this point has been resolved.
>>Glad to hear that.
3. I need more time.
>>Sure. If you need help please let us know.-
September 25, 2023 at 9:23 AM #196592
l.gan
ParticipantOkay, I’ll try to explain in more detail:
1. Using a Woodmart child theme.
The problem is that if you add products from 1 vendor to your cart, then everything is ok.
But if you add 2 products from 2 buckets (or more), then the buyer receives the template from the plugin folder, and not from the child theme.
Watch the video:https://drive.google.com/file/d/1d9hEQklUGNjEBRlBexk-g3foIXlxLAlX/view?usp=sharing
2. Because If you have any doubts about the correctness of my Woodmart child theme, I created a Storefront child theme using a popular plugin.
I placed a file with an email template in the child theme. And you may also see the problem repeating itself.
In both video versions there is no custom code or third-party plugins.
The problem is the same (which means the problem is not in my child theme): If there is 1 product in the order, then at first glance everything is ok.
But if the order contains several products from 2 or more vendors, the letter uses the template from the Multivendor plugin and ignores the child template.I recorded a video for you with the whole process.
https://drive.google.com/file/d/1uruAenA3cmnId3mBkWppEtXtcy12OIua/view?usp=sharing
-
-
September 25, 2023 at 12:56 AM #196615
l.gan
Participantcheck your spam please, my answer seems to be there
-
September 25, 2023 at 2:05 PM #196634
Sangita Support Squad
Keymaster@l.gan As the overriding is working fine when a product from one vendor is added that means there is no issue with the overriding path.
So kindly check the code carefully to debug the issue.-
September 25, 2023 at 4:14 PM #196637
l.gan
ParticipantSangeeta thank you for your answer, but it seems you don’t understand me.
no problem:
If the products in the cart are from 1 vendor, then the file for the template mail is taken from the child theme. (The file that is overridden and located in the folder ../public_html/wp-content/themes/storefront-child/woocommerce/emails).problem:
If there are products from 2 vendors (or more) in the cart, then the file for the template mail is taken from the plugin folder /public_html/wp-content/plugins/dc-woocommerce-multi-vendor/templates/woocommerce/emails and this file is not overridden, this is the original file !It turns out that if a client ordered goods from 1 vendor, he will receive a letter with the design.
And if he ordered goods in 1 order with 2 (or more) suborders, then he will receive a template letter from the multivendor (without Design!).
We are talking only about a letter to the client about his new order.
This is problem. I don’t know how to explain this to you anymore.
This problem is corrected only when the file itself, which is located at /public_html/wp-content/plugins/dc-woocommerce-multi-vendor/templates/woocommerce/emails, is changed. Then there won’t be a problem. But when updating it will also be updated, this is not an option._____
There is no custom code on the testing site. The only correction in the code of the letter file (which is in the child theme) is only to indicate the path where the template comes from, and this can be seen in the video.
This has been tested on several sites, + I’ve posted a video for you, + you have access to a test environment, so please don’t tell me everything is fine.
-
-
September 27, 2023 at 6:14 PM #196697
Sangita Support Squad
KeymasterAdd the below code in the functions.php file of your current active theme and also add the correct overriding path in the code where that is required –
add_action('init', 'remove_mail'); function remove_mail() { global $MVX; remove_filter( 'wc_get_template', array( $MVX->frontend, 'mvx_template_email_order_details' ), 10, 5 ); add_filter( 'wc_get_template', 'mvx_template_email_order_details_custom', 10, 5 ); } function mvx_template_email_order_details_custom( $template, $template_name, $args, $template_path, $default_path ) { global $MVX; if ( 'email-order-details.php' === basename( $template ) ) { if ( $args['plain_text'] === false && $args['sent_to_admin'] === false ) { $order = $args['order']; $order_id = $order->get_id(); $vendors = $MVX->frontend->get_vendors_of_order($order_id); if ( count($vendors) > 1 ) { $template = //add your overridding file path here; } } } return $template; }
Copy -
September 27, 2023 at 7:21 PM #196699
l.gan
ParticipantWhen a vendor adds a new product an error occurs. And it is impossible to add a product.
The E_PARSE type error occurred on line 90 of //public_html/wp-content/themes/woodmart-child/functions.php. Error message: syntax error, unexpected identifier ” ”
line 90: if ( $args [‘plain_text’] === false && $args[‘sent_to_admin’] === false )When placing an order I receive a message
“There was an error during the checkout process. Please try again.”The same error occurs in the developer console.
/?wc-ajax=checkout:1 Failed to load resource: the server responded with a status of 500 () -
September 28, 2023 at 10:57 AM #196713
Sangita Support Squad
KeymasterKindly add the below code and check if you are still facing the issue on your end or not –
add_action('init', 'remove_mail'); function remove_mail(){ global $MVX; remove_filter( 'wc_get_template', array( $MVX->frontend, 'mvx_template_email_order_details' ), 10, 5 ); add_filter( 'wc_get_template', 'mvx_template_email_order_details_custom', 10, 5 ); } function mvx_template_email_order_details_custom( $template, $template_name, $args, $template_path, $default_path ){ global $MVX; if ( 'email-order-details.php' === basename( $template ) ){ if ( $args['plain_text'] === false && $args['sent_to_admin'] === false ){ $order = $args['order']; $order_id = $order->get_id(); $vendors = $MVX->frontend->get_vendors_of_order($order_id); if ( count($vendors) > 1 ){ $template = //add your overridding file path here; } } } return $template; }
Copy-
September 29, 2023 at 5:28 PM #196766
l.gan
ParticipantCould you please tell me in what format the path to the file should be specified.
I tried $template = ‘/woodmart-child/woocommerce/emails/email-order-details.php’;But the letter arrives without any order details at all. (the rest of the parts, header, footer and information about vendors come entirely)
-
-
September 29, 2023 at 5:46 PM #196768
NerdySupportExpert Moumita
Keymaster@l.gan, you need to give the full path of the file like public_html/wp-content……email-order-details.php
So, check the file path on your end and provide the information as per that.
-
October 3, 2023 at 3:32 PM #196864
Sangita Support Squad
Keymaster@l.gan Sorry for the delayed response. We have added the earlier shared code on our end and the template overriding is working fine. Kindly check the video https://watch.screencastify.com/v/g1KOXFiPf6ciAC3j5ZI5.
So please double check this on your end. -
October 13, 2023 at 8:36 PM #197161
Sangita Support Squad
Keymaster@l.gan no worries. We will look forward to hear back from you.
-
-
AuthorPosts
Please LOGIN to reply to this topic