WCMp Core
-
AuthorPosts
-
-
October 7, 2021 at 1:45 AM #128710MaxenceTPParticipant
Hello,
I don’t quite understand how the “Share Coupon Discount” option works: https://prnt.sc/1v1nr37
I would like the coupon to be fully charged to the seller and the admin commission to remain unchanged. Here is an example to be clearer:
The product is at 10€; the seller earns 75% per saleIn normal time he would earn 7,5€ per sale
If I subtract a 2€ discount, I would like the seller to earn (7,5 – 2) = 5,5€ for the sale.How can I do this?
-
October 7, 2021 at 8:25 PM #128761MVX Support NinjaKeymaster
Hi, thank you for getting in touch with us.
Kindly note that whenever you are creating a coupon and enabling the option of Share Coupon Discount, vendor’s commission will get calculated deducting the coupon’s price.
For example, if a product price is 500$,coupon discount is 20% and vendor’s commission is 75%.
It means after applying the coupon the amount will get deducted i.e, 500$ – 20% =400$
Vendor’s commission will be calculated on 400$, i.e, 75% of 400$= 300$
Note that this commission is calculated including coupon discount.However if you do not enable “Share Coupon Discount”, then vendor will get the commission on the actual price of the product, ,i.e, vendor will receive 75% of 500$ = 375
Note that this commission is calculated excluding the coupon discount. -
October 7, 2021 at 9:12 PM #128769MaxenceTPParticipant
Yes, that’s what I understood during my tests.
How can I make it so that the vendor handles all the discount? Like the example I gave above -
October 8, 2021 at 1:11 PM #128802MVX Support NinjaKeymaster
Hi,
I understand your requirement that you want coupon amount to be deducted from vendor’s commission.
The default flow of the plugin does not support this, since other marketplace do not follow this rule of calculating coupon amount.
However if you wish you can do custom code to modify the admin’s commision on coupon amount.
If you have any hook filter do let us know. -
October 8, 2021 at 7:38 PM #128825MaxenceTPParticipant
If you can help me with that, it would be really nice 🙂
-
October 11, 2021 at 3:29 PM #128936MVX Support NinjaKeymaster
We would love to help you out @MaxenceTP. Generally, as you know, our team does give code snippets, but if that requires a small amount of coding.
Now the flow you are looking for requires a good amount of codes. So If you have any developer, ask them to contact us so we can help you out with the coding procedure.
Alternatively, you may hire our service team (https://multivendorx.com/custom-development/) so they can add this feature in your site. -
October 11, 2021 at 5:18 PM #128941MaxenceTPParticipant
Can you tell me which files and/or functions I need to change?
-
October 13, 2021 at 8:58 PM #129023NerdySupportExpert MoumitaKeymaster
Hi, our team will look into this, kindly provide them some time.
p.s. Our office is closed due to holidays (12th to 17th Oct). Hence, the response might get delayed.
-
October 14, 2021 at 1:39 AM #129044MaxenceTPParticipant
Ok I’m waiting for your answer 🙂
-
October 18, 2021 at 4:28 PM #129168MVX Support NinjaKeymaster
Hi,
As per your requirement you have to add custom doe using below filterapply_filters('wcmp_get_commission_line_total', $line_total, $product_id, $variation_id, $item, $order_id, $item_id);
CopyRegards,
-
October 19, 2021 at 8:47 PM #129253MaxenceTPParticipant
I made some modifications in the class-wcmp-calculate-commission.php that seem to be correct: https://prnt.sc/1wpwo3h
However how can I integrate this into the apply_filters so I don’t directly modify the plugin files? Or else can you make an update to WCMP to add this functionality in a setting?
-
October 21, 2021 at 6:29 PM #129350MVX Support NinjaKeymaster
Hi,
other marketplace do not follow this rule of calculating coupon amount. So you have to add code using filter and hooks kindly use below filter to override and change the codeapply_filters('wcmp_get_commission_line_total', $line_total, $product_id, $variation_id, $item, $order_id, $item_id);
Copyand
apply_filters('vendor_commission_amount', $amount, $product_id, $variation_id, $item, $order_id, $item_id);
CopyRegards,
-
October 22, 2021 at 5:37 PM #129252MaxenceTPParticipant
I made some modifications in the class-wcmp-calculate-commission.php that seem to be correct: https://prnt.sc/1wpwo3h
However how can I integrate this into the apply_filters so I don’t directly modify the plugin files? Or else can you make an update to WCMP to add this functionality in a setting?
Here is my code: https://pastebin.com/Yf2mAvSb
-
October 22, 2021 at 5:37 PM #129241MaxenceTPParticipant
I made some modifications in the class-wcmp-calculate-commission.php that seem to be correct: https://prnt.sc/1wpwo3h
However how can I integrate this into the apply_filters so I don’t directly modify the plugin files? Or else can you make an update to WCMP to add this functionality in a setting?
Here is my code: https://pastebin.com/Yf2mAvSb
-
October 23, 2021 at 2:12 AM #129441MaxenceTPParticipant
Wow, why did my answers get duplicated :d
I don’t see how to do this with only filters. For example on my screenshot I modify line 547, how could I do that?
Or else can I overwrite the whole get_item_commission function in my theme? And if yes, how?Sorry for the inconvenience, and thanks in advance for the help
-
October 23, 2021 at 6:44 PM #129467MVX Support NinjaKeymaster
Hi,
You can’t override the whole function or not override our core file.
You have to use above filter.
Kindly hire a developer for this custom work.Regards,
-
October 24, 2021 at 1:59 AM #129470MaxenceTPParticipant
Well what I did works, the only problem is that I have to re-modify the file at each update since I can’t do that in my child-theme.
I don’t see how another developer would be useful.How do you think you can do with the filter? I don’t see how to get the right result by modifying the code only in this place.
Can you give me an example in a few words? Or in a few lines? -
October 25, 2021 at 3:31 PM #129539MVX Support NinjaKeymaster
can you provide us with the coding overview
-
October 26, 2021 at 12:28 PM #129568MaxenceTPParticipant
As I said, here is what I would like to change in the code : https://prnt.sc/1wpwo3h
And this is the code of the screenshot : https://pastebin.com/Yf2mAvSb -
October 26, 2021 at 6:52 PM #129659MVX Support NinjaKeymaster
Hi,
Please add this code in the function.php of the current active theme and test:add_filter('vendor_commission_amount', 'wcmp_vendor_commission_amount_modification', 99, 6); function wcmp_vendor_commission_amount_modification( $amount, $product_id, $variation_id, $item, $order_id, $item_id) { global $WCMp; $order = wc_get_order($order_id); $amount = 0; $commission = array(); $commission_rule = array(); $product_value_total = 0; // Check order coupon created by vendor or not $order_counpon_author_is_vendor = false; if ($order->get_coupon_codes()) { foreach( $order->get_coupon_codes() as $coupon_code ) { $coupon = new WC_Coupon($coupon_code); $order_counpon_author_is_vendor = $coupon && is_user_wcmp_vendor( get_post_field ( 'post_author', $coupon->get_id() ) ) ? true : false; } } $line_discount = 0; if (isset($WCMp->vendor_caps->payment_cap['commission_include_coupon'])) { //$line_total = $order->get_item_total($item, false, false) * $item['qty']; $line_total = $order->get_item_subtotal($item, false, false) * $item['qty']; $line_discount = ($order->get_item_subtotal($item, false, false) - $order->get_item_total($item, false, false)) * $item['qty']; /*if (isset($WCMp->vendor_caps->payment_cap['admin_coupon_excluded']) && !$order_counpon_author_is_vendor) { $line_total = $order->get_item_subtotal($item, false, false) * $item['qty']; }*/ } else { $line_total = $order->get_item_subtotal($item, false, false) * $item['qty']; } // Filter the item total before calculating item commission. $line_total = apply_filters('wcmp_get_commission_line_total', $line_total, $product_id, $variation_id, $item, $order_id, $item_id); if ($product_id) { $vendor_id = wc_get_order_item_meta($item_id, '_vendor_id', true); if ($vendor_id) { $vendor = get_wcmp_vendor($vendor_id); } else { $vendor = get_wcmp_product_vendors($product_id); } if ($vendor) { $commission = $WCMp->commission->get_commission_amount($product_id, $vendor->term_id, $variation_id, $item_id, $order); $commission = apply_filters('wcmp_get_commission_amount', $commission, $product_id, $vendor->term_id, $variation_id, $item_id, $order); if (!empty($commission)) { if ($WCMp->vendor_caps->payment_cap['commission_type'] == 'fixed_with_percentage') { $amount = (float) $line_total * ( (float) $commission['commission_val'] / 100 ) + (float) $commission['commission_fixed']; } else if ($WCMp->vendor_caps->payment_cap['commission_type'] == 'fixed_with_percentage_qty') { $amount = (float) $line_total * ( (float) $commission['commission_val'] / 100 ) + ((float) $commission['commission_fixed'] * $item['qty']); } else if ($WCMp->vendor_caps->payment_cap['commission_type'] == 'percent') { $amount = (float) $line_total * ( (float) $commission['commission_val'] / 100 ); } else if ($WCMp->vendor_caps->payment_cap['commission_type'] == 'fixed') { $amount = (float) $commission['commission_val'] * $item['qty']; } elseif ($WCMp->vendor_caps->payment_cap['commission_type'] == 'commission_by_product_price') { $amount = $WCMp->commission->wcmp_get_commission_as_per_product_price($product_id, $line_total, $item['qty'], $commission_rule); } elseif ($WCMp->vendor_caps->payment_cap['commission_type'] == 'commission_by_purchase_quantity') { $amount = $WCMp->commission->wcmp_get_commission_rule_by_quantity_rule($product_id, $line_total, $item['qty'], $commission_rule); } if (isset($WCMp->vendor_caps->payment_cap['revenue_sharing_mode'])) { if ($WCMp->vendor_caps->payment_cap['revenue_sharing_mode'] == 'admin') { $amount = (float) $line_total - (float) $amount - (float) $line_discount; if ($amount < 0) { $amount = 0; } } } if ($variation_id == 0 || $variation_id == '') { $product_id_for_value = $product_id; } else { $product_id_for_value = $variation_id; } $product_value_total += $item->get_total(); if ( apply_filters('wcmp_admin_pay_commission_more_than_order_amount', true) && $amount > $product_value_total) { $amount = $product_value_total; } return $amount; } } } return $amount; }
CopyRegards,
-
October 27, 2021 at 2:38 AM #129675MaxenceTPParticipant
Thank you! The overwrite works 🙂
This is solved -
October 27, 2021 at 10:46 AM #129681MVX Support NinjaKeymaster
I hope you are satisfied with our assistance and plugin. A 5/5 review here- https://wordpress.org/support/plugin/dc-woocommerce-multi-vendor/reviews/#new-post , would be a great way to share your experience with others.
This motivates us to continue providing the best experience possible and also helps others know how WC-Marketplace can make their life easier.
-
-
AuthorPosts
The topic ‘Share Coupon Discount’ is closed to new replies.