Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Register a line item in HubSpot
- *
- * @access public
- * @since 1.17
- * @return int Line Item ID
- */
- public function add_line_item( $product ) {
- $line_item_data = array(
- 'properties' => array(
- 'hs_product_id' => $product['crm_product_id'],
- 'name' => $product['name'],
- 'price' => $product['price'],
- 'quantity' => $product['qty'],
- ),
- );
- /**
- * Filters the deal data.
- *
- * @since 1.17.9
- *
- * @param array $line_item_data The array of data used to create the line item.
- * @param array $product The product data.
- */
- $line_item_data = apply_filters( 'wpf_ecommerce_hubspot_add_line_item', $line_item_data, $product );
- $params = wp_fusion()->crm->get_params();
- $params['body'] = json_encode( $line_item_data );
- $response = wp_remote_post( 'https://api.hubapi.com/crm/v3/objects/line_items', $params );
- if ( is_wp_error( $response ) ) {
- return $response;
- }
- $response = json_decode( wp_remote_retrieve_body( $response ) );
- return $response->id;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement