Plugin Directory

Changeset 2750161


Ignore:
Timestamp:
06/30/2022 10:42:04 AM (4 years ago)
Author:
chirpyweb
Message:

abandoned api changes

Location:
chirpyweb
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • chirpyweb/tags/1.2/includes/class-chirpyweb-init.php

    r2749139 r2750161  
    584584    public function chirpyweb_cart_data() {
    585585            $cart_session  = WC()->session->get( 'cw_cart_token' );
     586           
    586587            $wpurl         = get_bloginfo( 'wpurl' );
    587588            $cart_contents = WC()->cart->get_cart_contents();
     
    608609                        'value'           => $total,
    609610                        'is_abandoned'    => true,
     611                         'is_empty_cart'  => false,
    610612                        'cart_url'        => $cart_url,
    611613                        'website_key'     => $tokan,
     
    624626            $cart_val         = $response_code->detail;
    625627        }
     628       
     629        if( empty( $cart_contents ) ) {
     630            $total         = WC()->cart->get_subtotal();
     631                $temp     = array(
     632                        'subscription_id' => $sub_id,
     633                        'cart_id'         => $cart_session,
     634                        'value'           => $total,
     635                        'is_abandoned'    => true,
     636                         'is_empty_cart'  => true,
     637                        'cart_url'        => $cart_url,
     638                        'website_key'     => $tokan,
     639                    );
     640                    $response = wp_safe_remote_post(
     641                        CHIRPY_WP_API . 'wp/cart/',
     642                        array(
     643                            'headers' => array(
     644                                'x-website-key' => $tokan,
     645                                'x-website-url' => $wpurl,
     646                            ),
     647                            'body'    => $temp,
     648                        )
     649                    );
     650            $response_code    = json_decode( wp_remote_retrieve_body( $response ) );
     651            $cart_val         = $response_code->detail;
     652        }
     653       
    626654    }
    627655
     
    669697        $tokan    = $settings['token'];
    670698        $cart_url = wc_get_cart_url();
    671         $cart_id  = $order->get_meta( 'cw_cart_token' );
     699        $cart_id = WC()->session->get( 'cw_cart_token' );
    672700        update_post_meta( $order_id, 'subscription_id', $sub_id );
    673701        $order->save;
     
    678706                'value'           => $total,
    679707                'is_abandoned'    => false,
     708                'is_empty_cart'  =>  true,
    680709                'cart_url'        => $cart_url,
    681710                'website_key'     => $tokan,
  • chirpyweb/tags/1.2/readme.txt

    r2749139 r2750161  
    8383* Change the Short Description
    8484* Update error message
     85
     86
     87= 1.2 =
     88* Added All the Woocommerce push notification functionality
     89* Abandoned Cart Notifications
     90* Back in Stock Alerts
     91* Price Drop Alerts
     92* Shipping Order Tracking Alerts
  • chirpyweb/trunk/includes/class-chirpyweb-init.php

    r2749139 r2750161  
    584584    public function chirpyweb_cart_data() {
    585585            $cart_session  = WC()->session->get( 'cw_cart_token' );
     586           
    586587            $wpurl         = get_bloginfo( 'wpurl' );
    587588            $cart_contents = WC()->cart->get_cart_contents();
     
    608609                        'value'           => $total,
    609610                        'is_abandoned'    => true,
     611                         'is_empty_cart'  => false,
    610612                        'cart_url'        => $cart_url,
    611613                        'website_key'     => $tokan,
     
    624626            $cart_val         = $response_code->detail;
    625627        }
     628       
     629        if( empty( $cart_contents ) ) {
     630            $total         = WC()->cart->get_subtotal();
     631                $temp     = array(
     632                        'subscription_id' => $sub_id,
     633                        'cart_id'         => $cart_session,
     634                        'value'           => $total,
     635                        'is_abandoned'    => true,
     636                         'is_empty_cart'  => true,
     637                        'cart_url'        => $cart_url,
     638                        'website_key'     => $tokan,
     639                    );
     640                    $response = wp_safe_remote_post(
     641                        CHIRPY_WP_API . 'wp/cart/',
     642                        array(
     643                            'headers' => array(
     644                                'x-website-key' => $tokan,
     645                                'x-website-url' => $wpurl,
     646                            ),
     647                            'body'    => $temp,
     648                        )
     649                    );
     650            $response_code    = json_decode( wp_remote_retrieve_body( $response ) );
     651            $cart_val         = $response_code->detail;
     652        }
     653       
    626654    }
    627655
     
    669697        $tokan    = $settings['token'];
    670698        $cart_url = wc_get_cart_url();
    671         $cart_id  = $order->get_meta( 'cw_cart_token' );
     699        $cart_id = WC()->session->get( 'cw_cart_token' );
    672700        update_post_meta( $order_id, 'subscription_id', $sub_id );
    673701        $order->save;
     
    678706                'value'           => $total,
    679707                'is_abandoned'    => false,
     708                'is_empty_cart'  =>  true,
    680709                'cart_url'        => $cart_url,
    681710                'website_key'     => $tokan,
  • chirpyweb/trunk/readme.txt

    r2749139 r2750161  
    8383* Change the Short Description
    8484* Update error message
     85
     86
     87= 1.2 =
     88* Added All the Woocommerce push notification functionality
     89* Abandoned Cart Notifications
     90* Back in Stock Alerts
     91* Price Drop Alerts
     92* Shipping Order Tracking Alerts
Note: See TracChangeset for help on using the changeset viewer.