Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Feature Request › Activate/Deactivate COD by vendors when desired.
- This topic has 22 replies, 4 voices, and was last updated 5 years, 11 months ago by WCFM Forum.
- AuthorPosts
- September 22, 2018 at 3:13 pm #32242d-n-13Participant
Hi good wclovers team,
I have tested the new feature “Reverse Withdrawal” and it works flawless ! Very well done wclovers !
Although this awesome feature is implemented, we cannot really use COD in most cases, currently WCFM Marketplace expects you to have shipping model as one of the following :-
1- Shipping by Admin only (COD per gateway can be done using 3rd party plugins such as Booster).
2- Shipping by Vendors only (All Vendors provide COD).
3- Shipping by Vendors only (All Vendors DON’T provide COD).
4- (1)+(2).
5- (1)+(3)Note : (2)+(3) cannot work together atm.
As you can see, Marketplace like mine where vendors do all the shipping by themselves won’t work well with COD + Reverse Withdrawal because I need to decide to accept only vendors who provide COD or accept vendors who don’t provide COD.
Now in what cases vendors provide or don’t provide COD ?
A – Some vendors will have to use 3rd party shipping companies such as FedEx and of course they don’t provide COD.
B – Some vendors will have to use 3rd party shipping companies such as local shipping companies and they provide COD services.
C – If vendor do the shipping himself or individual partners then he can do COD.As you can see, it’s hard to control when Vendors provide COD or Not.
Why this is an issue ?
If admin activate COD as payment method, then it will always be available at checkout, even for vendors who don’t provide COD, and they will have to cancel / re-apply order, it will cause bad experience for both Customers and Vendors.
Summery : Vendors need to have the ability to activate/deactivate COD by shipping methods or products. Also COD should be off by default and turned on by vendors when desired.
Kind Regards,
Khalid - November 13, 2018 at 9:36 am #36594WCFM ForumMember
Hi,
Sorry for delayed update on this.
Tell me one thing, are using any plugin (Booster) for controlling payment gateway options at checkout as cart products?
Suppose, a vendor does not support COD then this pay option should be hidden from checkout if this vendor’s product on cart, is this happen to your site?
Well, we can add an option at vendor level – whether “Reverse Withdrawal” will for him or not! Hope this will solve your issues quite a bit.
Please know me your thoughts!
Thank You
- November 16, 2018 at 8:55 pm #36871d-n-13Participant
Hi,
I don’t understand exactly what you mean,
Regarding Booster these are the options available : https://www.dropbox.com/s/rk5j9x326esorxd/payment%20gateway.JPG?dl=0
I am not sure how it is possible to integrate this with wcfm.
I want a simple checkbox option for vendors to show or hide COD, some vendors can some vendors cannot do COD.
WCFM Marketplace is so awesome with COD it has Reverse Withdrawal and many other features supports COD, but it only works if all vendors do COD.
Thank You
- November 17, 2018 at 10:32 am #36919MustafaParticipant
+1
- November 17, 2018 at 3:19 pm #36951WCFM ForumMember
HI,
“Regarding Booster these are the options available” – As I know this option comes with Product, right?
So, do you want to have this in WCFM product manager?
Thank You
- November 17, 2018 at 3:53 pm #36960d-n-13Participant
Hi,
You mean in each product, a Vendor can set if it has COD or Not ? that would be a reasonable solution.
Thank You
- November 17, 2018 at 4:14 pm #36962d-n-13Participant
Side Note,
It is better to associate COD with shipping if possible, example here : https://www.dropbox.com/s/4rnd3r4tc78em8l/shipping%2034.JPG?dl=0
Why is this better ? because if vendor wanna ship to different city or country he don’t want COD to be enabled.
I don’t know how easy or hard to do this in shipping level, but if it can be it would be better I think.
- November 20, 2018 at 7:36 am #37183WCFM ForumMember
Hi,
“It is better to associate COD with shipping if possible”
– With shipping method this will not work! WC has no such dependency.
Booster even allow only payment gateway specific shipping – https://booster.io/features/woocommerce-payment-gateways-by-shipping/
But reverse option not possible!We will implement this for product/vendor specific.
Hope you are using this – https://booster.io/features/woocommerce-payment-gateways-per-product-or-category/
Or some other plugin for the purpose?Thank You
- November 20, 2018 at 12:17 pm #37225d-n-13Participant
Hi,
”
With shipping method this will not work! WC has no such dependency.
Booster even allow only payment gateway specific shipping – https://booster.io/features/woocommerce-payment-gateways-by-shipping/
But reverse option not possible!
”How about you give me a filter to add new shipping methods “Flat Rate with COD”, “Free shipping with COD” and I add them to https://booster.io/features/woocommerce-payment-gateways-by-shipping/ ???
“We will implement this for product/vendor specific.”
You mean a vendor can add COD or remove COD while managing/editing the products ? it will be perfect
- November 28, 2018 at 8:51 am #38478WCFM ForumMember
HI,
“You mean a vendor can add COD or remove COD while managing/editing the products ? ”
– Yeah, this is possible to implement. Vendor will set whether they allow COD or not from their setting panel.
If COD not allowed by a vendor then if customer add his product in cart then COD option will not available under checkout for that order pay option.Thank You
- November 28, 2018 at 10:21 am #38495d-n-13Participant
Hi,
If possible to make it disabled by default then vendors can toggle them on when needed it would be cool.
Thank You
- November 28, 2018 at 11:43 am #38507WCFM ForumMember
Hi,
Yeah possible. but how you want to make this enable – Vendor wise or Product specific?
Thank You
- November 28, 2018 at 1:24 pm #38528d-n-13Participant
Hi,
Both are fine, I prefer vendor wise, 1 time setting. starting as disabled.
Thank You
- November 28, 2018 at 2:06 pm #38542WCFM ForumMember
OK, I will give you code for this.
Thank You
- November 28, 2018 at 2:38 pm #38543WCFM ForumMember
Hi,
Here is your code for the purpose –
// Payment Gateway Control add_filter( 'woocommerce_available_payment_gateways', function( $available_gateways ) { global $WCFM; if( isset( $available_gateways['cod'] ) ) { $cod_available = false; foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $cod_available = false; $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) { $vendor_id = $WCFM->wcfm_vendor_support->wcfm_get_vendor_id_from_product( $_product->get_id() ); if( !$vendor_id || !wcfm_is_vendor( $vendor_id ) ) continue; $vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true ); if( !$vendor_data ) $vendor_data = array(); $is_cod_enabled = isset( $vendor_data['payment']['wcfm_cod_enabled'] ) ? 'yes' : 'no' ; if( $is_cod_enabled == 'yes' ) { $cod_available = true; } } } // Unset COD if( !$cod_available ) unset( $available_gateways['cod'] ); } return $available_gateways; }, 200 ); // Vendor Setting add_filter( 'wcfm_marketplace_settings_fields_billing', function( $vendor_billing_fileds, $vendor_id ) { $vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true ); if( !$vendor_data ) $vendor_data = array(); $is_cod_enabled = isset( $vendor_data['payment']['wcfm_cod_enabled'] ) ? 'yes' : 'no' ; $vendor_wcfm_cod_enabled_fileds = array( 'wcfm_cod_enabled' => array('label' => __('COD Enable for Checkout', 'wc-frontend-manager'), 'name' => 'payment[wcfm_cod_enabled]', 'type' => 'checkbox', 'class' => 'wcfm-checkbox wcfm_ele', 'label_class' => 'wcfm_title wcfm_ele checkbox_title', 'value' => 'yes', 'dfvalue' => $is_cod_enabled ), ); $vendor_billing_fileds = array_merge( $vendor_wcfm_cod_enabled_fileds, $vendor_billing_fileds ); return $vendor_billing_fileds; }, 50, 2);
There is a setting option for enable COD for any vendor – https://ibb.co/zVh4c0M
Thank You
- December 4, 2018 at 4:02 pm #39020d-n-13Guest
Hello,
I’ve tested out, it is working 90% prefect,
the problem is if there are 2 products one of them with COD then it apply COD to both, is it possible to make it the opposite way ? if one of them with no COD then both/all don’t offer COD in the same order ?
- December 4, 2018 at 4:39 pm #39023WCFM ForumMember
Hi,
“the problem is if there are 2 products one of them with COD then it apply COD to both, is it possible to make it the opposite way ? if one of them with no COD then both/all don’t offer COD in the same order ?”
– Really! As i have written code in a way -> if cart has two products from two different vendor but only one allow COD then COD will not available for pay option. Is this not working for you?Well, I have tweak this code a bit, please use this ->
// Payment Gateway Control add_filter( 'woocommerce_available_payment_gateways', function( $available_gateways ) { global $WCFM; if( isset( $available_gateways['cod'] ) ) { $cod_available = false; foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $cod_available = false; $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) { $vendor_id = $WCFM->wcfm_vendor_support->wcfm_get_vendor_id_from_product( $_product->get_id() ); if( !$vendor_id || !wcfm_is_vendor( $vendor_id ) ) continue; $vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true ); if( !$vendor_data ) $vendor_data = array(); $is_cod_enabled = isset( $vendor_data['payment']['wcfm_cod_enabled'] ) ? 'yes' : 'no' ; if( $is_cod_enabled == 'yes' ) { $cod_available = true; } else { break; } } } // Unset COD if( !$cod_available ) unset( $available_gateways['cod'] ); } return $available_gateways; }, 200 ); // Vendor Setting add_filter( 'wcfm_marketplace_settings_fields_billing', function( $vendor_billing_fileds, $vendor_id ) { $vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true ); if( !$vendor_data ) $vendor_data = array(); $is_cod_enabled = isset( $vendor_data['payment']['wcfm_cod_enabled'] ) ? 'yes' : 'no' ; $vendor_wcfm_cod_enabled_fileds = array( 'wcfm_cod_enabled' => array('label' => __('COD Enable for Checkout', 'wc-frontend-manager'), 'name' => 'payment[wcfm_cod_enabled]', 'type' => 'checkbox', 'class' => 'wcfm-checkbox wcfm_ele', 'label_class' => 'wcfm_title wcfm_ele checkbox_title', 'value' => 'yes', 'dfvalue' => $is_cod_enabled ), ); $vendor_billing_fileds = array_merge( $vendor_wcfm_cod_enabled_fileds, $vendor_billing_fileds ); return $vendor_billing_fileds; }, 50, 2);
Thank You
- December 10, 2018 at 7:08 pm #39555d-n-13Participant
Hi,
Thanks for your most awesome support, the code is causing console error, and wp-admin > appearance > menus don’t show up anymore. https://www.dropbox.com/s/b6pnpj9tpzoigop/cod%20code%20menu%20error.JPG?dl=0
- December 11, 2018 at 6:16 am #39597WCFM ForumMember
Hi,
Are you sure this code causing this?
This code works only for site frontend then how this can break Appearance menu?
If you disable this code that page works perfectly!
Did you checked?Thank you
- December 11, 2018 at 10:06 am #39639d-n-13Participant
Hi,
I don’t know why it is causing the error, but I manually removed the code and the error is gone, I put it back the error is shown again.
- December 11, 2018 at 10:24 am #39642WCFM ForumMember
Hi,
I have just tweak that code a bit, use this one and take a look ->
// Payment Gateway Control add_filter( 'woocommerce_available_payment_gateways', function( $available_gateways ) { global $WCFM; if( !is_admin() && isset( $available_gateways['cod'] ) ) { $cod_available = false; foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $cod_available = false; $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) { $vendor_id = $WCFM->wcfm_vendor_support->wcfm_get_vendor_id_from_product( $_product->get_id() ); if( !$vendor_id || !wcfm_is_vendor( $vendor_id ) ) continue; $vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true ); if( !$vendor_data ) $vendor_data = array(); $is_cod_enabled = isset( $vendor_data['payment']['wcfm_cod_enabled'] ) ? 'yes' : 'no' ; if( $is_cod_enabled == 'yes' ) { $cod_available = true; } } } // Unset COD if( !$cod_available ) unset( $available_gateways['cod'] ); } return $available_gateways; }, 200 ); // Vendor Setting add_filter( 'wcfm_marketplace_settings_fields_billing', function( $vendor_billing_fileds, $vendor_id ) { $vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true ); if( !$vendor_data ) $vendor_data = array(); $is_cod_enabled = isset( $vendor_data['payment']['wcfm_cod_enabled'] ) ? 'yes' : 'no' ; $vendor_wcfm_cod_enabled_fileds = array( 'wcfm_cod_enabled' => array('label' => __('COD Enable for Checkout', 'wc-frontend-manager'), 'name' => 'payment[wcfm_cod_enabled]', 'type' => 'checkbox', 'class' => 'wcfm-checkbox wcfm_ele', 'label_class' => 'wcfm_title wcfm_ele checkbox_title', 'value' => 'yes', 'dfvalue' => $is_cod_enabled ), ); $vendor_billing_fileds = array_merge( $vendor_wcfm_cod_enabled_fileds, $vendor_billing_fileds ); return $vendor_billing_fileds; }, 50, 2);
Thank You
- December 11, 2018 at 10:44 am #39648d-n-13Participant
Now it’s working !
Thanks
- December 11, 2018 at 10:49 am #39649WCFM ForumMember
Great 🙂
- AuthorPosts
- The topic ‘Activate/Deactivate COD by vendors when desired.’ is closed to new replies.