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

author author     2022-12-09     496

关键词:

<?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活动门票加:woocommerce购物车:在每个门票名称前加上适用的活动的帖子标题(如果附加到(代码片段)

查看详情

php活动门票加:woocommerce门票:将门票购买限制限制为1。(代码片段)

查看详情

php活动门票加:woocommerce门票:将门票购买限制限制为1。(代码片段)

查看详情

php活动门票加:woocommerce:强制所有门票“单独出售”。(代码片段)

查看详情

php活动门票加:woocommerce:强制所有门票“单独出售”。(代码片段)

查看详情

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

查看详情

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

查看详情

php活动日历:eventbrite门票:自定义iframe的高度。(代码片段)

查看详情

php活动日历:eventbrite门票:自定义iframe的高度。(代码片段)

查看详情

php活动日历+社区活动门票:强制全局股票被检查然后隐藏(以避免取消选中)。(代码片段)

查看详情

php活动日历+社区活动门票:强制全局股票被检查然后隐藏(以避免取消选中)。(代码片段)

查看详情

php活动门票:在门票电子邮件中显示活动日期和时间。(代码片段)

查看详情

php活动门票:在门票电子邮件中显示活动日期和时间。(代码片段)

查看详情

php活动门票加v4.6+-woocommerce门票:保留除了价格最低的wooticket之外的每个活动作为隐藏的可见性。改变lea(代码片段)

查看详情

php活动门票加v4.6+-woocommerce门票:保留除了价格最低的wooticket之外的每个活动作为隐藏的可见性。改变lea(代码片段)

查看详情

php活动门票:设置每张门票允许的最大数量。(代码片段)

查看详情

php活动门票加-当woocommerceticket添加到购物车时,将其他woocommerce产品添加到购物车(代码片段)

查看详情

php活动门票加-当woocommerceticket添加到购物车时,将其他woocommerce产品添加到购物车(代码片段)

查看详情