PluginProbe ʕ •ᴥ•ʔ
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). / 2.3.14
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). v2.3.14
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 11 months ago purchase-orders 1 year ago zoho-crm 1 year ago zoho-inventory 11 months ago class-api-handler-zoho.php 11 months ago class-auth-zoho.php 1 year ago class-common.php 1 year ago class-plugin.php 11 months ago class-wc-api.php 1 year ago index.php 1 year ago
class-wc-api.php
73 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 register_rest_field(
40 'product',
41 '_cost_price',
42 array(
43 'get_callback' => array( $this, 'cmbird_get_product_field' ),
44 'update_callback' => array( $this, 'cmbird_update_product_field' ),
45 'schema' => null,
46 )
47 );
48 }
49
50 /**
51 * Get meta field value.
52 *
53 * @param mixed $object
54 * @param mixed $object
55 * @param mixed $field_name
56 * @param mixed $request
57 * @return mixed
58 */
59 public function cmbird_get_product_field( $object, $field_name, $request ) {
60 return get_post_meta( $object['id'], $field_name, true );
61 }
62 /**
63 * Update meta field value.
64 * @param mixed $value
65 * @param mixed $object
66 * @param mixed $field_name
67 * @return bool|int
68 */
69 public function cmbird_update_product_field( $value, $object, $field_name ) {
70 return update_post_meta( $object->id, $field_name, $value );
71 }
72 }
73