if ( ! defined( 'ABSPATH' ) ) { exit; } /** * WC Order Item Product Data Store * * @version 3.0.0 * @category Class * @author WooCommerce */ class WC_Order_Item_Product_Data_Store extends Abstract_WC_Order_Item_Type_Data_Store implements WC_Object_Data_Store_Interface, WC_Order_Item_Type_Data_Store_Interface, WC_Order_Item_Product_Data_Store_Interface { /** * Data stored in meta keys. * @since 3.0.0 * @var array */ protected $internal_meta_keys = array( '_product_id', '_variation_id', '_qty', '_tax_class', '_line_subtotal', '_line_subtotal_tax', '_line_total', '_line_tax', '_line_tax_data' ); /** * Read/populate data properties specific to this order item. * * @since 3.0.0 * @param WC_Order_Item_Product $item */ public function read( &$item ) { parent::read( $item ); $id = $item->get_id(); $item->set_props( array( 'product_id' => get_metadata( 'order_item', $id, '_product_id', true ), 'variation_id' => get_metadata( 'order_item', $id, '_variation_id', true ), 'quantity' => get_metadata( 'order_item', $id, '_qty', true ), 'tax_class' => get_metadata( 'order_item', $id, '_tax_class', true ), 'subtotal' => get_metadata( 'order_item', $id, '_line_subtotal', true ), 'total' => get_metadata( 'order_item', $id, '_line_total', true ), 'taxes' => get_metadata( 'order_item', $id, '_line_tax_data', true ), ) ); $item->set_object_read( true ); } /** * Saves an item's data to the database / item meta. * Ran after both create and update, so $id will be set. * * @since 3.0.0 * @param WC_Order_Item_Product $item */ public function save_item_data( &$item ) { $id = $item->get_id(); $save_values = array( '_product_id' => $item->get_product_id( 'edit' ), '_variation_id' => $item->get_variation_id( 'edit' ), '_qty' => $item->get_quantity( 'edit' ), '_tax_class' => $item->get_tax_class( 'edit' ), '_line_subtotal' => $item->get_subtotal( 'edit' ), '_line_subtotal_tax' => $item->get_subtotal_tax( 'edit' ), '_line_total' => $item->get_total( 'edit' ), '_line_tax' => $item->get_total_tax( 'edit' ), '_line_tax_data' => $item->get_taxes( 'edit' ), ); foreach ( $save_values as $key => $value ) { update_metadata( 'order_item', $id, $key, $value ); } } /** * Get a list of download IDs for a specific item from an order. * * @since 3.0.0 * @param WC_Order_Item_Product $item * @param WC_Order $order * @return array */ public function get_download_ids( $item, $order ) { global $wpdb; return $wpdb->get_col( $wpdb->prepare( "SELECT download_id FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE user_email = %s AND order_key = %s AND product_id = %d ORDER BY permission_id", $order->get_billing_email(), $order->get_order_key(), $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id() ) ); } } if ( ! defined( 'ABSPATH' ) ) { exit; } /** * WC Order Item Shipping Data Store * * @version 3.0.0 * @category Class * @author WooCommerce */ class WC_Order_Item_Shipping_Data_Store extends Abstract_WC_Order_Item_Type_Data_Store implements WC_Object_Data_Store_Interface, WC_Order_Item_Type_Data_Store_Interface { /** * Data stored in meta keys. * @since 3.0.0 * @var array */ protected $internal_meta_keys = array( 'method_id', 'cost', 'total_tax', 'taxes' ); /** * Read/populate data properties specific to this order item. * * @since 3.0.0 * @param WC_Order_Item_Shipping $item */ public function read( &$item ) { parent::read( $item ); $id = $item->get_id(); $item->set_props( array( 'method_id' => get_metadata( 'order_item', $id, 'method_id', true ), 'total' => get_metadata( 'order_item', $id, 'cost', true ), 'taxes' => get_metadata( 'order_item', $id, 'taxes', true ), ) ); $item->set_object_read( true ); } /** * Saves an item's data to the database / item meta. * Ran after both create and update, so $id will be set. * * @since 3.0.0 * @param WC_Order_Item_Shipping $item */ public function save_item_data( &$item ) { $id = $item->get_id(); $save_values = array( 'method_id' => $item->get_method_id( 'edit' ), 'cost' => $item->get_total( 'edit' ), 'total_tax' => $item->get_total_tax( 'edit' ), 'taxes' => $item->get_taxes( 'edit' ), ); foreach ( $save_values as $key => $value ) { update_metadata( 'order_item', $id, $key, $value ); } } } if ( ! defined( 'ABSPATH' ) ) { exit; } /** * WC Order Item Tax Data Store * * @version 3.0.0 * @category Class * @author WooCommerce */ class WC_Order_Item_Tax_Data_Store extends Abstract_WC_Order_Item_Type_Data_Store implements WC_Object_Data_Store_Interface, WC_Order_Item_Type_Data_Store_Interface { /** * Data stored in meta keys. * @since 3.0.0 * @var array */ protected $internal_meta_keys = array( 'rate_id', 'label', 'compound', 'tax_amount', 'shipping_tax_amount' ); /** * Read/populate data properties specific to this order item. * * @since 3.0.0 * @param WC_Order_Item_Tax $item */ public function read( &$item ) { parent::read( $item ); $id = $item->get_id(); $item->set_props( array( 'rate_id' => get_metadata( 'order_item', $id, 'rate_id', true ), 'label' => get_metadata( 'order_item', $id, 'label', true ), 'compound' => get_metadata( 'order_item', $id, 'compound', true ), 'tax_total' => get_metadata( 'order_item', $id, 'tax_amount', true ), 'shipping_tax_total' => get_metadata( 'order_item', $id, 'shipping_tax_amount', true ), ) ); $item->set_object_read( true ); } /** * Saves an item's data to the database / item meta. * Ran after both create and update, so $id will be set. * * @since 3.0.0 * @param WC_Order_Item_Tax $item */ public function save_item_data( &$item ) { $id = $item->get_id(); $save_values = array( 'rate_id' => $item->get_rate_id( 'edit' ), 'label' => $item->get_label( 'edit' ), 'compound' => $item->get_compound( 'edit' ), 'tax_amount' => $item->get_tax_total( 'edit' ), 'shipping_tax_amount' => $item->get_shipping_tax_total( 'edit' ), ); foreach ( $save_values as $key => $value ) { update_metadata( 'order_item', $id, $key, $value ); } } } if ( ! defined( 'ABSPATH' ) ) { exit; } /** * WC Order Refund Data Store: Stored in CPT. * * @version 3.0.0 * @category Class * @author WooThemes */ class WC_Order_Refund_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implements WC_Object_Data_Store_Interface, WC_Order_Refund_Data_Store_Interface { /** * Data stored in meta keys, but not considered "meta" for an order. * @since 3.0.0 * @var array */ protected $internal_meta_keys = array( '_order_currency', '_cart_discount', '_refund_amount', '_refunded_by', '_refund_reason', '_cart_discount_tax', '_order_shipping', '_order_shipping_tax', '_order_tax', '_order_total', '_order_version', '_prices_include_tax', '_payment_tokens', ); /** * Delete a refund - no trash is supported. * @param WC_Order $order * @param array $args Array of args to pass to the delete method. */ public function delete( &$order, $args = array() ) { $id = $order->get_id(); if ( ! $id ) { return; } wp_delete_post( $id ); $order->set_id( 0 ); do_action( 'woocommerce_delete_order_refund', $id ); } /** * Read refund data. Can be overridden by child classes to load other props. * * @param WC_Order $refund * @param object $post_object * @since 3.0.0 */ protected function read_order_data( &$refund, $post_object ) { parent::read_order_data( $refund, $post_object ); $id = $refund->get_id(); $refund->set_props( array( 'amount' => get_post_meta( $id, '_refund_amount', true ), 'refunded_by' => metadata_exists( 'post', $id, '_refunded_by' ) ? get_post_meta( $id, '_refunded_by', true ) : absint( $post_object->post_author ), 'reason' => metadata_exists( 'post', $id, '_refund_reason' ) ? get_post_meta( $id, '_refund_reason', true ) : $post_object->post_excerpt, ) ); } /** * Helper method that updates all the post meta for an order based on it's settings in the WC_Order class. * * @param WC_Order * @param WC_Order $refund * @since 3.0.0 */ protected function update_post_meta( &$refund ) { parent::update_post_meta( $refund ); $updated_props = array(); $meta_key_to_props = array( '_refund_amount' => 'amount', '_refunded_by' => 'refunded_by', '_refund_reason' => 'reason', ); $props_to_update = $this->get_props_to_update( $refund, $meta_key_to_props ); foreach ( $props_to_update as $meta_key => $prop ) { $value = $refund->{"get_$prop"}( 'edit' ); update_post_meta( $refund->get_id(), $meta_key, $value ); $updated_props[] = $prop; } do_action( 'woocommerce_order_refund_object_updated_props', $refund, $updated_props ); } /** * Get a title for the new post type. * * @return string */ protected function get_post_title() { // @codingStandardsIgnoreStart /* translators: %s: Order date */ return sprintf( __( 'Refund – %s', 'woocommerce' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Order date parsed by strftime', 'woocommerce' ) ) ); // @codingStandardsIgnoreEnd } } Cart - Glamorous Bouquets

Cart

Your cart is currently empty.