Файловый менеджер - Редактировать - /home/tuudkjt/globeasy/wp-includes/ID3/legacy.zip
Назад
PK wQ/]>j}v v $ abstract-wc-legacy-payment-token.phpnu ��� <?php if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Legacy Payment Tokens. * Payment Tokens were introduced in 2.6.0 with create and update as methods. * Major CRUD changes occurred in 3.0, so these were deprecated (save and delete still work). * This legacy class is for backwards compatibility in case any code called ->read, ->update or ->create * directly on the object. * * @version 3.0.0 * @package WooCommerce\Classes * @category Class * @author WooCommerce */ abstract class WC_Legacy_Payment_Token extends WC_Data { /** * Sets the type of this payment token (CC, eCheck, or something else). * * @param string Payment Token Type (CC, eCheck) */ public function set_type( $type ) { wc_deprecated_function( 'WC_Payment_Token::set_type', '3.0.0', 'Type cannot be overwritten.' ); } /** * Read a token by ID. * @deprecated 3.0.0 - Init a token class with an ID. * * @param int $token_id */ public function read( $token_id ) { wc_deprecated_function( 'WC_Payment_Token::read', '3.0.0', 'a new token class initialized with an ID.' ); $this->set_id( $token_id ); $data_store = WC_Data_Store::load( 'payment-token' ); $data_store->read( $this ); } /** * Update a token. * @deprecated 3.0.0 - Use ::save instead. */ public function update() { wc_deprecated_function( 'WC_Payment_Token::update', '3.0.0', 'WC_Payment_Token::save instead.' ); $data_store = WC_Data_Store::load( 'payment-token' ); try { $data_store->update( $this ); } catch ( Exception $e ) { return false; } } /** * Create a token. * @deprecated 3.0.0 - Use ::save instead. */ public function create() { wc_deprecated_function( 'WC_Payment_Token::create', '3.0.0', 'WC_Payment_Token::save instead.' ); $data_store = WC_Data_Store::load( 'payment-token' ); try { $data_store->create( $this ); } catch ( Exception $e ) { return false; } } } PK wQ/]̿K�1 �1 class-wc-legacy-cart.phpnu ��� <?php /** * Legacy cart * * Legacy and deprecated functions are here to keep the WC_Cart class clean. * This class will be removed in future versions. * * @version 3.2.0 * @package WooCommerce\Classes * @category Class * @author Automattic */ if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Legacy cart class. */ #[AllowDynamicProperties] abstract class WC_Legacy_Cart { /** * Array of defaults. Not used since 3.2. * * @deprecated 3.2.0 */ public $cart_session_data = array( 'cart_contents_total' => 0, 'total' => 0, 'subtotal' => 0, 'subtotal_ex_tax' => 0, 'tax_total' => 0, 'taxes' => array(), 'shipping_taxes' => array(), 'discount_cart' => 0, 'discount_cart_tax' => 0, 'shipping_total' => 0, 'shipping_tax_total' => 0, 'coupon_discount_amounts' => array(), 'coupon_discount_tax_amounts' => array(), 'fee_total' => 0, 'fees' => array(), ); /** * Contains an array of coupon usage counts after they have been applied. * * @deprecated 3.2.0 * @var array */ public $coupon_applied_count = array(); /** * Map legacy variables. * * @param string $name Property name. * @param mixed $value Value to set. */ public function __isset( $name ) { $legacy_keys = array_merge( array( 'dp', 'prices_include_tax', 'round_at_subtotal', 'cart_contents_total', 'total', 'subtotal', 'subtotal_ex_tax', 'tax_total', 'fee_total', 'discount_cart', 'discount_cart_tax', 'shipping_total', 'shipping_tax_total', 'display_totals_ex_tax', 'display_cart_ex_tax', 'cart_contents_weight', 'cart_contents_count', 'coupons', 'taxes', 'shipping_taxes', 'coupon_discount_amounts', 'coupon_discount_tax_amounts', 'fees', 'tax', 'discount_total', 'tax_display_cart', ), is_array( $this->cart_session_data ) ? array_keys( $this->cart_session_data ) : array() ); if ( in_array( $name, $legacy_keys, true ) ) { return true; } return false; } /** * Magic getters. * * If you add/remove cases here please update $legacy_keys in __isset accordingly. * * @param string $name Property name. * @return mixed */ public function &__get( $name ) { $value = ''; switch ( $name ) { case 'dp' : $value = wc_get_price_decimals(); break; case 'prices_include_tax' : $value = wc_prices_include_tax(); break; case 'round_at_subtotal' : $value = 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ); break; case 'cart_contents_total' : $value = $this->get_cart_contents_total(); break; case 'total' : $value = $this->get_total( 'edit' ); break; case 'subtotal' : $value = $this->get_subtotal() + $this->get_subtotal_tax(); break; case 'subtotal_ex_tax' : $value = $this->get_subtotal(); break; case 'tax_total' : $value = $this->get_fee_tax() + $this->get_cart_contents_tax(); break; case 'fee_total' : $value = $this->get_fee_total(); break; case 'discount_cart' : $value = $this->get_discount_total(); break; case 'discount_cart_tax' : $value = $this->get_discount_tax(); break; case 'shipping_total' : $value = $this->get_shipping_total(); break; case 'shipping_tax_total' : $value = $this->get_shipping_tax(); break; case 'display_totals_ex_tax' : case 'display_cart_ex_tax' : $value = ! $this->display_prices_including_tax(); break; case 'cart_contents_weight' : $value = $this->get_cart_contents_weight(); break; case 'cart_contents_count' : $value = $this->get_cart_contents_count(); break; case 'coupons' : $value = $this->get_coupons(); break; // Arrays returned by reference to allow modification without notices. TODO: Remove in 4.0. case 'taxes' : wc_deprecated_function( 'WC_Cart->taxes', '3.2', sprintf( 'getters (%s) and setters (%s)', 'WC_Cart::get_cart_contents_taxes()', 'WC_Cart::set_cart_contents_taxes()' ) ); $value = &$this->totals[ 'cart_contents_taxes' ]; break; case 'shipping_taxes' : wc_deprecated_function( 'WC_Cart->shipping_taxes', '3.2', sprintf( 'getters (%s) and setters (%s)', 'WC_Cart::get_shipping_taxes()', 'WC_Cart::set_shipping_taxes()' ) ); $value = &$this->totals[ 'shipping_taxes' ]; break; case 'coupon_discount_amounts' : $value = &$this->coupon_discount_totals; break; case 'coupon_discount_tax_amounts' : $value = &$this->coupon_discount_tax_totals; break; case 'fees' : wc_deprecated_function( 'WC_Cart->fees', '3.2', sprintf( 'the fees API (%s)', 'WC_Cart::get_fees' ) ); // Grab fees from the new API. $new_fees = $this->fees_api()->get_fees(); // Add new fees to the legacy prop so it can be adjusted via legacy property. $this->fees = $new_fees; // Return by reference. $value = &$this->fees; break; // Deprecated args. TODO: Remove in 4.0. case 'tax' : wc_deprecated_argument( 'WC_Cart->tax', '2.3', 'Use WC_Tax directly' ); $this->tax = new WC_Tax(); $value = $this->tax; break; case 'discount_total': wc_deprecated_argument( 'WC_Cart->discount_total', '2.3', 'After tax coupons are no longer supported. For more information see: https://woocommerce.wordpress.com/2014/12/upcoming-coupon-changes-in-woocommerce-2-3/' ); $value = 0; break; case 'tax_display_cart': wc_deprecated_argument( 'WC_Cart->tax_display_cart', '4.4', 'Use WC_Cart->get_tax_price_display_mode() instead.' ); $value = $this->get_tax_price_display_mode(); break; } return $value; } /** * Map legacy variables to setters. * * @param string $name Property name. * @param mixed $value Value to set. */ public function __set( $name, $value ) { switch ( $name ) { case 'cart_contents_total' : $this->set_cart_contents_total( $value ); break; case 'total' : $this->set_total( $value ); break; case 'subtotal' : $this->set_subtotal( $value ); break; case 'subtotal_ex_tax' : $this->set_subtotal( $value ); break; case 'tax_total' : $this->set_cart_contents_tax( $value ); $this->set_fee_tax( 0 ); break; case 'taxes' : $this->set_cart_contents_taxes( $value ); break; case 'shipping_taxes' : $this->set_shipping_taxes( $value ); break; case 'fee_total' : $this->set_fee_total( $value ); break; case 'discount_cart' : $this->set_discount_total( $value ); break; case 'discount_cart_tax' : $this->set_discount_tax( $value ); break; case 'shipping_total' : $this->set_shipping_total( $value ); break; case 'shipping_tax_total' : $this->set_shipping_tax( $value ); break; case 'coupon_discount_amounts' : $this->set_coupon_discount_totals( $value ); break; case 'coupon_discount_tax_amounts' : $this->set_coupon_discount_tax_totals( $value ); break; case 'fees' : wc_deprecated_function( 'WC_Cart->fees', '3.2', sprintf( 'the fees API (%s)', 'WC_Cart::add_fee' ) ); $this->fees = $value; break; default : $this->$name = $value; break; } } /** * Methods moved to session class in 3.2.0. */ public function get_cart_from_session() { $this->session->get_cart_from_session(); } public function maybe_set_cart_cookies() { $this->session->maybe_set_cart_cookies(); } public function set_session() { $this->session->set_session(); } public function get_cart_for_session() { return $this->session->get_cart_for_session(); } public function persistent_cart_update() { $this->session->persistent_cart_update(); } public function persistent_cart_destroy() { $this->session->persistent_cart_destroy(); } /** * Get the total of all cart discounts. * * @return float */ public function get_cart_discount_total() { return $this->get_discount_total(); } /** * Get the total of all cart tax discounts (used for discounts on tax inclusive prices). * * @return float */ public function get_cart_discount_tax_total() { return $this->get_discount_tax(); } /** * Renamed for consistency. * * @param string $coupon_code * @return bool True if the coupon is applied, false if it does not exist or cannot be applied. */ public function add_discount( $coupon_code ) { return $this->apply_coupon( $coupon_code ); } /** * Remove taxes. * * @deprecated 3.2.0 Taxes are never calculated if customer is tax except making this function unused. */ public function remove_taxes() { wc_deprecated_function( 'WC_Cart::remove_taxes', '3.2', '' ); } /** * Init. * * @deprecated 3.2.0 Session is loaded via hooks rather than directly. */ public function init() { wc_deprecated_function( 'WC_Cart::init', '3.2', '' ); $this->get_cart_from_session(); } /** * Function to apply discounts to a product and get the discounted price (before tax is applied). * * @deprecated 3.2.0 Calculation and coupon logic is handled in WC_Cart_Totals. * @param mixed $values Cart item. * @param mixed $price Price of item. * @param bool $add_totals Legacy. * @return float price */ public function get_discounted_price( $values, $price, $add_totals = false ) { wc_deprecated_function( 'WC_Cart::get_discounted_price', '3.2', '' ); $cart_item_key = $values['key']; $cart_item = $this->cart_contents[ $cart_item_key ]; return $cart_item['line_total']; } /** * Gets the url to the cart page. * * @deprecated 2.5.0 in favor to wc_get_cart_url() * @return string url to page */ public function get_cart_url() { wc_deprecated_function( 'WC_Cart::get_cart_url', '2.5', 'wc_get_cart_url' ); return wc_get_cart_url(); } /** * Gets the url to the checkout page. * * @deprecated 2.5.0 in favor to wc_get_checkout_url() * @return string url to page */ public function get_checkout_url() { wc_deprecated_function( 'WC_Cart::get_checkout_url', '2.5', 'wc_get_checkout_url' ); return wc_get_checkout_url(); } /** * Sees if we need a shipping address. * * @deprecated 2.5.0 in favor to wc_ship_to_billing_address_only() * @return bool */ public function ship_to_billing_address_only() { wc_deprecated_function( 'WC_Cart::ship_to_billing_address_only', '2.5', 'wc_ship_to_billing_address_only' ); return wc_ship_to_billing_address_only(); } /** * Coupons enabled function. Filterable. * * @deprecated 2.5.0 * @return bool */ public function coupons_enabled() { wc_deprecated_function( 'WC_Legacy_Cart::coupons_enabled', '2.5.0', 'wc_coupons_enabled' ); return wc_coupons_enabled(); } /** * Gets the total (product) discount amount - these are applied before tax. * * @deprecated 2.3.0 Order discounts (after tax) removed in 2.3 so multiple methods for discounts are no longer required. * @return mixed formatted price or false if there are none. */ public function get_discounts_before_tax() { wc_deprecated_function( 'get_discounts_before_tax', '2.3', 'get_total_discount' ); if ( $this->get_cart_discount_total() ) { $discounts_before_tax = wc_price( $this->get_cart_discount_total() ); } else { $discounts_before_tax = false; } return apply_filters( 'woocommerce_cart_discounts_before_tax', $discounts_before_tax, $this ); } /** * Get the total of all order discounts (after tax discounts). * * @deprecated 2.3.0 Order discounts (after tax) removed in 2.3. * @return int */ public function get_order_discount_total() { wc_deprecated_function( 'get_order_discount_total', '2.3' ); return 0; } /** * Function to apply cart discounts after tax. * * @deprecated 2.3.0 Coupons can not be applied after tax. * @param $values * @param $price */ public function apply_cart_discounts_after_tax( $values, $price ) { wc_deprecated_function( 'apply_cart_discounts_after_tax', '2.3' ); } /** * Function to apply product discounts after tax. * * @deprecated 2.3.0 Coupons can not be applied after tax. * * @param $values * @param $price */ public function apply_product_discounts_after_tax( $values, $price ) { wc_deprecated_function( 'apply_product_discounts_after_tax', '2.3' ); } /** * Gets the order discount amount - these are applied after tax. * * @deprecated 2.3.0 Coupons can not be applied after tax. */ public function get_discounts_after_tax() { wc_deprecated_function( 'get_discounts_after_tax', '2.3' ); } } PK wQ/]�k)�b �b abstract-wc-legacy-order.phpnu ��� <?php use Automattic\WooCommerce\Enums\OrderStatus; if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Legacy Abstract Order * * Legacy and deprecated functions are here to keep the WC_Abstract_Order clean. * This class will be removed in future versions. * * @version 3.0.0 * @package WooCommerce\Abstracts * @category Abstract Class * @author WooThemes */ abstract class WC_Abstract_Legacy_Order extends WC_Data { /** * Add coupon code to the order. * @param string|array $code * @param int $discount tax amount. * @param int $discount_tax amount. * @return int order item ID * @throws WC_Data_Exception */ public function add_coupon( $code = array(), $discount = 0, $discount_tax = 0 ) { wc_deprecated_function( 'WC_Order::add_coupon', '3.0', 'a new WC_Order_Item_Coupon object and add to order with WC_Order::add_item()' ); $item = new WC_Order_Item_Coupon(); $item->set_props( array( 'code' => $code, 'discount' => $discount, 'discount_tax' => $discount_tax, 'order_id' => $this->get_id(), ) ); $item->save(); $this->add_item( $item ); wc_do_deprecated_action( 'woocommerce_order_add_coupon', array( $this->get_id(), $item->get_id(), $code, $discount, $discount_tax ), '3.0', 'woocommerce_new_order_item action instead.' ); return $item->get_id(); } /** * Add a tax row to the order. * @param int $tax_rate_id * @param int $tax_amount amount of tax. * @param int $shipping_tax_amount shipping amount. * @return int order item ID * @throws WC_Data_Exception */ public function add_tax( $tax_rate_id, $tax_amount = 0, $shipping_tax_amount = 0 ) { wc_deprecated_function( 'WC_Order::add_tax', '3.0', 'a new WC_Order_Item_Tax object and add to order with WC_Order::add_item()' ); $item = new WC_Order_Item_Tax(); $item->set_props( array( 'rate_id' => $tax_rate_id, 'tax_total' => $tax_amount, 'shipping_tax_total' => $shipping_tax_amount, ) ); $item->set_rate( $tax_rate_id ); $item->set_order_id( $this->get_id() ); $item->save(); $this->add_item( $item ); wc_do_deprecated_action( 'woocommerce_order_add_tax', array( $this->get_id(), $item->get_id(), $tax_rate_id, $tax_amount, $shipping_tax_amount ), '3.0', 'woocommerce_new_order_item action instead.' ); return $item->get_id(); } /** * Add a shipping row to the order. * @param WC_Shipping_Rate shipping_rate * @return int order item ID * @throws WC_Data_Exception */ public function add_shipping( $shipping_rate ) { wc_deprecated_function( 'WC_Order::add_shipping', '3.0', 'a new WC_Order_Item_Shipping object and add to order with WC_Order::add_item()' ); $item = new WC_Order_Item_Shipping(); $item->set_props( array( 'method_title' => $shipping_rate->label, 'method_id' => $shipping_rate->id, 'total' => wc_format_decimal( $shipping_rate->cost ), 'taxes' => $shipping_rate->taxes, 'order_id' => $this->get_id(), ) ); foreach ( $shipping_rate->get_meta_data() as $key => $value ) { $item->add_meta_data( $key, $value, true ); } $item->save(); $this->add_item( $item ); wc_do_deprecated_action( 'woocommerce_order_add_shipping', array( $this->get_id(), $item->get_id(), $shipping_rate ), '3.0', 'woocommerce_new_order_item action instead.' ); return $item->get_id(); } /** * Add a fee to the order. * Order must be saved prior to adding items. * * Fee is an amount of money charged for a particular piece of work * or for a particular right or service, and not supposed to be negative. * * @throws WC_Data_Exception * @param object $fee Fee data. * @return int Updated order item ID. */ public function add_fee( $fee ) { wc_deprecated_function( 'WC_Order::add_fee', '3.0', 'a new WC_Order_Item_Fee object and add to order with WC_Order::add_item()' ); $item = new WC_Order_Item_Fee(); $item->set_props( array( 'name' => $fee->name, 'tax_class' => $fee->taxable ? $fee->tax_class : 0, 'total' => $fee->amount, 'total_tax' => $fee->tax, 'taxes' => array( 'total' => $fee->tax_data, ), 'order_id' => $this->get_id(), ) ); $item->save(); $this->add_item( $item ); wc_do_deprecated_action( 'woocommerce_order_add_fee', array( $this->get_id(), $item->get_id(), $fee ), '3.0', 'woocommerce_new_order_item action instead.' ); return $item->get_id(); } /** * Update a line item for the order. * * Note this does not update order totals. * * @param object|int $item order item ID or item object. * @param WC_Product $product * @param array $args data to update. * @return int updated order item ID * @throws WC_Data_Exception */ public function update_product( $item, $product, $args ) { wc_deprecated_function( 'WC_Order::update_product', '3.0', 'an interaction with the WC_Order_Item_Product class' ); if ( is_numeric( $item ) ) { $item = $this->get_item( $item ); } if ( ! is_object( $item ) || ! $item->is_type( 'line_item' ) ) { return false; } if ( ! $this->get_id() ) { $this->save(); // Order must exist } // BW compatibility with old args if ( isset( $args['totals'] ) ) { foreach ( $args['totals'] as $key => $value ) { if ( 'tax' === $key ) { $args['total_tax'] = $value; } elseif ( 'tax_data' === $key ) { $args['taxes'] = $value; } else { $args[ $key ] = $value; } } } // Handle qty if set. if ( isset( $args['qty'] ) ) { if ( $product->backorders_require_notification() && $product->is_on_backorder( $args['qty'] ) ) { $item->add_meta_data( apply_filters( 'woocommerce_backordered_item_meta_name', __( 'Backordered', 'woocommerce' ), $item ), $args['qty'] - max( 0, $product->get_stock_quantity() ), true ); } $args['subtotal'] = $args['subtotal'] ? $args['subtotal'] : wc_get_price_excluding_tax( $product, array( 'qty' => $args['qty'] ) ); $args['total'] = $args['total'] ? $args['total'] : wc_get_price_excluding_tax( $product, array( 'qty' => $args['qty'] ) ); } $item->set_order_id( $this->get_id() ); $item->set_props( $args ); $item->save(); do_action( 'woocommerce_order_edit_product', $this->get_id(), $item->get_id(), $args, $product ); return $item->get_id(); } /** * Update coupon for order. Note this does not update order totals. * @param object|int $item * @param array $args * @return int updated order item ID * @throws WC_Data_Exception */ public function update_coupon( $item, $args ) { wc_deprecated_function( 'WC_Order::update_coupon', '3.0', 'an interaction with the WC_Order_Item_Coupon class' ); if ( is_numeric( $item ) ) { $item = $this->get_item( $item ); } if ( ! is_object( $item ) || ! $item->is_type( 'coupon' ) ) { return false; } if ( ! $this->get_id() ) { $this->save(); // Order must exist } // BW compatibility for old args if ( isset( $args['discount_amount'] ) ) { $args['discount'] = $args['discount_amount']; } if ( isset( $args['discount_amount_tax'] ) ) { $args['discount_tax'] = $args['discount_amount_tax']; } $item->set_order_id( $this->get_id() ); $item->set_props( $args ); $item->save(); do_action( 'woocommerce_order_update_coupon', $this->get_id(), $item->get_id(), $args ); return $item->get_id(); } /** * Update shipping method for order. * * Note this does not update the order total. * * @param object|int $item * @param array $args * @return int updated order item ID * @throws WC_Data_Exception */ public function update_shipping( $item, $args ) { wc_deprecated_function( 'WC_Order::update_shipping', '3.0', 'an interaction with the WC_Order_Item_Shipping class' ); if ( is_numeric( $item ) ) { $item = $this->get_item( $item ); } if ( ! is_object( $item ) || ! $item->is_type( 'shipping' ) ) { return false; } if ( ! $this->get_id() ) { $this->save(); // Order must exist } // BW compatibility for old args if ( isset( $args['cost'] ) ) { $args['total'] = $args['cost']; } $item->set_order_id( $this->get_id() ); $item->set_props( $args ); $item->save(); $this->calculate_shipping(); do_action( 'woocommerce_order_update_shipping', $this->get_id(), $item->get_id(), $args ); return $item->get_id(); } /** * Update fee for order. * * Note this does not update order totals. * * @param object|int $item * @param array $args * @return int updated order item ID * @throws WC_Data_Exception */ public function update_fee( $item, $args ) { wc_deprecated_function( 'WC_Order::update_fee', '3.0', 'an interaction with the WC_Order_Item_Fee class' ); if ( is_numeric( $item ) ) { $item = $this->get_item( $item ); } if ( ! is_object( $item ) || ! $item->is_type( 'fee' ) ) { return false; } if ( ! $this->get_id() ) { $this->save(); // Order must exist } $item->set_order_id( $this->get_id() ); $item->set_props( $args ); $item->save(); do_action( 'woocommerce_order_update_fee', $this->get_id(), $item->get_id(), $args ); return $item->get_id(); } /** * Update tax line on order. * Note this does not update order totals. * * @since 3.0 * @param object|int $item * @param array $args * @return int updated order item ID * @throws WC_Data_Exception */ public function update_tax( $item, $args ) { wc_deprecated_function( 'WC_Order::update_tax', '3.0', 'an interaction with the WC_Order_Item_Tax class' ); if ( is_numeric( $item ) ) { $item = $this->get_item( $item ); } if ( ! is_object( $item ) || ! $item->is_type( 'tax' ) ) { return false; } if ( ! $this->get_id() ) { $this->save(); // Order must exist } $item->set_order_id( $this->get_id() ); $item->set_props( $args ); $item->save(); do_action( 'woocommerce_order_update_tax', $this->get_id(), $item->get_id(), $args ); return $item->get_id(); } /** * Get a product (either product or variation). * @deprecated 4.4.0 * @param object $item * @return WC_Product|bool */ public function get_product_from_item( $item ) { wc_deprecated_function( 'WC_Abstract_Legacy_Order::get_product_from_item', '4.4.0', '$item->get_product()' ); if ( is_callable( array( $item, 'get_product' ) ) ) { $product = $item->get_product(); } else { $product = false; } return apply_filters( 'woocommerce_get_product_from_item', $product, $item, $this ); } /** * Set the customer address. * @param array $address Address data. * @param string $type Type of address; 'billing' or 'shipping'. */ public function set_address( $address, $type = 'billing' ) { foreach ( $address as $key => $value ) { update_post_meta( $this->get_id(), "_{$type}_" . $key, $value ); if ( is_callable( array( $this, "set_{$type}_{$key}" ) ) ) { $this->{"set_{$type}_{$key}"}( $value ); } } } /** * Set an order total. * @param float $amount * @param string $total_type * @return bool */ public function legacy_set_total( $amount, $total_type = 'total' ) { if ( ! in_array( $total_type, array( 'shipping', 'tax', 'shipping_tax', 'total', 'cart_discount', 'cart_discount_tax' ) ) ) { return false; } switch ( $total_type ) { case 'total' : $amount = wc_format_decimal( $amount, wc_get_price_decimals() ); $this->set_total( $amount ); update_post_meta( $this->get_id(), '_order_total', $amount ); break; case 'cart_discount' : $amount = wc_format_decimal( $amount ); $this->set_discount_total( $amount ); update_post_meta( $this->get_id(), '_cart_discount', $amount ); break; case 'cart_discount_tax' : $amount = wc_format_decimal( $amount ); $this->set_discount_tax( $amount ); update_post_meta( $this->get_id(), '_cart_discount_tax', $amount ); break; case 'shipping' : $amount = wc_format_decimal( $amount ); $this->set_shipping_total( $amount ); update_post_meta( $this->get_id(), '_order_shipping', $amount ); break; case 'shipping_tax' : $amount = wc_format_decimal( $amount ); $this->set_shipping_tax( $amount ); update_post_meta( $this->get_id(), '_order_shipping_tax', $amount ); break; case 'tax' : $amount = wc_format_decimal( $amount ); $this->set_cart_tax( $amount ); update_post_meta( $this->get_id(), '_order_tax', $amount ); break; } return true; } /** * Magic __isset method for backwards compatibility. Handles legacy properties which could be accessed directly in the past. * * @param string $key * @return bool */ public function __isset( $key ) { $legacy_props = array( 'completed_date', 'id', 'order_type', 'post', 'status', 'post_status', 'customer_note', 'customer_message', 'user_id', 'customer_user', 'prices_include_tax', 'tax_display_cart', 'display_totals_ex_tax', 'display_cart_ex_tax', 'order_date', 'modified_date', 'cart_discount', 'cart_discount_tax', 'order_shipping', 'order_shipping_tax', 'order_total', 'order_tax', 'billing_first_name', 'billing_last_name', 'billing_company', 'billing_address_1', 'billing_address_2', 'billing_city', 'billing_state', 'billing_postcode', 'billing_country', 'billing_phone', 'billing_email', 'shipping_first_name', 'shipping_last_name', 'shipping_company', 'shipping_address_1', 'shipping_address_2', 'shipping_city', 'shipping_state', 'shipping_postcode', 'shipping_country', 'customer_ip_address', 'customer_user_agent', 'payment_method_title', 'payment_method', 'order_currency' ); return $this->get_id() ? ( in_array( $key, $legacy_props ) || metadata_exists( 'post', $this->get_id(), '_' . $key ) ) : false; } /** * Magic __get method for backwards compatibility. * * @param string $key * @return mixed */ public function __get( $key ) { wc_doing_it_wrong( $key, 'Order properties should not be accessed directly.', '3.0' ); if ( 'completed_date' === $key ) { return $this->get_date_completed() ? gmdate( 'Y-m-d H:i:s', $this->get_date_completed()->getOffsetTimestamp() ) : ''; } elseif ( 'paid_date' === $key ) { return $this->get_date_paid() ? gmdate( 'Y-m-d H:i:s', $this->get_date_paid()->getOffsetTimestamp() ) : ''; } elseif ( 'modified_date' === $key ) { return $this->get_date_modified() ? gmdate( 'Y-m-d H:i:s', $this->get_date_modified()->getOffsetTimestamp() ) : ''; } elseif ( 'order_date' === $key ) { return $this->get_date_created() ? gmdate( 'Y-m-d H:i:s', $this->get_date_created()->getOffsetTimestamp() ) : ''; } elseif ( 'id' === $key ) { return $this->get_id(); } elseif ( 'post' === $key ) { return get_post( $this->get_id() ); } elseif ( 'status' === $key ) { return $this->get_status(); } elseif ( 'post_status' === $key ) { return get_post_status( $this->get_id() ); } elseif ( 'customer_message' === $key || 'customer_note' === $key ) { return $this->get_customer_note(); } elseif ( in_array( $key, array( 'user_id', 'customer_user' ) ) ) { return $this->get_customer_id(); } elseif ( 'tax_display_cart' === $key ) { return get_option( 'woocommerce_tax_display_cart' ); } elseif ( 'display_totals_ex_tax' === $key ) { return 'excl' === get_option( 'woocommerce_tax_display_cart' ); } elseif ( 'display_cart_ex_tax' === $key ) { return 'excl' === get_option( 'woocommerce_tax_display_cart' ); } elseif ( 'cart_discount' === $key ) { return $this->get_total_discount(); } elseif ( 'cart_discount_tax' === $key ) { return $this->get_discount_tax(); } elseif ( 'order_tax' === $key ) { return $this->get_cart_tax(); } elseif ( 'order_shipping_tax' === $key ) { return $this->get_shipping_tax(); } elseif ( 'order_shipping' === $key ) { return $this->get_shipping_total(); } elseif ( 'order_total' === $key ) { return $this->get_total(); } elseif ( 'order_type' === $key ) { return $this->get_type(); } elseif ( 'order_currency' === $key ) { return $this->get_currency(); } elseif ( 'order_version' === $key ) { return $this->get_version(); } elseif ( is_callable( array( $this, "get_{$key}" ) ) ) { return $this->{"get_{$key}"}(); } else { return get_post_meta( $this->get_id(), '_' . $key, true ); } } /** * has_meta function for order items. This is different to the WC_Data * version and should be removed in future versions. * * @deprecated 3.0 * * @param int $order_item_id * * @return array of meta data. */ public function has_meta( $order_item_id ) { global $wpdb; wc_deprecated_function( 'WC_Order::has_meta( $order_item_id )', '3.0', 'WC_Order_item::get_meta_data' ); return $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value, meta_id, order_item_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id = %d ORDER BY meta_id", absint( $order_item_id ) ), ARRAY_A ); } /** * Display meta data belonging to an item. * @param array $item */ public function display_item_meta( $item ) { wc_deprecated_function( 'WC_Order::display_item_meta', '3.0', 'wc_display_item_meta' ); $product = $item->get_product(); $item_meta = new WC_Order_Item_Meta( $item, $product ); $item_meta->display(); } /** * Display download links for an order item. * @param array $item */ public function display_item_downloads( $item ) { wc_deprecated_function( 'WC_Order::display_item_downloads', '3.0', 'wc_display_item_downloads' ); $product = $item->get_product(); if ( $product && $product->exists() && $product->is_downloadable() && $this->is_download_permitted() ) { $download_files = $this->get_item_downloads( $item ); $i = 0; $links = array(); foreach ( $download_files as $download_id => $file ) { $i++; /* translators: 1: current item count */ $prefix = count( $download_files ) > 1 ? sprintf( __( 'Download %d', 'woocommerce' ), $i ) : __( 'Download', 'woocommerce' ); $links[] = '<small class="download-url">' . esc_html( $prefix ) . ': <a href="' . esc_url( $file['download_url'] ) . '" target="_blank">' . esc_html( $file['name'] ) . '</a></small>' . "\n"; } echo '<br/>' . implode( '<br/>', $links ); } } /** * Get the Download URL. * * @param int $product_id * @param int $download_id * @return string */ public function get_download_url( $product_id, $download_id ) { wc_deprecated_function( 'WC_Order::get_download_url', '3.0', 'WC_Order_Item_Product::get_item_download_url' ); return add_query_arg( array( 'download_file' => $product_id, 'order' => $this->get_order_key(), 'email' => urlencode( $this->get_billing_email() ), 'key' => $download_id, ), trailingslashit( home_url() ) ); } /** * Get the downloadable files for an item in this order. * * @param array $item * @return array */ public function get_item_downloads( $item ) { wc_deprecated_function( 'WC_Order::get_item_downloads', '3.0', 'WC_Order_Item_Product::get_item_downloads' ); if ( ! $item instanceof WC_Order_Item ) { if ( ! empty( $item['variation_id'] ) ) { $product_id = $item['variation_id']; } elseif ( ! empty( $item['product_id'] ) ) { $product_id = $item['product_id']; } else { return array(); } // Create a 'virtual' order item to allow retrieving item downloads when // an array of product_id is passed instead of actual order item. $item = new WC_Order_Item_Product(); $item->set_product( wc_get_product( $product_id ) ); $item->set_order_id( $this->get_id() ); } return $item->get_item_downloads(); } /** * Gets shipping total. Alias of WC_Order::get_shipping_total(). * @deprecated 3.0.0 since this is an alias only. * @return float */ public function get_total_shipping() { return $this->get_shipping_total(); } /** * Get order item meta. * @deprecated 3.0.0 * @param mixed $order_item_id * @param string $key (default: '') * @param bool $single (default: false) * @return array|string */ public function get_item_meta( $order_item_id, $key = '', $single = false ) { wc_deprecated_function( 'WC_Order::get_item_meta', '3.0', 'wc_get_order_item_meta' ); return get_metadata( 'order_item', $order_item_id, $key, $single ); } /** * Get all item meta data in array format in the order it was saved. Does not group meta by key like get_item_meta(). * * @param mixed $order_item_id * @return array of objects */ public function get_item_meta_array( $order_item_id ) { wc_deprecated_function( 'WC_Order::get_item_meta_array', '3.0', 'WC_Order_Item::get_meta_data() (note the format has changed)' ); $item = $this->get_item( $order_item_id ); $meta_data = $item->get_meta_data(); $item_meta_array = array(); foreach ( $meta_data as $meta ) { $item_meta_array[ $meta->id ] = $meta; } return $item_meta_array; } /** * Get coupon codes only. * * @deprecated 3.7.0 - Replaced with better named method to reflect the actual data being returned. * @return array */ public function get_used_coupons() { wc_deprecated_function( 'get_used_coupons', '3.7', 'WC_Abstract_Order::get_coupon_codes' ); return $this->get_coupon_codes(); } /** * Expand item meta into the $item array. * @deprecated 3.0.0 Item meta no longer expanded due to new order item * classes. This function now does nothing to avoid data breakage. * @param array $item before expansion. * @return array */ public function expand_item_meta( $item ) { wc_deprecated_function( 'WC_Order::expand_item_meta', '3.0' ); return $item; } /** * Load the order object. Called from the constructor. * @deprecated 3.0.0 Logic moved to constructor * @param int|object|WC_Order $order Order to init. */ protected function init( $order ) { wc_deprecated_function( 'WC_Order::init', '3.0', 'Logic moved to constructor' ); if ( is_numeric( $order ) ) { $this->set_id( $order ); } elseif ( $order instanceof WC_Order ) { $this->set_id( absint( $order->get_id() ) ); } elseif ( isset( $order->ID ) ) { $this->set_id( absint( $order->ID ) ); } $this->set_object_read( false ); $this->data_store->read( $this ); } /** * Gets an order from the database. * @deprecated 3.0 * @param int $id (default: 0). * @return bool */ public function get_order( $id = 0 ) { wc_deprecated_function( 'WC_Order::get_order', '3.0' ); if ( ! $id ) { return false; } $result = get_post( $id ); if ( $result ) { $this->populate( $result ); return true; } return false; } /** * Populates an order from the loaded post data. * @deprecated 3.0 * @param mixed $result */ public function populate( $result ) { wc_deprecated_function( 'WC_Order::populate', '3.0' ); $this->set_id( $result->ID ); $this->set_object_read( false ); $this->data_store->read( $this ); } /** * Cancel the order and restore the cart (before payment). * @deprecated 3.0.0 Moved to event handler. * @param string $note (default: '') Optional note to add. */ public function cancel_order( $note = '' ) { wc_deprecated_function( 'WC_Order::cancel_order', '3.0', 'WC_Order::update_status' ); WC()->session->set( 'order_awaiting_payment', false ); $this->update_status( OrderStatus::CANCELLED, $note ); } /** * Record sales. * @deprecated 3.0.0 */ public function record_product_sales() { wc_deprecated_function( 'WC_Order::record_product_sales', '3.0', 'wc_update_total_sales_counts' ); wc_update_total_sales_counts( $this->get_id() ); } /** * Increase applied coupon counts. * @deprecated 3.0.0 */ public function increase_coupon_usage_counts() { wc_deprecated_function( 'WC_Order::increase_coupon_usage_counts', '3.0', 'wc_update_coupon_usage_counts' ); wc_update_coupon_usage_counts( $this->get_id() ); } /** * Decrease applied coupon counts. * @deprecated 3.0.0 */ public function decrease_coupon_usage_counts() { wc_deprecated_function( 'WC_Order::decrease_coupon_usage_counts', '3.0', 'wc_update_coupon_usage_counts' ); wc_update_coupon_usage_counts( $this->get_id() ); } /** * Reduce stock levels for all line items in the order. * @deprecated 3.0.0 */ public function reduce_order_stock() { wc_deprecated_function( 'WC_Order::reduce_order_stock', '3.0', 'wc_reduce_stock_levels' ); wc_reduce_stock_levels( $this->get_id() ); } /** * Send the stock notifications. * @deprecated 3.0.0 No longer needs to be called directly. * * @param $product * @param $new_stock * @param $qty_ordered */ public function send_stock_notifications( $product, $new_stock, $qty_ordered ) { wc_deprecated_function( 'WC_Order::send_stock_notifications', '3.0' ); } /** * Output items for display in html emails. * @deprecated 3.0.0 Moved to template functions. * @param array $args Items args. * @return string */ public function email_order_items_table( $args = array() ) { wc_deprecated_function( 'WC_Order::email_order_items_table', '3.0', 'wc_get_email_order_items' ); return wc_get_email_order_items( $this, $args ); } /** * Get currency. * @deprecated 3.0.0 */ public function get_order_currency() { wc_deprecated_function( 'WC_Order::get_order_currency', '3.0', 'WC_Order::get_currency' ); return apply_filters( 'woocommerce_get_order_currency', $this->get_currency(), $this ); } } PK wQ/]~5�� � class-wc-legacy-coupon.phpnu ��� <?php if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Legacy Coupon. * * Legacy and deprecated functions are here to keep the WC_Legacy_Coupon class clean. * This class will be removed in future versions. * * @class WC_Legacy_Coupon * @version 3.0.0 * @package WooCommerce\Classes * @category Class * @author WooThemes */ abstract class WC_Legacy_Coupon extends WC_Data { /** * Magic __isset method for backwards compatibility. Legacy properties which could be accessed directly in the past. * @param string $key * @return bool */ public function __isset( $key ) { $legacy_keys = array( 'id', 'exists', 'coupon_custom_fields', 'type', 'discount_type', 'amount', 'coupon_amount', 'code', 'individual_use', 'product_ids', 'exclude_product_ids', 'usage_limit', 'usage_limit_per_user', 'limit_usage_to_x_items', 'usage_count', 'expiry_date', 'product_categories', 'exclude_product_categories', 'minimum_amount', 'maximum_amount', 'customer_email', ); if ( in_array( $key, $legacy_keys ) ) { return true; } return false; } /** * Magic __get method for backwards compatibility. Maps legacy vars to new getters. * @param string $key * @return mixed */ public function __get( $key ) { wc_doing_it_wrong( $key, 'Coupon properties should not be accessed directly.', '3.0' ); switch ( $key ) { case 'id' : $value = $this->get_id(); break; case 'exists' : $value = $this->get_id() > 0; break; case 'coupon_custom_fields' : $legacy_custom_fields = array(); $custom_fields = $this->get_id() ? $this->get_meta_data() : array(); if ( ! empty( $custom_fields ) ) { foreach ( $custom_fields as $cf_value ) { // legacy only supports 1 key $legacy_custom_fields[ $cf_value->key ][0] = $cf_value->value; } } $value = $legacy_custom_fields; break; case 'type' : case 'discount_type' : $value = $this->get_discount_type(); break; case 'amount' : case 'coupon_amount' : $value = $this->get_amount(); break; case 'code' : $value = $this->get_code(); break; case 'individual_use' : $value = ( true === $this->get_individual_use() ) ? 'yes' : 'no'; break; case 'product_ids' : $value = $this->get_product_ids(); break; case 'exclude_product_ids' : $value = $this->get_excluded_product_ids(); break; case 'usage_limit' : $value = $this->get_usage_limit(); break; case 'usage_limit_per_user' : $value = $this->get_usage_limit_per_user(); break; case 'limit_usage_to_x_items' : $value = $this->get_limit_usage_to_x_items(); break; case 'usage_count' : $value = $this->get_usage_count(); break; case 'expiry_date' : $value = ( $this->get_date_expires() ? $this->get_date_expires()->date( 'Y-m-d' ) : '' ); break; case 'product_categories' : $value = $this->get_product_categories(); break; case 'exclude_product_categories' : $value = $this->get_excluded_product_categories(); break; case 'minimum_amount' : $value = $this->get_minimum_amount(); break; case 'maximum_amount' : $value = $this->get_maximum_amount(); break; case 'customer_email' : $value = $this->get_email_restrictions(); break; default : $value = ''; break; } return $value; } /** * Format loaded data as array. * @param string|array $array * @return array */ public function format_array( $array ) { wc_deprecated_function( 'WC_Coupon::format_array', '3.0' ); if ( ! is_array( $array ) ) { if ( is_serialized( $array ) ) { $array = maybe_unserialize( $array ); } else { $array = explode( ',', $array ); } } return array_filter( array_map( 'trim', array_map( 'strtolower', $array ) ) ); } /** * Check if coupon needs applying before tax. * * @return bool */ public function apply_before_tax() { wc_deprecated_function( 'WC_Coupon::apply_before_tax', '3.0' ); return true; } /** * Check if a coupon enables free shipping. * * @return bool */ public function enable_free_shipping() { wc_deprecated_function( 'WC_Coupon::enable_free_shipping', '3.0', 'WC_Coupon::get_free_shipping' ); return $this->get_free_shipping(); } /** * Check if a coupon excludes sale items. * * @return bool */ public function exclude_sale_items() { wc_deprecated_function( 'WC_Coupon::exclude_sale_items', '3.0', 'WC_Coupon::get_exclude_sale_items' ); return $this->get_exclude_sale_items(); } /** * Increase usage count for current coupon. * * @param string $used_by Either user ID or billing email */ public function inc_usage_count( $used_by = '' ) { $this->increase_usage_count( $used_by ); } /** * Decrease usage count for current coupon. * * @param string $used_by Either user ID or billing email */ public function dcr_usage_count( $used_by = '' ) { $this->decrease_usage_count( $used_by ); } } PK wQ/]�{<� � class-wc-legacy-customer.phpnu ��� <?php if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Legacy Customer. * * @version 3.0.0 * @package WooCommerce\Classes * @category Class * @author WooThemes */ abstract class WC_Legacy_Customer extends WC_Data { /** * __isset legacy. * @param mixed $key * @return bool */ public function __isset( $key ) { $legacy_keys = array( 'id', 'country', 'state', 'postcode', 'city', 'address_1', 'address', 'address_2', 'shipping_country', 'shipping_state', 'shipping_postcode', 'shipping_city', 'shipping_address_1', 'shipping_address', 'shipping_address_2', 'is_vat_exempt', 'calculated_shipping', ); $key = $this->filter_legacy_key( $key ); return in_array( $key, $legacy_keys ); } /** * __get function. * @param string $key * @return string */ public function __get( $key ) { wc_doing_it_wrong( $key, 'Customer properties should not be accessed directly.', '3.0' ); $key = $this->filter_legacy_key( $key ); if ( in_array( $key, array( 'country', 'state', 'postcode', 'city', 'address_1', 'address', 'address_2' ) ) ) { $key = 'billing_' . $key; } return is_callable( array( $this, "get_{$key}" ) ) ? $this->{"get_{$key}"}() : ''; } /** * __set function. * * @param string $key * @param mixed $value */ public function __set( $key, $value ) { wc_doing_it_wrong( $key, 'Customer properties should not be set directly.', '3.0' ); $key = $this->filter_legacy_key( $key ); if ( is_callable( array( $this, "set_{$key}" ) ) ) { $this->{"set_{$key}"}( $value ); } } /** * Address and shipping_address are aliased, so we want to get the 'real' key name. * For all other keys, we can just return it. * @since 3.0.0 * @param string $key * @return string */ private function filter_legacy_key( $key ) { if ( 'address' === $key ) { $key = 'address_1'; } if ( 'shipping_address' === $key ) { $key = 'shipping_address_1'; } return $key; } /** * Sets session data for the location. * * @param string $country * @param string $state * @param string $postcode (default: '') * @param string $city (default: '') */ public function set_location( $country, $state, $postcode = '', $city = '' ) { $this->set_billing_location( $country, $state, $postcode, $city ); $this->set_shipping_location( $country, $state, $postcode, $city ); } /** * Get default country for a customer. * @return string */ public function get_default_country() { wc_deprecated_function( 'WC_Customer::get_default_country', '3.0', 'wc_get_customer_default_location' ); $default = wc_get_customer_default_location(); return $default['country']; } /** * Get default state for a customer. * @return string */ public function get_default_state() { wc_deprecated_function( 'WC_Customer::get_default_state', '3.0', 'wc_get_customer_default_location' ); $default = wc_get_customer_default_location(); return $default['state']; } /** * Set customer address to match shop base address. */ public function set_to_base() { wc_deprecated_function( 'WC_Customer::set_to_base', '3.0', 'WC_Customer::set_billing_address_to_base' ); $this->set_billing_address_to_base(); } /** * Set customer shipping address to base address. */ public function set_shipping_to_base() { wc_deprecated_function( 'WC_Customer::set_shipping_to_base', '3.0', 'WC_Customer::set_shipping_address_to_base' ); $this->set_shipping_address_to_base(); } /** * Calculated shipping. * @param boolean $calculated */ public function calculated_shipping( $calculated = true ) { wc_deprecated_function( 'WC_Customer::calculated_shipping', '3.0', 'WC_Customer::set_calculated_shipping' ); $this->set_calculated_shipping( $calculated ); } /** * Set default data for a customer. */ public function set_default_data() { wc_deprecated_function( 'WC_Customer::set_default_data', '3.0' ); } /** * Save data function. */ public function save_data() { $this->save(); } /** * Is the user a paying customer? * * @param int $user_id * * @return bool */ function is_paying_customer( $user_id = '' ) { wc_deprecated_function( 'WC_Customer::is_paying_customer', '3.0', 'WC_Customer::get_is_paying_customer' ); if ( ! empty( $user_id ) ) { $user_id = get_current_user_id(); } return '1' === get_user_meta( $user_id, 'paying_customer', true ); } /** * Legacy get address. */ function get_address() { wc_deprecated_function( 'WC_Customer::get_address', '3.0', 'WC_Customer::get_billing_address_1' ); return $this->get_billing_address_1(); } /** * Legacy get address 2. */ function get_address_2() { wc_deprecated_function( 'WC_Customer::get_address_2', '3.0', 'WC_Customer::get_billing_address_2' ); return $this->get_billing_address_2(); } /** * Legacy get country. */ function get_country() { wc_deprecated_function( 'WC_Customer::get_country', '3.0', 'WC_Customer::get_billing_country' ); return $this->get_billing_country(); } /** * Legacy get state. */ function get_state() { wc_deprecated_function( 'WC_Customer::get_state', '3.0', 'WC_Customer::get_billing_state' ); return $this->get_billing_state(); } /** * Legacy get postcode. */ function get_postcode() { wc_deprecated_function( 'WC_Customer::get_postcode', '3.0', 'WC_Customer::get_billing_postcode' ); return $this->get_billing_postcode(); } /** * Legacy get city. */ function get_city() { wc_deprecated_function( 'WC_Customer::get_city', '3.0', 'WC_Customer::get_billing_city' ); return $this->get_billing_city(); } /** * Legacy set country. * * @param string $country */ function set_country( $country ) { wc_deprecated_function( 'WC_Customer::set_country', '3.0', 'WC_Customer::set_billing_country' ); $this->set_billing_country( $country ); } /** * Legacy set state. * * @param string $state */ function set_state( $state ) { wc_deprecated_function( 'WC_Customer::set_state', '3.0', 'WC_Customer::set_billing_state' ); $this->set_billing_state( $state ); } /** * Legacy set postcode. * * @param string $postcode */ function set_postcode( $postcode ) { wc_deprecated_function( 'WC_Customer::set_postcode', '3.0', 'WC_Customer::set_billing_postcode' ); $this->set_billing_postcode( $postcode ); } /** * Legacy set city. * * @param string $city */ function set_city( $city ) { wc_deprecated_function( 'WC_Customer::set_city', '3.0', 'WC_Customer::set_billing_city' ); $this->set_billing_city( $city ); } /** * Legacy set address. * * @param string $address */ function set_address( $address ) { wc_deprecated_function( 'WC_Customer::set_address', '3.0', 'WC_Customer::set_billing_address' ); $this->set_billing_address( $address ); } /** * Legacy set address. * * @param string $address */ function set_address_2( $address ) { wc_deprecated_function( 'WC_Customer::set_address_2', '3.0', 'WC_Customer::set_billing_address_2' ); $this->set_billing_address_2( $address ); } } PK wQ/]��c��U �U abstract-wc-legacy-product.phpnu ��� <?php use Automattic\WooCommerce\Enums\ProductType; if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Legacy Abstract Product * * Legacy and deprecated functions are here to keep the WC_Abstract_Product * clean. * This class will be removed in future versions. * * @version 3.0.0 * @package WooCommerce\Abstracts * @category Abstract Class * @author WooThemes */ abstract class WC_Abstract_Legacy_Product extends WC_Data { /** * Magic __isset method for backwards compatibility. Legacy properties which could be accessed directly in the past. * * @param string $key Key name. * @return bool */ public function __isset( $key ) { $valid = array( 'id', 'product_attributes', 'visibility', 'sale_price_dates_from', 'sale_price_dates_to', 'post', 'download_type', 'product_image_gallery', 'variation_shipping_class', 'shipping_class', 'total_stock', 'crosssell_ids', 'parent', ); if ( $this->is_type( ProductType::VARIATION ) ) { $valid = array_merge( $valid, array( 'variation_id', 'variation_data', 'variation_has_stock', 'variation_shipping_class_id', 'variation_has_sku', 'variation_has_length', 'variation_has_width', 'variation_has_height', 'variation_has_weight', 'variation_has_tax_class', 'variation_has_downloadable_files', ) ); } return in_array( $key, array_merge( $valid, array_keys( $this->data ) ) ) || metadata_exists( 'post', $this->get_id(), '_' . $key ) || metadata_exists( 'post', $this->get_parent_id(), '_' . $key ); } /** * Magic __get method for backwards compatibility. Maps legacy vars to new getters. * * @param string $key Key name. * @return mixed */ public function __get( $key ) { if ( 'post_type' === $key ) { return $this->post_type; } wc_doing_it_wrong( $key, __( 'Product properties should not be accessed directly.', 'woocommerce' ), '3.0' ); switch ( $key ) { case 'id' : $value = $this->is_type( ProductType::VARIATION ) ? $this->get_parent_id() : $this->get_id(); break; case 'product_type' : $value = $this->get_type(); break; case 'product_attributes' : $value = isset( $this->data['attributes'] ) ? $this->data['attributes'] : ''; break; case 'visibility' : $value = $this->get_catalog_visibility(); break; case 'sale_price_dates_from' : return $this->get_date_on_sale_from() ? $this->get_date_on_sale_from()->getTimestamp() : ''; break; case 'sale_price_dates_to' : return $this->get_date_on_sale_to() ? $this->get_date_on_sale_to()->getTimestamp() : ''; break; case 'post' : $value = get_post( $this->get_id() ); break; case 'download_type' : return 'standard'; break; case 'product_image_gallery' : $value = $this->get_gallery_image_ids(); break; case 'variation_shipping_class' : case 'shipping_class' : $value = $this->get_shipping_class(); break; case 'total_stock' : $value = $this->get_total_stock(); break; case 'downloadable' : case 'virtual' : case 'manage_stock' : case 'featured' : case 'sold_individually' : $value = $this->{"get_$key"}() ? 'yes' : 'no'; break; case 'crosssell_ids' : $value = $this->get_cross_sell_ids(); break; case 'upsell_ids' : $value = $this->get_upsell_ids(); break; case 'parent' : $value = wc_get_product( $this->get_parent_id() ); break; case 'variation_id' : $value = $this->is_type( ProductType::VARIATION ) ? $this->get_id() : ''; break; case 'variation_data' : $value = $this->is_type( ProductType::VARIATION ) ? wc_get_product_variation_attributes( $this->get_id() ) : ''; break; case 'variation_has_stock' : $value = $this->is_type( ProductType::VARIATION ) ? $this->managing_stock() : ''; break; case 'variation_shipping_class_id' : $value = $this->is_type( ProductType::VARIATION ) ? $this->get_shipping_class_id() : ''; break; case 'variation_has_sku' : case 'variation_has_length' : case 'variation_has_width' : case 'variation_has_height' : case 'variation_has_weight' : case 'variation_has_tax_class' : case 'variation_has_downloadable_files' : $value = true; // These were deprecated in 2.2 and simply returned true in 2.6.x. break; default : if ( in_array( $key, array_keys( $this->data ) ) ) { $value = $this->{"get_$key"}(); } else { $value = get_post_meta( $this->id, '_' . $key, true ); } break; } return $value; } /** * If set, get the default attributes for a variable product. * * @deprecated 3.0.0 * @return array */ public function get_variation_default_attributes() { wc_deprecated_function( 'WC_Product_Variable::get_variation_default_attributes', '3.0', 'WC_Product::get_default_attributes' ); return apply_filters( 'woocommerce_product_default_attributes', $this->get_default_attributes(), $this ); } /** * Returns the gallery attachment ids. * * @deprecated 3.0.0 * @return array */ public function get_gallery_attachment_ids() { wc_deprecated_function( 'WC_Product::get_gallery_attachment_ids', '3.0', 'WC_Product::get_gallery_image_ids' ); return $this->get_gallery_image_ids(); } /** * Set stock level of the product. * * @deprecated 3.0.0 * * @param int $amount * @param string $mode * * @return int */ public function set_stock( $amount = null, $mode = 'set' ) { wc_deprecated_function( 'WC_Product::set_stock', '3.0', 'wc_update_product_stock' ); return wc_update_product_stock( $this, $amount, $mode ); } /** * Reduce stock level of the product. * * @deprecated 3.0.0 * @param int $amount Amount to reduce by. Default: 1 * @return int new stock level */ public function reduce_stock( $amount = 1 ) { wc_deprecated_function( 'WC_Product::reduce_stock', '3.0', 'wc_update_product_stock' ); return wc_update_product_stock( $this, $amount, 'decrease' ); } /** * Increase stock level of the product. * * @deprecated 3.0.0 * @param int $amount Amount to increase by. Default 1. * @return int new stock level */ public function increase_stock( $amount = 1 ) { wc_deprecated_function( 'WC_Product::increase_stock', '3.0', 'wc_update_product_stock' ); return wc_update_product_stock( $this, $amount, 'increase' ); } /** * Check if the stock status needs changing. * * @deprecated 3.0.0 Sync is done automatically on read/save, so calling this should not be needed any more. */ public function check_stock_status() { wc_deprecated_function( 'WC_Product::check_stock_status', '3.0' ); } /** * Get and return related products. * @deprecated 3.0.0 Use wc_get_related_products instead. * * @param int $limit * * @return array */ public function get_related( $limit = 5 ) { wc_deprecated_function( 'WC_Product::get_related', '3.0', 'wc_get_related_products' ); return wc_get_related_products( $this->get_id(), $limit ); } /** * Retrieves related product terms. * @deprecated 3.0.0 Use wc_get_product_term_ids instead. * * @param $term * * @return array */ protected function get_related_terms( $term ) { wc_deprecated_function( 'WC_Product::get_related_terms', '3.0', 'wc_get_product_term_ids' ); return array_merge( array( 0 ), wc_get_product_term_ids( $this->get_id(), $term ) ); } /** * Builds the related posts query. * @deprecated 3.0.0 Use Product Data Store get_related_products_query instead. * * @param $cats_array * @param $tags_array * @param $exclude_ids * @param $limit */ protected function build_related_query( $cats_array, $tags_array, $exclude_ids, $limit ) { wc_deprecated_function( 'WC_Product::build_related_query', '3.0', 'Product Data Store get_related_products_query' ); $data_store = WC_Data_Store::load( 'product' ); return $data_store->get_related_products_query( $cats_array, $tags_array, $exclude_ids, $limit ); } /** * Returns the child product. * @deprecated 3.0.0 Use wc_get_product instead. * @param mixed $child_id * @return WC_Product|WC_Product|WC_Product_variation */ public function get_child( $child_id ) { wc_deprecated_function( 'WC_Product::get_child', '3.0', 'wc_get_product' ); return wc_get_product( $child_id ); } /** * Functions for getting parts of a price, in html, used by get_price_html. * * @deprecated 3.0.0 * @return string */ public function get_price_html_from_text() { wc_deprecated_function( 'WC_Product::get_price_html_from_text', '3.0', 'wc_get_price_html_from_text' ); return wc_get_price_html_from_text(); } /** * Functions for getting parts of a price, in html, used by get_price_html. * * @deprecated 3.0.0 Use wc_format_sale_price instead. * @param string $from String or float to wrap with 'from' text * @param mixed $to String or float to wrap with 'to' text * @return string */ public function get_price_html_from_to( $from, $to ) { wc_deprecated_function( 'WC_Product::get_price_html_from_to', '3.0', 'wc_format_sale_price' ); return apply_filters( 'woocommerce_get_price_html_from_to', wc_format_sale_price( $from, $to ), $from, $to, $this ); } /** * Lists a table of attributes for the product page. * @deprecated 3.0.0 Use wc_display_product_attributes instead. */ public function list_attributes() { wc_deprecated_function( 'WC_Product::list_attributes', '3.0', 'wc_display_product_attributes' ); wc_display_product_attributes( $this ); } /** * Returns the price (including tax). Uses customer tax rates. Can work for a specific $qty for more accurate taxes. * * @deprecated 3.0.0 Use wc_get_price_including_tax instead. * @param int $qty * @param string $price to calculate, left blank to just use get_price() * @return string */ public function get_price_including_tax( $qty = 1, $price = '' ) { wc_deprecated_function( 'WC_Product::get_price_including_tax', '3.0', 'wc_get_price_including_tax' ); return wc_get_price_including_tax( $this, array( 'qty' => $qty, 'price' => $price ) ); } /** * Returns the price including or excluding tax, based on the 'woocommerce_tax_display_shop' setting. * * @deprecated 3.0.0 Use wc_get_price_to_display instead. * @param string $price to calculate, left blank to just use get_price() * @param integer $qty passed on to get_price_including_tax() or get_price_excluding_tax() * @return string */ public function get_display_price( $price = '', $qty = 1 ) { wc_deprecated_function( 'WC_Product::get_display_price', '3.0', 'wc_get_price_to_display' ); return wc_get_price_to_display( $this, array( 'qty' => $qty, 'price' => $price ) ); } /** * Returns the price (excluding tax) - ignores tax_class filters since the price may *include* tax and thus needs subtracting. * Uses store base tax rates. Can work for a specific $qty for more accurate taxes. * * @deprecated 3.0.0 Use wc_get_price_excluding_tax instead. * @param int $qty * @param string $price to calculate, left blank to just use get_price() * @return string */ public function get_price_excluding_tax( $qty = 1, $price = '' ) { wc_deprecated_function( 'WC_Product::get_price_excluding_tax', '3.0', 'wc_get_price_excluding_tax' ); return wc_get_price_excluding_tax( $this, array( 'qty' => $qty, 'price' => $price ) ); } /** * Adjust a products price dynamically. * * @deprecated 3.0.0 * @param mixed $price */ public function adjust_price( $price ) { wc_deprecated_function( 'WC_Product::adjust_price', '3.0', 'WC_Product::set_price / WC_Product::get_price' ); $this->data['price'] = $this->data['price'] + $price; } /** * Returns the product categories. * * @deprecated 3.0.0 * @param string $sep (default: ', '). * @param string $before (default: ''). * @param string $after (default: ''). * @return string */ public function get_categories( $sep = ', ', $before = '', $after = '' ) { wc_deprecated_function( 'WC_Product::get_categories', '3.0', 'wc_get_product_category_list' ); return wc_get_product_category_list( $this->get_id(), $sep, $before, $after ); } /** * Returns the product tags. * * @deprecated 3.0.0 * @param string $sep (default: ', '). * @param string $before (default: ''). * @param string $after (default: ''). * @return array */ public function get_tags( $sep = ', ', $before = '', $after = '' ) { wc_deprecated_function( 'WC_Product::get_tags', '3.0', 'wc_get_product_tag_list' ); return wc_get_product_tag_list( $this->get_id(), $sep, $before, $after ); } /** * Get the product's post data. * * @deprecated 3.0.0 * @return WP_Post */ public function get_post_data() { wc_deprecated_function( 'WC_Product::get_post_data', '3.0', 'get_post' ); // In order to keep backwards compatibility it's required to use the parent data for variations. if ( $this->is_type( ProductType::VARIATION ) ) { $post_data = get_post( $this->get_parent_id() ); } else { $post_data = get_post( $this->get_id() ); } return $post_data; } /** * Get the parent of the post. * * @deprecated 3.0.0 * @return int */ public function get_parent() { wc_deprecated_function( 'WC_Product::get_parent', '3.0', 'WC_Product::get_parent_id' ); return apply_filters( 'woocommerce_product_parent', absint( $this->get_post_data()->post_parent ), $this ); } /** * Returns the upsell product ids. * * @deprecated 3.0.0 * @return array */ public function get_upsells() { wc_deprecated_function( 'WC_Product::get_upsells', '3.0', 'WC_Product::get_upsell_ids' ); return apply_filters( 'woocommerce_product_upsell_ids', $this->get_upsell_ids(), $this ); } /** * Returns the cross sell product ids. * * @deprecated 3.0.0 * @return array */ public function get_cross_sells() { wc_deprecated_function( 'WC_Product::get_cross_sells', '3.0', 'WC_Product::get_cross_sell_ids' ); return apply_filters( 'woocommerce_product_crosssell_ids', $this->get_cross_sell_ids(), $this ); } /** * Check if variable product has default attributes set. * * @deprecated 3.0.0 * @return bool */ public function has_default_attributes() { wc_deprecated_function( 'WC_Product_Variable::has_default_attributes', '3.0', 'a check against WC_Product::get_default_attributes directly' ); if ( ! $this->get_default_attributes() ) { return true; } return false; } /** * Get variation ID. * * @deprecated 3.0.0 * @return int */ public function get_variation_id() { wc_deprecated_function( 'WC_Product::get_variation_id', '3.0', 'WC_Product::get_id(). It will always be the variation ID if this is a variation.' ); return $this->get_id(); } /** * Get product variation description. * * @deprecated 3.0.0 * @return string */ public function get_variation_description() { wc_deprecated_function( 'WC_Product::get_variation_description', '3.0', 'WC_Product::get_description()' ); return $this->get_description(); } /** * Check if all variation's attributes are set. * * @deprecated 3.0.0 * @return boolean */ public function has_all_attributes_set() { wc_deprecated_function( 'WC_Product::has_all_attributes_set', '3.0', 'an array filter on get_variation_attributes for a quick solution.' ); $set = true; // undefined attributes have null strings as array values foreach ( $this->get_variation_attributes() as $att ) { if ( ! $att ) { $set = false; break; } } return $set; } /** * Returns whether or not the variations parent is visible. * * @deprecated 3.0.0 * @return bool */ public function parent_is_visible() { wc_deprecated_function( 'WC_Product::parent_is_visible', '3.0' ); return $this->is_visible(); } /** * Get total stock - This is the stock of parent and children combined. * * @deprecated 3.0.0 * @return int */ public function get_total_stock() { wc_deprecated_function( 'WC_Product::get_total_stock', '3.0', 'get_stock_quantity on each child. Beware of performance issues in doing so.' ); if ( sizeof( $this->get_children() ) > 0 ) { $total_stock = max( 0, $this->get_stock_quantity() ); foreach ( $this->get_children() as $child_id ) { if ( 'yes' === get_post_meta( $child_id, '_manage_stock', true ) ) { $stock = get_post_meta( $child_id, '_stock', true ); $total_stock += max( 0, wc_stock_amount( $stock ) ); } } } else { $total_stock = $this->get_stock_quantity(); } return wc_stock_amount( $total_stock ); } /** * Get formatted variation data with WC < 2.4 back compat and proper formatting of text-based attribute names. * * @deprecated 3.0.0 * * @param bool $flat * * @return string */ public function get_formatted_variation_attributes( $flat = false ) { wc_deprecated_function( 'WC_Product::get_formatted_variation_attributes', '3.0', 'wc_get_formatted_variation' ); return wc_get_formatted_variation( $this, $flat ); } /** * Sync variable product prices with the children lowest/highest prices. * * @deprecated 3.0.0 not used in core. * * @param int $product_id */ public function variable_product_sync( $product_id = 0 ) { wc_deprecated_function( 'WC_Product::variable_product_sync', '3.0' ); if ( empty( $product_id ) ) { $product_id = $this->get_id(); } // Sync prices with children if ( is_callable( array( __CLASS__, 'sync' ) ) ) { self::sync( $product_id ); } } /** * Sync the variable product's attributes with the variations. * * @param $product * @param bool $children */ public static function sync_attributes( $product, $children = false ) { if ( ! is_a( $product, 'WC_Product' ) ) { $product = wc_get_product( $product ); } /** * Pre 2.4 handling where 'slugs' were saved instead of the full text attribute. * Attempt to get full version of the text attribute from the parent and UPDATE meta. */ if ( version_compare( get_post_meta( $product->get_id(), '_product_version', true ), '2.4.0', '<' ) ) { $parent_attributes = array_filter( (array) get_post_meta( $product->get_id(), '_product_attributes', true ) ); if ( ! $children ) { $children = $product->get_children( 'edit' ); } foreach ( $children as $child_id ) { $all_meta = get_post_meta( $child_id ); foreach ( $all_meta as $name => $value ) { if ( 0 !== strpos( $name, 'attribute_' ) ) { continue; } if ( sanitize_title( $value[0] ) === $value[0] ) { foreach ( $parent_attributes as $attribute ) { if ( 'attribute_' . sanitize_title( $attribute['name'] ) !== $name ) { continue; } $text_attributes = wc_get_text_attributes( $attribute['value'] ); foreach ( $text_attributes as $text_attribute ) { if ( sanitize_title( $text_attribute ) === $value[0] ) { update_post_meta( $child_id, $name, $text_attribute ); break; } } } } } } } } /** * Match a variation to a given set of attributes using a WP_Query. * @deprecated 3.0.0 in favour of Product data store's find_matching_product_variation. * * @param array $match_attributes */ public function get_matching_variation( $match_attributes = array() ) { wc_deprecated_function( 'WC_Product::get_matching_variation', '3.0', 'Product data store find_matching_product_variation' ); $data_store = WC_Data_Store::load( 'product' ); return $data_store->find_matching_product_variation( $this, $match_attributes ); } /** * Returns whether or not we are showing dimensions on the product page. * @deprecated 3.0.0 Unused. * @return bool */ public function enable_dimensions_display() { wc_deprecated_function( 'WC_Product::enable_dimensions_display', '3.0' ); return apply_filters( 'wc_product_enable_dimensions_display', true ) && ( $this->has_dimensions() || $this->has_weight() || $this->child_has_weight() || $this->child_has_dimensions() ); } /** * Returns the product rating in html format. * * @deprecated 3.0.0 * @param string $rating (default: '') * @return string */ public function get_rating_html( $rating = null ) { wc_deprecated_function( 'WC_Product::get_rating_html', '3.0', 'wc_get_rating_html' ); return wc_get_rating_html( $rating ); } /** * Sync product rating. Can be called statically. * * @deprecated 3.0.0 * @param int $post_id */ public static function sync_average_rating( $post_id ) { wc_deprecated_function( 'WC_Product::sync_average_rating', '3.0', 'WC_Comments::get_average_rating_for_product or leave to CRUD.' ); // See notes in https://github.com/woocommerce/woocommerce/pull/22909#discussion_r262393401. // Sync count first like in the original method https://github.com/woocommerce/woocommerce/blob/2.6.0/includes/abstracts/abstract-wc-product.php#L1101-L1128. self::sync_rating_count( $post_id ); $average = WC_Comments::get_average_rating_for_product( wc_get_product( $post_id ) ); update_post_meta( $post_id, '_wc_average_rating', $average ); } /** * Sync product rating count. Can be called statically. * * @deprecated 3.0.0 * @param int $post_id */ public static function sync_rating_count( $post_id ) { wc_deprecated_function( 'WC_Product::sync_rating_count', '3.0', 'WC_Comments::get_rating_counts_for_product or leave to CRUD.' ); $counts = WC_Comments::get_rating_counts_for_product( wc_get_product( $post_id ) ); update_post_meta( $post_id, '_wc_rating_count', $counts ); } /** * Same as get_downloads in CRUD. * * @deprecated 3.0.0 * @return array */ public function get_files() { wc_deprecated_function( 'WC_Product::get_files', '3.0', 'WC_Product::get_downloads' ); return $this->get_downloads(); } /** * @deprecated 3.0.0 Sync is taken care of during save - no need to call this directly. */ public function grouped_product_sync() { wc_deprecated_function( 'WC_Product::grouped_product_sync', '3.0' ); } } PK wQ/]�* class-wc-legacy-webhook.phpnu ��� <?php /** * Legacy Webhook * * Legacy and deprecated functions are here to keep the WC_Legacy_Webhook class clean. * This class will be removed in future versions. * * @version 3.2.0 * @package WooCommerce\Classes * @category Class * @author Automattic */ if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Legacy Webhook class. */ abstract class WC_Legacy_Webhook extends WC_Data { /** * Magic __isset method for backwards compatibility. Legacy properties which could be accessed directly in the past. * * @param string $key Item to check. * @return bool */ public function __isset( $key ) { $legacy_keys = array( 'id', 'status', 'post_data', 'delivery_url', 'secret', 'topic', 'hooks', 'resource', 'event', 'failure_count', 'api_version', ); if ( in_array( $key, $legacy_keys, true ) ) { return true; } return false; } /** * Magic __get method for backwards compatibility. Maps legacy vars to new getters. * * @param string $key Item to get. * @return mixed */ public function __get( $key ) { wc_doing_it_wrong( $key, 'Webhook properties should not be accessed directly.', '3.2' ); switch ( $key ) { case 'id' : $value = $this->get_id(); break; case 'status' : $value = $this->get_status(); break; case 'post_data' : $value = null; break; case 'delivery_url' : $value = $this->get_delivery_url(); break; case 'secret' : $value = $this->get_secret(); break; case 'topic' : $value = $this->get_topic(); break; case 'hooks' : $value = $this->get_hooks(); break; case 'resource' : $value = $this->get_resource(); break; case 'event' : $value = $this->get_event(); break; case 'failure_count' : $value = $this->get_failure_count(); break; case 'api_version' : $value = $this->get_api_version(); break; default : $value = ''; break; } // End switch(). return $value; } /** * Get the post data for the webhook. * * @deprecated 3.2.0 * @since 2.2 * @return null|WP_Post */ public function get_post_data() { wc_deprecated_function( 'WC_Webhook::get_post_data', '3.2' ); return null; } /** * Update the webhook status. * * @deprecated 3.2.0 * @since 2.2.0 * @param string $status Status to set. */ public function update_status( $status ) { wc_deprecated_function( 'WC_Webhook::update_status', '3.2', 'WC_Webhook::set_status' ); $this->set_status( $status ); $this->save(); } } PK wQ/]����G G ! class-wc-legacy-shipping-zone.phpnu ��� <?php if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Legacy Shipping Zone. * * @version 3.0.0 * @package WooCommerce\Classes * @category Class * @author WooThemes */ abstract class WC_Legacy_Shipping_Zone extends WC_Data { /** * Get zone ID * @return int|null Null if the zone does not exist. 0 is the default zone. * @deprecated 3.0 */ public function get_zone_id() { wc_deprecated_function( 'WC_Shipping_Zone::get_zone_id', '3.0', 'WC_Shipping_Zone::get_id' ); return $this->get_id(); } /** * Read a shipping zone by ID. * @deprecated 3.0.0 - Init a shipping zone with an ID. * * @param int $zone_id */ public function read( $zone_id ) { wc_deprecated_function( 'WC_Shipping_Zone::read', '3.0', 'a shipping zone initialized with an ID.' ); $this->set_id( $zone_id ); $data_store = WC_Data_Store::load( 'shipping-zone' ); $data_store->read( $this ); } /** * Update a zone. * @deprecated 3.0.0 - Use ::save instead. */ public function update() { wc_deprecated_function( 'WC_Shipping_Zone::update', '3.0', 'WC_Shipping_Zone::save instead.' ); $data_store = WC_Data_Store::load( 'shipping-zone' ); try { $data_store->update( $this ); } catch ( Exception $e ) { return false; } } /** * Create a zone. * @deprecated 3.0.0 - Use ::save instead. */ public function create() { wc_deprecated_function( 'WC_Shipping_Zone::create', '3.0', 'WC_Shipping_Zone::save instead.' ); $data_store = WC_Data_Store::load( 'shipping-zone' ); try { $data_store->create( $this ); } catch ( Exception $e ) { return false; } } } PK �h/]��E��B �B '