class-wc-abstract-order-data-store-interface.php
5 years ago
class-wc-coupon-data-store-interface.php
5 years ago
class-wc-customer-data-store-interface.php
5 years ago
class-wc-customer-download-data-store-interface.php
5 years ago
class-wc-customer-download-log-data-store-interface.php
5 years ago
class-wc-importer-interface.php
5 years ago
class-wc-log-handler-interface.php
5 years ago
class-wc-logger-interface.php
5 years ago
class-wc-object-data-store-interface.php
5 years ago
class-wc-order-data-store-interface.php
1 year ago
class-wc-order-item-data-store-interface.php
3 years ago
class-wc-order-item-product-data-store-interface.php
5 years ago
class-wc-order-item-type-data-store-interface.php
5 years ago
class-wc-order-refund-data-store-interface.php
5 years ago
class-wc-payment-token-data-store-interface.php
5 years ago
class-wc-product-data-store-interface.php
1 year ago
class-wc-product-variable-data-store-interface.php
5 years ago
class-wc-queue-interface.php
4 months ago
class-wc-shipping-zone-data-store-interface.php
4 years ago
class-wc-webhooks-data-store-interface.php
5 years ago
class-wc-product-data-store-interface.php
141 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Product Data Store Interface |
| 4 | * |
| 5 | * @version 3.0.0 |
| 6 | * @package WooCommerce\Interface |
| 7 | */ |
| 8 | |
| 9 | /** |
| 10 | * WC Product Data Store Interface |
| 11 | * |
| 12 | * Functions that must be defined by product store classes. |
| 13 | * |
| 14 | * @version 3.0.0 |
| 15 | */ |
| 16 | interface WC_Product_Data_Store_Interface { |
| 17 | |
| 18 | /** |
| 19 | * Returns an array of on sale products, as an array of objects with an |
| 20 | * ID and parent_id present. Example: $return[0]->id, $return[0]->parent_id. |
| 21 | * |
| 22 | * @return array |
| 23 | */ |
| 24 | public function get_on_sale_products(); |
| 25 | |
| 26 | /** |
| 27 | * Returns a list of product IDs ( id as key => parent as value) that are |
| 28 | * featured. Uses get_posts instead of wc_get_products since we want |
| 29 | * some extra meta queries and ALL products (posts_per_page = -1). |
| 30 | * |
| 31 | * @return array |
| 32 | */ |
| 33 | public function get_featured_product_ids(); |
| 34 | |
| 35 | /** |
| 36 | * Check if product sku is found for any other product IDs. |
| 37 | * |
| 38 | * @param int $product_id Product ID. |
| 39 | * @param string $sku SKU. |
| 40 | * @return bool |
| 41 | */ |
| 42 | public function is_existing_sku( $product_id, $sku ); |
| 43 | |
| 44 | /** |
| 45 | * Return product ID based on SKU. |
| 46 | * |
| 47 | * @param string $sku SKU. |
| 48 | * @return int |
| 49 | */ |
| 50 | public function get_product_id_by_sku( $sku ); |
| 51 | |
| 52 | |
| 53 | /** |
| 54 | * Returns an array of IDs of products that have sales starting soon. |
| 55 | * |
| 56 | * @return array |
| 57 | */ |
| 58 | public function get_starting_sales(); |
| 59 | |
| 60 | /** |
| 61 | * Returns an array of IDs of products that have sales which are due to end. |
| 62 | * |
| 63 | * @return array |
| 64 | */ |
| 65 | public function get_ending_sales(); |
| 66 | |
| 67 | /** |
| 68 | * Find a matching (enabled) variation within a variable product. |
| 69 | * |
| 70 | * @param WC_Product $product Variable product object. |
| 71 | * @param array $match_attributes Array of attributes we want to try to match. |
| 72 | * @return int Matching variation ID or 0. |
| 73 | */ |
| 74 | public function find_matching_product_variation( $product, $match_attributes = array() ); |
| 75 | |
| 76 | /** |
| 77 | * Make sure all variations have a sort order set so they can be reordered correctly. |
| 78 | * |
| 79 | * @param int $parent_id Parent ID. |
| 80 | */ |
| 81 | public function sort_all_product_variations( $parent_id ); |
| 82 | |
| 83 | /** |
| 84 | * Return a list of related products (using data like categories and IDs). |
| 85 | * |
| 86 | * @param array $cats_array List of categories IDs. |
| 87 | * @param array $tags_array List of tags IDs. |
| 88 | * @param array $exclude_ids Excluded IDs. |
| 89 | * @param int $limit Limit of results. |
| 90 | * @param int $product_id Product ID. |
| 91 | * @return array |
| 92 | */ |
| 93 | public function get_related_products( $cats_array, $tags_array, $exclude_ids, $limit, $product_id ); |
| 94 | |
| 95 | /** |
| 96 | * Update a product's stock amount directly. |
| 97 | * |
| 98 | * Uses queries rather than update_post_meta so we can do this in one query (to avoid stock issues). |
| 99 | * |
| 100 | * @param int $product_id_with_stock Product ID. |
| 101 | * @param int|null $stock_quantity Stock quantity to update to. |
| 102 | * @param string $operation Either set, increase or decrease. |
| 103 | */ |
| 104 | public function update_product_stock( $product_id_with_stock, $stock_quantity = null, $operation = 'set' ); |
| 105 | |
| 106 | /** |
| 107 | * Update a product's sale count directly. |
| 108 | * |
| 109 | * Uses queries rather than update_post_meta so we can do this in one query for performance. |
| 110 | * |
| 111 | * @param int $product_id Product ID. |
| 112 | * @param int|null $quantity Stock quantity to use for update. |
| 113 | * @param string $operation Either set, increase or decrease. |
| 114 | */ |
| 115 | public function update_product_sales( $product_id, $quantity = null, $operation = 'set' ); |
| 116 | |
| 117 | /** |
| 118 | * Get shipping class ID by slug. |
| 119 | * |
| 120 | * @param string $slug Shipping class slug. |
| 121 | * @return int|false |
| 122 | */ |
| 123 | public function get_shipping_class_id_by_slug( $slug ); |
| 124 | |
| 125 | /** |
| 126 | * Returns an array of products. |
| 127 | * |
| 128 | * @param array $args @see wc_get_products. |
| 129 | * @return array |
| 130 | */ |
| 131 | public function get_products( $args = array() ); |
| 132 | |
| 133 | /** |
| 134 | * Get the product type based on product ID. |
| 135 | * |
| 136 | * @param int $product_id Product ID. |
| 137 | * @return bool|string |
| 138 | */ |
| 139 | public function get_product_type( $product_id ); |
| 140 | } |
| 141 |