php 活动日历和活动门票加(ET +):如果门票适用于特定类别的活动,则禁用QR码。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 活动日历和活动门票加(ET +):如果门票适用于特定类别的活动,则禁用QR码。相关的知识,希望对你有一定的参考价值。

<?php
/**
 * The Events Calendar & Event Tickets Plus (ET+): Disable QR Code if ticket is for an event in a specific category.
 *
 * Requires ET+ 4.8.2 or later (when this filter was added).
 * Useful for events where there is no physical check-in required, such as an online event or webinar.
 *
 * @link https://gist.github.com/cliffordp/7a819ccf8343cc19a07fd74b9f9aa762 This snippet.
 *
 * @param bool  $enabled The bool that comes from the options.
 * @param array $ticket  The ticket.
 *
 * @return bool
 */
function cliff_disable_qr_if_tickets_event_has_category( $enabled, $ticket ) {
	// Avoid fatals if The Events Calendar is not active or if Ticket is not attached to an Event.
	if (
		! class_exists( 'Tribe__Events__Main' )
		|| empty( $ticket['event_id'] )
	) {
		return $enabled;
	}

	// !!! CHANGE THIS TO THE ONES YOU WANT !!!
	$disabled_event_cat_slugs = [
		'no-qr',
		'online',
		'webinars',
	];

	// Get the Event Categories from this Ticket's Event ID.
	$event_cats = wp_get_post_terms(
		$ticket['event_id'],
		Tribe__Events__Main::TAXONOMY,
		[
			'fields' => 'id=>slug',
		]
	);

	// If ANY of the Event's categories are in the disabled list, do NOT display the QR code.
	foreach ( $event_cats as $id => $slug ) {
		if ( in_array( $slug, $disabled_event_cat_slugs ) ) {
			return false;
		}
	}

	// Otherwise, don't change what it originally was.
	return $enabled;
}

add_filter( 'tribe_tickets_plus_qr_enabled', 'cliff_disable_qr_if_tickets_event_has_category', 10, 2 );

以上是关于php 活动日历和活动门票加(ET +):如果门票适用于特定类别的活动,则禁用QR码。的主要内容,如果未能解决你的问题,请参考以下文章

php 活动门票:在门票电子邮件中显示活动日期和时间。

php 活动门票加:WooCommerce购物车:在每个门票名称前加上适用的活动的帖子标题(如果附加到

php 活动门票加:WooCommerce购物车:在每个门票名称前加上适用的活动的帖子标题(如果附加到

php 活动日历:社区活动门票:在社区活动列表视图上显示“付款选项”按钮。

php 活动日历:社区活动门票:在社区活动列表视图上显示“付款选项”按钮。

php 活动门票加:WooCommerce:强制所有门票“单独出售”。