Deactivate payment method COD for special ticket category

Home Forums Ticket Products Event Tickets Plus Deactivate payment method COD for special ticket category

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1507623
    salilou
    Participant

    Hello,
    I want to deactivate the cash on demand payment method for a special ticket category (id=54).
    There are plugins that check the product category, but that is not set.
    I found a filter (woocommerce_available_payment_gateways) to check if any of the items in a product category, so now I need to extend it to
    1. get the event id from the product (ticket) id and
    2. get an array with the categories of the ticket
    Do you have a code snippet for that?
    Thank you!

    #1507628
    salilou
    Participant

    This is my current code:

    add_filter( ‘woocommerce_available_payment_gateways’, ‘bbloomer_unset_gateway_by_category’ );

    function bbloomer_unset_gateway_by_category( $available_gateways ) {
    global $woocommerce;
    $unset = false;
    $category_ids = array( 54 );
    foreach ( $woocommerce->cart->cart_contents as $key => $values ) {
    $terms = get_the_terms( $values[‘product_id’], ‘product_cat’ );
    foreach ( $terms as $term ) {
    if ( in_array( $term->term_id, $category_ids ) ) {
    $unset = true;
    break;
    }
    }
    }
    if ( $unset == true ) unset( $available_gateways[‘cheque’] );
    return $available_gateways;
    }

    #1509030

    Hi Hannes,

    Thanks so much for reaching out again!

    This seems like an issue to bring up with WooCommerce Support, as the code that you are looking at relates to their plugin.

    Let me know how that goes!

     

    Thanks,

    Jaime

    #1513262
    salilou
    Participant

    Hi Jaime,
    mh, I want to read out the event categories of an event connected to an ticket in the cart.
    This seems more to be a TEC task, doesn’t it?
    If I would ask this to WooCommerce support, they surely will lead me back to you! 🙂
    Greetings,
    Hannes

    #1513595

    Hi Hannes,

    After reviewing your request this essentially looks like a custom development task and so is outside of our stated scope of support.

    With that being said, we’d love to help point you in the right direction.

    I’d recommend starting off by taking a look at our Themer’s Guide, which can show you which templates can be edited and copied in order to attempt the results that you are looking for.

    If you’d prefer not to tackle this customization on your own, we may be able to assist you further. We do need to prioritize support requests from other customers at this time but I’ll certainly flag this with the team and – although we can’t make any promises – if we have time and space to come back and help, we’ll be happy to do so.  Please let us know if you’d like to go this route so that you can be added to this queue.

    In the meantime, if there is any more information you can share (including mocks) that will help us to better understand what you are seeking please do feel free to add them to this ticket.

    If you urgently need help with this, however, you may instead wish to consider working with a suitably skilled developer or designer who can offer the additional level of support you require.

    Let me know if you have any other questions on this topic!

     

    Thanks,

    Jaime

    #1515181
    salilou
    Participant

    Yes, please add me to your queue!

    #1515593

    Great, will do!

    #1516488
    Barry
    Member

    Hi @salilou,

    I’m not completely sure I’m interpreting your request correctly but here is some code – based on your own snippet – that checks to see if any of the cart items are tickets associated with an event in one or more target categories, and uses that as the trigger to unset a payment option:

    https://gist.github.com/barryhughes/c271d3d38ba506deda16d6aa98016034

    Let me know if that helps, or indeed if you have further questions about this 🙂

    #1533119
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Deactivate payment method COD for special ticket category’ is closed to new replies.