Home › Forums › Ticket Products › Event Tickets Plus › Deactivate payment method COD for special ticket category
- This topic has 7 replies, 3 voices, and was last updated 5 years, 11 months ago by salilou.
-
AuthorPosts
-
April 15, 2018 at 9:18 am #1507623salilouParticipant
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!April 15, 2018 at 9:19 am #1507628salilouParticipantThis 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;
}April 17, 2018 at 5:52 am #1509030Jaime MarchwinskiKeymasterHi 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
April 22, 2018 at 1:28 pm #1513262salilouParticipantHi 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,
HannesApril 23, 2018 at 5:42 am #1513595Jaime MarchwinskiKeymasterHi 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
April 24, 2018 at 11:43 am #1515181salilouParticipantYes, please add me to your queue!
April 25, 2018 at 4:50 am #1515593Jaime MarchwinskiKeymasterGreat, will do!
April 25, 2018 at 10:26 pm #1516488BarryMemberHi @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 🙂
May 17, 2018 at 9:35 am #1533119Support DroidKeymasterHey 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 -
AuthorPosts
- The topic ‘Deactivate payment method COD for special ticket category’ is closed to new replies.