Miscellaneous cleanup of typos + change some return types for IDE helpers
This commit is contained in:
parent
adfd955194
commit
a29ba23fab
|
@ -220,7 +220,7 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
|
|||
/**
|
||||
* 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 $order WC_Order
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected function update_post_meta( &$order ) {
|
||||
|
|
|
@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
class WC_Customer_Download_Data_Store implements WC_Customer_Download_Data_Store_Interface {
|
||||
|
||||
/**
|
||||
* Create dowload permission for a user.
|
||||
* Create download permission for a user.
|
||||
*
|
||||
* @param WC_Customer_Download $download
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@ class WC_Data_Store_WP {
|
|||
|
||||
/**
|
||||
* Meta type. This should match up with
|
||||
* the types avaiable at https://codex.wordpress.org/Function_Reference/add_metadata.
|
||||
* the types available at https://codex.wordpress.org/Function_Reference/add_metadata.
|
||||
* WP defines 'post', 'user', 'comment', and 'term'.
|
||||
*/
|
||||
protected $meta_type = 'post';
|
||||
|
@ -97,7 +97,7 @@ class WC_Data_Store_WP {
|
|||
* @since 3.0.0
|
||||
* @param WC_Data
|
||||
* @param stdClass (containing ->key and ->value)
|
||||
* @return meta ID
|
||||
* @return int meta ID
|
||||
*/
|
||||
public function add_meta( &$object, $meta ) {
|
||||
return add_metadata( $this->meta_type, $object->get_id(), $meta->key, $meta->value, false );
|
||||
|
|
|
@ -240,7 +240,7 @@ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implement
|
|||
|
||||
parent::update_post_meta( $order );
|
||||
|
||||
// If address changed, store concatinated version to make searches faster.
|
||||
// If address changed, store concatenated version to make searches faster.
|
||||
if ( in_array( 'billing', $updated_props ) || ! metadata_exists( 'post', $id, '_billing_address_index' ) ) {
|
||||
update_post_meta( $id, '_billing_address_index', implode( ' ', $order->get_address( 'billing' ) ) );
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class WC_Order_Item_Coupon_Data_Store extends Abstract_WC_Order_Item_Type_Data_S
|
|||
* Read/populate data properties specific to this order item.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param WC_Order_Item $item
|
||||
* @param WC_Order_Item_Coupon $item
|
||||
*/
|
||||
public function read( &$item ) {
|
||||
parent::read( $item );
|
||||
|
@ -40,7 +40,7 @@ class WC_Order_Item_Coupon_Data_Store extends Abstract_WC_Order_Item_Type_Data_S
|
|||
* Ran after both create and update, so $item->get_id() will be set.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param WC_Order_Item $item
|
||||
* @param WC_Order_Item_Coupon $item
|
||||
*/
|
||||
public function save_item_data( &$item ) {
|
||||
$id = $item->get_id();
|
||||
|
|
|
@ -17,7 +17,7 @@ class WC_Order_Item_Data_Store implements WC_Order_Item_Data_Store_Interface {
|
|||
*
|
||||
* @since 3.0.0
|
||||
* @param int $order_id
|
||||
* @param array $item. order_item_name and order_item_type.
|
||||
* @param array $item order_item_name and order_item_type.
|
||||
* @return int Order Item ID
|
||||
*/
|
||||
public function add_order_item( $order_id, $item ) {
|
||||
|
@ -44,7 +44,7 @@ class WC_Order_Item_Data_Store implements WC_Order_Item_Data_Store_Interface {
|
|||
*
|
||||
* @since 3.0.0
|
||||
* @param int $item_id
|
||||
* @param array $item. order_item_name or order_item_type.
|
||||
* @param array $item order_item_name or order_item_type.
|
||||
* @return boolean
|
||||
*/
|
||||
public function update_order_item( $item_id, $item ) {
|
||||
|
|
|
@ -11,6 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* @author WooCommerce
|
||||
*/
|
||||
class WC_Order_Item_Fee_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
|
||||
|
@ -22,7 +23,7 @@ class WC_Order_Item_Fee_Data_Store extends Abstract_WC_Order_Item_Type_Data_Stor
|
|||
* Read/populate data properties specific to this order item.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param WC_Order_Item $item
|
||||
* @param WC_Order_Item_Fee $item
|
||||
*/
|
||||
public function read( &$item ) {
|
||||
parent::read( $item );
|
||||
|
@ -41,7 +42,7 @@ class WC_Order_Item_Fee_Data_Store extends Abstract_WC_Order_Item_Type_Data_Stor
|
|||
* Ran after both create and update, so $id will be set.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param WC_Order_Item $item
|
||||
* @param WC_Order_Item_Fee $item
|
||||
*/
|
||||
public function save_item_data( &$item ) {
|
||||
$id = $item->get_id();
|
||||
|
|
|
@ -11,6 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* @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
|
||||
|
@ -22,7 +23,7 @@ class WC_Order_Item_Product_Data_Store extends Abstract_WC_Order_Item_Type_Data_
|
|||
* Read/populate data properties specific to this order item.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param WC_Order_Item $item
|
||||
* @param WC_Order_Item_Product $item
|
||||
*/
|
||||
public function read( &$item ) {
|
||||
parent::read( $item );
|
||||
|
@ -44,7 +45,7 @@ class WC_Order_Item_Product_Data_Store extends Abstract_WC_Order_Item_Type_Data_
|
|||
* Ran after both create and update, so $id will be set.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param WC_Order_Item $item
|
||||
* @param WC_Order_Item_Product $item
|
||||
*/
|
||||
public function save_item_data( &$item ) {
|
||||
$id = $item->get_id();
|
||||
|
@ -68,7 +69,7 @@ class WC_Order_Item_Product_Data_Store extends Abstract_WC_Order_Item_Type_Data_
|
|||
* Get a list of download IDs for a specific item from an order.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param WC_Order_Item $item
|
||||
* @param WC_Order_Item_Product $item
|
||||
* @param WC_Order $order
|
||||
* @return array
|
||||
*/
|
||||
|
|
|
@ -11,6 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* @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
|
||||
|
@ -22,7 +23,7 @@ class WC_Order_Item_Shipping_Data_Store extends Abstract_WC_Order_Item_Type_Data
|
|||
* Read/populate data properties specific to this order item.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param WC_Order_Item $item
|
||||
* @param WC_Order_Item_Shipping $item
|
||||
*/
|
||||
public function read( &$item ) {
|
||||
parent::read( $item );
|
||||
|
@ -40,7 +41,7 @@ class WC_Order_Item_Shipping_Data_Store extends Abstract_WC_Order_Item_Type_Data
|
|||
* Ran after both create and update, so $id will be set.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param WC_Order_Item $item
|
||||
* @param WC_Order_Item_Shipping $item
|
||||
*/
|
||||
public function save_item_data( &$item ) {
|
||||
$id = $item->get_id();
|
||||
|
|
|
@ -11,6 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* @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
|
||||
|
@ -22,7 +23,7 @@ class WC_Order_Item_Tax_Data_Store extends Abstract_WC_Order_Item_Type_Data_Stor
|
|||
* Read/populate data properties specific to this order item.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param WC_Order_Item $item
|
||||
* @param WC_Order_Item_Tax $item
|
||||
*/
|
||||
public function read( &$item ) {
|
||||
parent::read( $item );
|
||||
|
@ -42,7 +43,7 @@ class WC_Order_Item_Tax_Data_Store extends Abstract_WC_Order_Item_Type_Data_Stor
|
|||
* Ran after both create and update, so $id will be set.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param WC_Order_Item $item
|
||||
* @param WC_Order_Item_Tax $item
|
||||
*/
|
||||
public function save_item_data( &$item ) {
|
||||
$id = $item->get_id();
|
||||
|
|
|
@ -35,7 +35,7 @@ class WC_Order_Refund_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT im
|
|||
|
||||
/**
|
||||
* Delete a refund - no trash is supported.
|
||||
* @param WC_Order
|
||||
* @param WC_Order $order
|
||||
* @param array $args Array of args to pass to the delete method.
|
||||
*/
|
||||
public function delete( &$order, $args = array() ) {
|
||||
|
@ -49,7 +49,7 @@ class WC_Order_Refund_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT im
|
|||
/**
|
||||
* Read refund data. Can be overridden by child classes to load other props.
|
||||
*
|
||||
* @param WC_Order
|
||||
* @param WC_Order $refund
|
||||
* @param object $post_object
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
@ -67,7 +67,7 @@ class WC_Order_Refund_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT im
|
|||
* 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 bool $force Force all props to be written even if not changed. This is used during creation.
|
||||
* @param WC_Order $refund
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected function update_post_meta( &$refund ) {
|
||||
|
|
|
@ -13,10 +13,11 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* @author WooCommerce
|
||||
*/
|
||||
interface WC_Order_Item_Data_Store_Interface {
|
||||
|
||||
/**
|
||||
* Add an order item to an order.
|
||||
* @param int $order_id
|
||||
* @param array $item. order_item_name and order_item_type.
|
||||
* @param array $item order_item_name and order_item_type.
|
||||
* @return int Order Item ID
|
||||
*/
|
||||
public function add_order_item( $order_id, $item );
|
||||
|
@ -24,7 +25,7 @@ interface WC_Order_Item_Data_Store_Interface {
|
|||
/**
|
||||
* Update an order item.
|
||||
* @param int $item_id
|
||||
* @param array $item. order_item_name or order_item_type.
|
||||
* @param array $item order_item_name or order_item_type.
|
||||
* @return boolean
|
||||
*/
|
||||
public function update_order_item( $item_id, $item );
|
||||
|
|
|
@ -20,9 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* @return mixed
|
||||
*/
|
||||
function wc_add_order_item( $order_id, $item ) {
|
||||
$order_id = absint( $order_id );
|
||||
|
||||
if ( ! $order_id )
|
||||
if ( ! $order_id = absint( $order_id ) )
|
||||
return false;
|
||||
|
||||
$defaults = array(
|
||||
|
@ -69,13 +67,13 @@ function wc_update_order_item( $item_id, $args ) {
|
|||
* @return bool
|
||||
*/
|
||||
function wc_delete_order_item( $item_id ) {
|
||||
$item_id = absint( $item_id );
|
||||
$data_store = WC_Data_Store::load( 'order-item' );
|
||||
|
||||
if ( ! $item_id ) {
|
||||
if ( ! $item_id = absint( $item_id ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$data_store = WC_Data_Store::load( 'order-item' );
|
||||
|
||||
do_action( 'woocommerce_before_delete_order_item', $item_id );
|
||||
|
||||
$data_store->delete_order_item( $item_id );
|
||||
|
|
Loading…
Reference in New Issue