PluginProbe ʕ •ᴥ•ʔ
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). / 2.3.3
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). v2.3.3
3.0.3 3.0.2 3.0.1 trunk 2.2.14 2.2.15 2.2.16 2.2.17 2.2.18 2.2.19 2.3.0 2.3.1 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.7.91 2.7.92 2.7.93 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0
commercebird / includes / classes / apis / class-api-for-cmbird.php
commercebird / includes / classes / apis Last commit date
class-api-for-cmbird.php 1 year ago class-api-for-exact-webhooks.php 1 year ago class-api-for-product-webhook.php 1 year ago class-api-for-shipping-status.php 1 year ago class-api-for-woo-order.php 1 year ago class-api-for-zoho-inventory.php 1 year ago class-commercebird-list-items-api-controller.php 1 year ago class-commercebird-media-api-controller.php 1 year ago class-commercebird-metadata-controller.php 1 year ago index.php 1 year ago trait-api-permission.php 1 year ago
class-api-for-cmbird.php
57 lines
1 <?php
2
3 namespace CommerceBird\API;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 use WP_REST_Response;
10 use WP_REST_Server;
11 use WP_REST_Controller;
12
13 class CMBird_APIs extends WP_REST_Controller {
14
15 protected $prefix = 'wc/v3';
16 protected $rest_base = 'cmbird';
17
18 public function __construct() {
19 register_rest_route(
20 $this->prefix,
21 '/' . $this->rest_base . '/products-skus/',
22 array(
23 'methods' => WP_REST_Server::READABLE,
24 'callback' => array( $this, 'get_all_product_with_skus' ),
25 'permission_callback' => array( $this, 'permission_check' ),
26 )
27 );
28 }
29
30 /**
31 * Check if a given request has access to get items.
32 */
33 public function permission_check() {
34 return current_user_can( 'manage_woocommerce' );
35 }
36
37 public function get_all_product_with_skus(): WP_REST_RESPONSE {
38 $rest_response = new WP_REST_Response();
39 $rest_response->set_data( $this->empty_response );
40 $rest_response->set_status( 200 );
41
42 global $wpdb;
43
44 // Query to fetch product IDs and SKUs directly from the database
45 $results = $wpdb->get_results( "
46 SELECT p.ID as product_id, pm.meta_value as sku, p.post_type as product_type
47 FROM {$wpdb->posts} p
48 LEFT JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id AND pm.meta_key = '_sku'
49 WHERE p.post_type IN ('product', 'product_variation') AND p.post_status = 'publish'
50 " );
51
52 $rest_response->set_data( $results );
53
54 return rest_ensure_response( $rest_response );
55 }
56 }
57