• Resolved manalb

    (@manalb)


    Hello everyone,

    We’ve been using WCFM to launch a local food delivery service. Vendors won’t keep inventory, as normaly they can always preprare the meal. But occasionnaly they may need to cancel the order for unavailability.

    I asked WCFM premium support to allow vendor cancellation from front end. I got this snippet of code to add:

    add_filter( 'wcfm_allowed_order_status', function( $status, $order_id ) {
    if( !isset( $status['wc-cancelled'] ) ) { $status['wc-cancelled'] = 'Cancelled'; }
    return $status;
    }, 50, 2 );

    It does the cancellation BUT:
    -It is completely ignored as an email trigger (none of the cancelled order emails set up from woocommerce are sent when vendor cancels)
    -It does not update the order status on WCFM Vendor APP
    -The cancelling capacity does not appear on Vendor APP.

    I’ve already asked WCFM by email, but if someone see this and has a code suggestion please please help, we’re supposed to launch this week 🙁

    Side note: I tried to post this on the WCFM forum but the craziest thing just happens with the site login. When I click Log in, it says I already am, when I go on the forum to post, it says you need to login. It drove me mad.

    Thank you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • thank you bro. bro just to know where did it put code in theme’s function.php or snippet plugin? tks bro

    • This reply was modified 6 years, 4 months ago by shayed.
    Thread Starter manalb

    (@manalb)

    Hi,

    Thanks for getting back. I added it in child theme’s function.php

    ok can your customer also cancel old order? if yes then its not a good idea give that option to your customers. then can cancel any order from past.

    Thread Starter manalb

    (@manalb)

    No customer can’t cancel order. Only vendor can (and admin if a vendor asks them).

    This is common if food delivery, customer can’t cancel a meal that’s being prepared for them already.

    Thanks and I really hope you can suggest something that solves my issue please

    hi bro sorry my mistake. i meant vendor. we should have accept or decline at the first place. the code i use is

    add_filter( 'wcfmmp_order_query', function( $sql ) {
    	$sql = str_replace( ' AND <code>is_trashed</code> = 0', '', $sql );
    	return $sql;
    }, 50 );
    
    add_filter( 'wcfm_allowed_order_status', function( $status, $order_id ) {
    	if( !isset( $status['wc-cancelled'] ) ) { $status['wc-cancelled'] = 'Cancelled'; }
    	return $status;
    }, 50, 2 );

    it does sent email to customer as it is default by woocommerce.

    i am also tring to make a food delivery website. but i think we should go for a proper ready made theme. this plugin needs lots of customisation. have to buy other plugin as well.

    • This reply was modified 6 years, 4 months ago by shayed.
    Thread Starter manalb

    (@manalb)

    Thank you a lot for your response.

    Yes I find this kind of business to be complicated to make with this plugin… I’m kind of dissapointed because I have to launch so soon.

    For the code you sent, I tried it. It does the same job as first code: Give vendor ability to cancel on front end, but nothing shows on the WCFM vendor app. Status doesn’t update 🙁 and mail isn’t sent to customer.

    By the way I have disabled customer notes because they are sent in English to french speaking customers) and I made a custom email from woocommerce>settings>emails with the trigger ‘Cancelled order’. This custom email works when admin cancels order but it doesn’t when vendor cancels.

    Thank you again

    Sorry to bother you, I know this doesn’t solve the problem you are talking about, but this line

    $sql = str_replace( ' AND <code>is_trashed = 0′, ”, $sql );

    Is wrong. I know you probably got from this issue, and my guess is it was valid back then. I replaced it by (wordpress comment format breaks the query, see it here):

    
      $sql = str_replace( 'AND <code>is_trashed</code> = 0', '', $sql );

    To comply with the syntax used in the 5.0.0 version of theese files:

    • /controllers/orders/wcfm-controller-wcfmmarketplace-orders.php
      /controllers/orders/wcfm-controller-wcfmmarketplace-itemized-orders.php
    • This will allow your vendors to see the cancelled orders (if that’s what you want).

    • This reply was modified 6 years, 2 months ago by boloncampana.
    • This reply was modified 6 years, 2 months ago by boloncampana.
    • This reply was modified 6 years, 2 months ago by boloncampana.
    • This reply was modified 6 years, 2 months ago by boloncampana. Reason: No way to use backquotes inside a code. I used pastebin to show the solution
Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Vendor order cancellation from unavailability’ is closed to new replies.