Tribe__Tickets__RSVP::update_sales_and_stock_by_order_status( int $order_id, string $attendee_order_status, int $ticket_id )

Updates the product sales and stock if old and new order stati differ in stock size.


Parameters

$order_id

(int) (Required) The order ID.

$attendee_order_status

(string) (Required) The order status.

$ticket_id

(int) (Required) The ticket ID.


Top ↑

Source

File: src/Tribe/RSVP.php

	public function update_sales_and_stock_by_order_status( $order_id, $attendee_order_status, $ticket_id ) {
		$sales_diff = $this->find_updated_sales_or_stock_value( $order_id, $attendee_order_status, $ticket_id, 'total_sales' );

		// it's all or none here...
		if ( false === $sales_diff ) {
			return false;
		}

		$stock_diff = $this->find_updated_sales_or_stock_value( $order_id, $attendee_order_status, $ticket_id, '_stock' );

		// it's all or none here...
		if ( false === $stock_diff ) {
			return false;
		}

		// these should NEVER be updated separately - if one goes up the other must go down and vice versa
		return update_post_meta( $ticket_id, 'total_sales', $sales_diff ) && update_post_meta( $ticket_id, '_stock', $stock_diff );
	}