php Event Tickets Plus v4.6 +:保存后将所有WooCommerce门票分配到特定产品类别(创建或更新,不会影响旧刻度)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Event Tickets Plus v4.6 +:保存后将所有WooCommerce门票分配到特定产品类别(创建或更新,不会影响旧刻度)相关的知识,希望对你有一定的参考价值。

<?php

/*
 * Event Tickets Plus v4.6+: Assign all WooCommerce Tickets to a specific
 * Product Category upon saving (create or update, won't affect old tickets).
 *
 * !!! YOU NEED TO CHANGE THE CODE TO BE THE PRODUCT CATEGORY ID(S) YOU WANT !!!
 *
 * @link https://gist.github.com/cliffordp/5bffd372db4ebf14482574ce9bb2479c This snippet.
 * @link https://gist.github.com/cliffordp/63abddea69b60f616c1aec1c6bdfc299 Another snippet you might be interested in.
 *
 * @param int    $post_id_attached_to           Post ID of post the ticket is tied to
 * @param Tribe__Tickets__Ticket_Object $ticket Ticket that was just saved
 * @param array  $ticket_raw_data               Ticket data
 * @param string $commerce_engine_class         Commerce engine class
*/
add_action( 'event_tickets_after_save_ticket', 'cliff_all_wootickets_into_a_product_category', 10, 4 );
function cliff_all_wootickets_into_a_product_category( $post_id_attached_to, $ticket, $ticket_raw_data, $commerce_engine_class ) {
	// CHANGE THIS TO BE ONE OR MORE PRODUCT CATEGORIES
	$taxonomy_term_ids = array( 54 );

	if ( 'Tribe__Tickets_Plus__Commerce__WooCommerce__Main' !== $commerce_engine_class ) {
		return;
	}

	wp_set_post_terms( $ticket->ID, $taxonomy_term_ids, 'product_cat', true );
}

以上是关于php Event Tickets Plus v4.6 +:保存后将所有WooCommerce门票分配到特定产品类别(创建或更新,不会影响旧刻度)的主要内容,如果未能解决你的问题,请参考以下文章

php Event Tickets Plus:在WooCommerce订单电子邮件的末尾添加额外的换行符。

php Event Tickets Plus:在WooCommerce订单电子邮件的末尾添加额外的换行符。

php Event Tickets&Plus:将媒体库中的文件附加到所有票证电子邮件。

php Event Tickets&Plus:将媒体库中的文件附加到所有票证电子邮件。

php Event Tickets Plus - 隐藏所有活动的参加者列表。屏幕截图:https://cl.ly/0H0A2I2d1k2B

php Event Tickets Plus - 隐藏所有活动的参加者列表。屏幕截图:https://cl.ly/0H0A2I2d1k2B