Advertisement
verygoodplugins

Untitled

Apr 21st, 2021
1,253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1.     public function change_stage( $deal_id, $stage ) {
  2.  
  3.         $pipeline_stage = explode( '+', $stage );
  4.  
  5.         $deal = array(
  6.             'properties' => array(
  7.                 array(
  8.                     'name'  => 'pipeline',
  9.                     'value' => $pipeline_stage[0],
  10.                 ),
  11.                 array(
  12.                     'name'  => 'dealstage',
  13.                     'value' => $pipeline_stage[1],
  14.                 ),
  15.             ),
  16.         );
  17.  
  18.         $params = wp_fusion()->crm->get_params();
  19.  
  20.         /**
  21.          * Filters the deal when changing the stage.
  22.          *
  23.          * @since 1.17.9
  24.          *
  25.          * @param array $deal    The deal data.
  26.          * @param int   $deal_id The deal ID to be updated.
  27.          */
  28.  
  29.         $deal = apply_filters( 'wpf_ecommerce_hubspot_change_deal_stage', $deal, $deal_id );
  30.  
  31.         $params['body']   = json_encode( $deal );
  32.         $params['method'] = 'PUT';
  33.  
  34.         $response = wp_remote_request( 'https://api.hubapi.com/deals/v1/deal/' . $deal_id, $params );
  35.  
  36.         if ( is_wp_error( $response ) ) {
  37.             return $response;
  38.         }
  39.  
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement