Plugin Directory

Changeset 3022575


Ignore:
Timestamp:
01/16/2024 06:11:45 PM (2 years ago)
Author:
api2cartdev
Message:

Added webhooks 'Category Created, Category Updated, Category Deleted'

Location:
api2cart-webhook-helper/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • api2cart-webhook-helper/trunk/a2c-webhook-helper.php

    r2964488 r3022575  
    44Description: The plugin adds extra webhook topics for WooCommerce.
    55Author: API2Cart
    6 Version: 1.6.6
     6Version: 1.7
    77Author URI: https://api2cart.com/
    88License:      GPL2
  • api2cart-webhook-helper/trunk/app/WH_Helper.php

    r2964488 r3022575  
    99{
    1010
    11   const VERSION                    = '1.6.6';
     11  const VERSION                    = '1.7';
    1212  const LANG_DOMAIN                = 'a2c_wh';
    1313
     
    6565    add_action( 'woocommerce_update_product_variation', array( $this, 'updateChild' ), 29, 2);
    6666    add_action( 'woocommerce_before_delete_product_variation', array( $this, 'deleteChild' ), 29, 1);
     67
     68    add_action( 'create_product_cat', array( $this, 'afterCategoryInsert' ), 29, 3);
     69    add_action( 'edited_product_cat', array( $this, 'afterCategoryUpdate' ), 29, 4);
     70    add_action( 'delete_term_taxonomy', array( $this, 'afterCategoryDelete' ), 29, 4);
    6771
    6872    $this->_blogId = get_current_blog_id();
     
    236240
    237241    do_action('a2c_wh_variant_deleted_action', ['store_id' => $this->_blogId, 'parent_id' => $parent->post_parent, 'id' => $id]);
     242  }
     243
     244  /**
     245   * @param $term_id
     246   */
     247  function afterCategoryInsert($term_id) {
     248    do_action('a2c_wh_category_created_action', ['store_id' => $this->_blogId, 'id' => $term_id]);
     249  }
     250
     251  /**
     252   * @param $term_id
     253   */
     254  function afterCategoryUpdate($term_id) {
     255    do_action('a2c_wh_category_updated_action', ['store_id' => $this->_blogId, 'id' => $term_id]);
     256  }
     257
     258  /**
     259   * @param $term_id
     260   */
     261  function afterCategoryDelete($term_id) {
     262    do_action('a2c_wh_category_deleted_action', ['store_id' => $this->_blogId, 'id' => $term_id]);
    238263  }
    239264
     
    288313    $resources[] = 'order_shipment';
    289314    $resources[] = 'variant';
     315    $resources[] = 'category';
    290316
    291317    return $resources;
     
    311337        'variant.updated' => __( 'Variant Updated', 'a2c_wh' ),
    312338        'variant.deleted' => __( 'Variant Deleted', 'a2c_wh' ),
     339        'category.created' => __( 'Category Created', 'a2c_wh' ),
     340        'category.updated' => __( 'Category Updated', 'a2c_wh' ),
     341        'category.deleted' => __( 'Category Deleted', 'a2c_wh' ),
    313342      )
    314343    );
     
    604633      'a2c_wh_variant_deleted_action',
    605634    );
     635    $topics['category.created'] = array(
     636      'a2c_wh_category_created_action',
     637    );
     638    $topics['category.updated'] = array(
     639      'a2c_wh_category_updated_action',
     640    );
     641    $topics['category.deleted'] = array(
     642      'a2c_wh_category_deleted_action',
     643    );
    606644
    607645    return $topics;
     
    617655  public function buildWebhookPayload($payload, $resource, $resource_id)
    618656  {
    619     if ( in_array($resource, ['basket', 'order_shipment', 'variant'] )) {
     657    if ( in_array($resource, ['basket', 'order_shipment', 'variant', 'category'] )) {
    620658      $payload = $resource_id;
    621659    }
  • api2cart-webhook-helper/trunk/readme.txt

    r3006762 r3022575  
    55Requires at least: 4.1
    66Tested up to: 6.5
    7 Stable tag: 1.6.6
     7Stable tag: 1.7
    88License:      GPL2
    99License URI:  https://www.gnu.org/licenses/gpl-2.0.html
     
    4848
    4949== Changelog ==
     50= 1.7 =
     51* Added webhooks 'Category Created, Category Updated, Category Deleted'
     52
    5053= 1.6.6 =
    5154* Fix bugs
Note: See TracChangeset for help on using the changeset viewer.