api
3 years ago
abstract-wc-legacy-order.php
5 years ago
abstract-wc-legacy-payment-token.php
5 years ago
abstract-wc-legacy-product.php
5 years ago
class-wc-legacy-api.php
4 years ago
class-wc-legacy-cart.php
5 years ago
class-wc-legacy-coupon.php
5 years ago
class-wc-legacy-customer.php
5 years ago
class-wc-legacy-shipping-zone.php
5 years ago
class-wc-legacy-webhook.php
5 years ago
abstract-wc-legacy-payment-token.php
71 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; |
| 4 | } |
| 5 | |
| 6 | /** |
| 7 | * Legacy Payment Tokens. |
| 8 | * Payment Tokens were introduced in 2.6.0 with create and update as methods. |
| 9 | * Major CRUD changes occurred in 3.0, so these were deprecated (save and delete still work). |
| 10 | * This legacy class is for backwards compatibility in case any code called ->read, ->update or ->create |
| 11 | * directly on the object. |
| 12 | * |
| 13 | * @version 3.0.0 |
| 14 | * @package WooCommerce\Classes |
| 15 | * @category Class |
| 16 | * @author WooCommerce |
| 17 | */ |
| 18 | abstract class WC_Legacy_Payment_Token extends WC_Data { |
| 19 | |
| 20 | /** |
| 21 | * Sets the type of this payment token (CC, eCheck, or something else). |
| 22 | * |
| 23 | * @param string Payment Token Type (CC, eCheck) |
| 24 | */ |
| 25 | public function set_type( $type ) { |
| 26 | wc_deprecated_function( 'WC_Payment_Token::set_type', '3.0.0', 'Type cannot be overwritten.' ); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Read a token by ID. |
| 31 | * @deprecated 3.0.0 - Init a token class with an ID. |
| 32 | * |
| 33 | * @param int $token_id |
| 34 | */ |
| 35 | public function read( $token_id ) { |
| 36 | wc_deprecated_function( 'WC_Payment_Token::read', '3.0.0', 'a new token class initialized with an ID.' ); |
| 37 | $this->set_id( $token_id ); |
| 38 | $data_store = WC_Data_Store::load( 'payment-token' ); |
| 39 | $data_store->read( $this ); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Update a token. |
| 44 | * @deprecated 3.0.0 - Use ::save instead. |
| 45 | */ |
| 46 | public function update() { |
| 47 | wc_deprecated_function( 'WC_Payment_Token::update', '3.0.0', 'WC_Payment_Token::save instead.' ); |
| 48 | $data_store = WC_Data_Store::load( 'payment-token' ); |
| 49 | try { |
| 50 | $data_store->update( $this ); |
| 51 | } catch ( Exception $e ) { |
| 52 | return false; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Create a token. |
| 58 | * @deprecated 3.0.0 - Use ::save instead. |
| 59 | */ |
| 60 | public function create() { |
| 61 | wc_deprecated_function( 'WC_Payment_Token::create', '3.0.0', 'WC_Payment_Token::save instead.' ); |
| 62 | $data_store = WC_Data_Store::load( 'payment-token' ); |
| 63 | try { |
| 64 | $data_store->create( $this ); |
| 65 | } catch ( Exception $e ) { |
| 66 | return false; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | } |
| 71 |