WC_Abstract_Order::add_payment_token( WC_Payment_Token $token )

Add a payment token to an order


Description Description


Parameters Parameters

$token

(Required) Payment token object.


Top ↑

Return Return

(boolean|int) The new token ID or false if it failed.


Top ↑

Source Source

File: includes/abstracts/abstract-wc-order.php

	public function add_payment_token( $token ) {
		if ( empty( $token ) || ! ( $token instanceof WC_Payment_Token ) ) {
			return false;
		}

		$token_ids   = $this->data_store->get_payment_token_ids( $this );
		$token_ids[] = $token->get_id();
		$this->data_store->update_payment_token_ids( $this, $token_ids );

		do_action( 'woocommerce_payment_token_added_to_order', $this->get_id(), $token->get_id(), $token, $token_ids );
		return $token->get_id();
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.