verygoodplugins

Untitled

Apr 13th, 2021
428
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. /**
  3.  * Register a line item in HubSpot
  4.  *
  5.  * @access  public
  6.  * @since   1.17
  7.  * @return  int Line Item ID
  8.  */
  9.  
  10. public function add_line_item( $product ) {
  11.  
  12.     $line_item_data = array(
  13.         'properties' => array(
  14.             'hs_product_id' => $product['crm_product_id'],
  15.             'name'          => $product['name'],
  16.             'price'         => $product['price'],
  17.             'quantity'      => $product['qty'],
  18.         ),
  19.     );
  20.  
  21.     /**
  22.      * Filters the deal data.
  23.      *
  24.      * @since 1.17.9
  25.      *
  26.      * @param array $line_item_data The array of data used to create the line item.
  27.      * @param array $product        The product data.
  28.      */
  29.  
  30.     $line_item_data = apply_filters( 'wpf_ecommerce_hubspot_add_line_item', $line_item_data, $product );
  31.  
  32.     $params         = wp_fusion()->crm->get_params();
  33.     $params['body'] = json_encode( $line_item_data );
  34.     $response       = wp_remote_post( 'https://api.hubapi.com/crm/v3/objects/line_items', $params );
  35.  
  36.     if ( is_wp_error( $response ) ) {
  37.         return $response;
  38.     }
  39.  
  40.     $response = json_decode( wp_remote_retrieve_body( $response ) );
  41.  
  42.     return $response->id;
  43.  
  44. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×