• Hello,
    I use your plugin because is very good and easy to use and configure.
    I wonder how can I send and receive product data through woocommerce rest api v3.
    I am using “product created” hook to deliver the payload. But I am not receiving product options in my json data.
    Is it possible that we could store our options in product meta in json format, and that will be automatically send through woocommerce webhooks?

    I will be waiting for your reply.
    Best regards,
    Nabeel Tariq

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Pektsekye

    (@pektsekye)

    Hello,

    I think it is possible.
    I don’t have time to help you with it now.

    Stanislav

    Plugin Author Pektsekye

    (@pektsekye)

    Hello,

    You can add the line:

    
        add_action('woocommerce_webhook_payload', array($this, 'add_options_to_woocommerce_webhook_payload'), 10, 3);
    

    after the line:

    
      add_action('delete_post', array($this, 'delete_post')); 
    

    and add the function:

    
      function add_options_to_woocommerce_webhook_payload($payload, $resource, $resource_id) {
        if ($resource == 'product'){
          $productId = $resource_id;  
          $payload["product_options"] = $this->getOptionModel()->getProductOptions($productId);    
        }      
        return $payload;
      }
    

    before the line:

    
      public function getOptionModel(){
    

    in the file:
    wp-content/plugins/product_options_for_woocommerce/Model/Observer.php

    so that the payload will have the product_options data:

    
        [product_options] => Array
            (
                [16] => Array
                    (
                        [option_id] => 16
                        [product_id] => 585
                        [title] => gg
                        [price] => 0.00
                        [type] => drop_down
                        [required] => 1
                        [sort_order] => 1
                        [values] => Array
                            (
                                [160] => Array
                                    (
                                        [value_id] => 160
                                        [option_id] => 16
                                        [product_id] => 585
                                        [title] => gggg
                                        [price] => 0.00
                                        [sort_order] => 1
                                    )
    
                            )
    
                    )
    
            )
    

    Stanislav

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Webhooks Support’ is closed to new replies.