Changeset 2999217
- Timestamp:
- 11/20/2023 07:32:13 PM (2 years ago)
- Location:
- shop-2-api/trunk
- Files:
-
- 3 edited
-
includes/Base/EnqueueWCAPI.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
-
shop-2-api.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shop-2-api/trunk/includes/Base/EnqueueWCAPI.php
r2975851 r2999217 39 39 40 40 $args = array( 41 'post_type' => 'product',41 'post_type' => array('product', 'product_variation'), 42 42 'meta_query' => array( 43 43 array( … … 51 51 $query = new WP_Query( $args ); 52 52 if ( $query->have_posts() ) { 53 $products = array(); 54 while ( $query->have_posts() ) { 55 $query->the_post(); 56 $product = new WC_Product(get_the_ID()); 57 $products[] = array( 58 'id' => get_the_ID(), 59 'name' => get_the_title(), 60 'price' => $product->get_price(), 61 'meta_key' => $meta_key, 62 'meta_value' => $meta_value, 63 'stock_quantity' => $product->get_stock_quantity() 64 ); 65 } 53 $products = $this->getProducts($query, $meta_key, $meta_value); 66 54 return rest_ensure_response( $products ); 67 55 } else { … … 69 57 } 70 58 } 59 60 /** 61 * @param WP_Query $query 62 * @param mixed $meta_key 63 * @param $meta_value 64 * @return array 65 */ 66 public function getProducts(WP_Query $query, mixed $meta_key, $meta_value): array 67 { 68 $products = array(); 69 while ($query->have_posts()) { 70 $query->the_post(); 71 $current_post_id = get_the_ID(); 72 $current_post_type = get_post_type($current_post_id); 73 if ($current_post_type === 'product_variation') { 74 $product = new WC_Product_Variation($current_post_id); 75 } else { 76 $product = new WC_Product(get_the_ID()); 77 } 78 79 $products[] = array( 80 'id' => get_the_ID(), 81 'name' => get_the_title(), 82 'price' => $product->get_price(), 83 'meta_key' => $meta_key, 84 'meta_value' => $meta_value, 85 'stock_quantity' => $product->get_stock_quantity() 86 ); 87 } 88 return $products; 89 } 71 90 } -
shop-2-api/trunk/readme.txt
r2983482 r2999217 159 159 3) Dashboard Changes 160 160 4) Added Alert on Order Failing Option 161 5) Fix bug where product variants is not retrieved 161 162 162 163 -
shop-2-api/trunk/shop-2-api.php
r2983482 r2999217 5 5 Plugin URI: https://wordpress.org/plugins/shop-2-api/ 6 6 Description: The plugin Shop2Api will sync products between e-Commerce platforms. The current supported e-Commerce platforms are WooCommerce to Bol.com, and we are working on Amazon, Shopify and others. We added a koopblok service so that you can check if you lower your price can you get koopblok. 7 Version: 1.0.28. 37 Version: 1.0.28.4 8 8 Requires at least: 5.0 9 9 Requires PHP: 7.2 … … 34 34 define('SHOP2API_PLUGIN_URL', plugin_dir_url( __FILE__ )); 35 35 define('SHOP2API_PLUGIN', plugin_basename( __FILE__ )); 36 define ('VERSION', '1.0.28. 3');36 define ('VERSION', '1.0.28.4'); 37 37 38 38 // Register items in the project.
Note: See TracChangeset
for help on using the changeset viewer.