Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › Problem with NEW ORDER email mixing products from another vendor
Tagged: mixed items, new order email
- This topic has 4 replies, 2 voices, and was last updated 5 years, 1 month ago by id.manage.
- AuthorPosts
- October 25, 2019 at 11:11 pm #89086daniel.oizumiParticipant
We are facing a very strange behavior when WCFM sends the NEW ORDER email to multiple vendors.
Sometimes the NEW ORDER email, sent to multiple vendors, gets mixed-up with items from another vendor (VENDOR A receives order of items from VENDOR B and vice versa).
What’s very strange is that when we replicate the order, the email is sent correctly, with each vendor receiving it’s corresponding items. (VENDOR A receives order with items from VENDOR A only).
Does anyone have a clue of why is this happening? - November 2, 2019 at 7:19 pm #90309daniel.oizumiParticipant
I fixed the problem removing a part of the code “|| in_array( $value->get_id(), $valid_items )” on the wc-frontend-manager\core\class-wcfm-wcfmmarketplace.php file.
Line 406
// Filter Order Details Line Items as Per Vendor
function wcfmmp_valid_line_items( $items, $order_id ) {
global $WCFM, $wpdb;$sql = “SELECT
product_id
,item_id
FROM {$wpdb->prefix}wcfm_marketplace_orders WHEREvendor_id
= {$this->vendor_id} ANDorder_id
= {$order_id}”;
$valid_products = $wpdb->get_results($sql);
$valid_items = array();
if( !empty($valid_products) ) {
foreach( $valid_products as $valid_product ) {
$valid_items[] = $valid_product->item_id;
$valid_items[] = $valid_product->product_id;
}
}$valid = array();
foreach ($items as $key => $value) {
if ( in_array( $value->get_variation_id(), $valid_items ) || in_array( $value->get_product_id(), $valid_items ) ) {
$valid[$key] = $value;
} elseif( $value->get_product_id() == 0 ) {
$_product_id = wc_get_order_item_meta( $key, ‘_product_id’, true );
if ( in_array( $_product_id, $valid_items ) ) {
$valid[$key] = $value;
}
}
}
return $valid;
}However, I would like to implement this fix on my function.php. Does anyone know how?
- November 3, 2019 at 2:49 am #90353daniel.oizumiParticipant
Sorry, I also had to change the SQL Query.
from:
$sql = “SELECT product_id, item_id FROM {$wpdb->prefix}wcfm_marketplace_orders WHERE vendor_id = {$this->vendor_id} AND order_id = {$order_id}”;to:
$sql = “SELECT product_id FROM {$wpdb->prefix}wcfm_marketplace_orders WHERE vendor_id = {$this->vendor_id} AND order_id = {$order_id}”; - November 3, 2019 at 3:39 am #90361daniel.oizumiParticipant
Had to change this as well
foreach( $valid_products as $valid_product ) {
//$valid_items[] = $valid_product->item_id;
$valid_items[] = $valid_product->product_id;
} - November 3, 2019 at 3:12 pm #90421id.manageParticipantThis reply has been marked as private.
- AuthorPosts
- The topic ‘Problem with NEW ORDER email mixing products from another vendor’ is closed to new replies.