PluginProbe ʕ •ᴥ•ʔ
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). / 2.7.5
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). v2.7.5
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 / class-wc-api.php
commercebird / includes / classes Last commit date
apis 4 months ago purchase-orders 5 months ago zoho-crm 7 months ago zoho-inventory 4 months ago class-api-handler-zoho.php 7 months ago class-auth-zoho.php 7 months ago class-common.php 7 months ago class-plugin.php 5 months ago class-wc-api.php 5 months ago index.php 1 year ago
class-wc-api.php
75 lines
1 <?php
2
3 namespace CommerceBird;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 /**
10 * Extending the WC API with our custom endpoints.
11 *
12 * @author Fawad Tiemoerie <info@roadmapstudios.com>
13 * @since 2.0.0
14 */
15 class Cmbird_WC_API {
16
17 /**
18 * Constructor.
19 */
20 public function __construct() {
21 add_action( 'rest_api_init', array( $this, 'register_routes' ), 15 );
22 }
23
24 public function register_routes() {
25 global $wp_version;
26 if ( version_compare( $wp_version, 6.0, '<' ) ) {
27 return;
28 }
29 $api_classes = array(
30 'CMBIRD_Media_API_Controller',
31 'CMBIRD_Metadata_API_Controller',
32 'CMBIRD_List_Items_API_Controller',
33 );
34 foreach ( $api_classes as $api_class ) {
35 $controller = new $api_class();
36 $controller->register_routes();
37 }
38 // register cost_price as meta field for products.
39 // TODO: remove this when launching Nextjs App.
40 register_rest_field(
41 'product',
42 '_cost_price',
43 array(
44 'get_callback' => array( $this, 'cmbird_get_product_field' ),
45 'update_callback' => array( $this, 'cmbird_update_product_field' ),
46 'schema' => null,
47 )
48 );
49 }
50
51 /**
52 * Get meta field value.
53 *
54 * @param mixed $object
55 * @param mixed $object
56 * @param mixed $field_name
57 * @param mixed $request
58 * @return mixed
59 */
60 public function cmbird_get_product_field( $object, $field_name, $request ) {
61 return get_post_meta( $object['id'], $field_name, true );
62 }
63 /**
64 * Update meta field value.
65 *
66 * @param mixed $value
67 * @param mixed $object
68 * @param mixed $field_name
69 * @return bool|int
70 */
71 public function cmbird_update_product_field( $value, $object, $field_name ) {
72 return update_post_meta( $object->id, $field_name, $value );
73 }
74 }
75