Plugin Directory

Changeset 2336028


Ignore:
Timestamp:
07/06/2020 12:35:23 PM (6 years ago)
Author:
platformlycom
Message:

Updated abandoned cart functionality

Location:
platformly-for-woocommerce/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • platformly-for-woocommerce/trunk/includes/class-abandoned-cart.php

    r2304947 r2336028  
    5151        }
    5252
    53         $cart_data = json_encode($current_cart);
    5453        $user_id = get_current_user_id();
     54        // Get cart total data
     55        $current_cart_totals = WC()->session->cart_totals;
     56        if(empty($current_cart_totals)){
     57            $current_cart_totals = [];
     58        }
     59
     60        $cart_data = json_encode([
     61            'cart' => $current_cart,
     62            'cart_totals' => $current_cart_totals,
     63        ]);
    5564
    5665        global $wpdb;
  • platformly-for-woocommerce/trunk/includes/class-platformly-woocommerce-rest-api.php

    r2304947 r2336028  
    179179
    180180            $cart_data = json_decode($abandoned_cart->cart_data, true);
     181
    181182            $cart = array();
    182             foreach ($cart_data as $_item) {
     183            if(isset($cart_data['cart'])){
     184                $data = $cart_data['cart'];
     185            }else{
     186                $data = $cart_data;
     187            }
     188            foreach ($data as $_item) {
    183189                $product = wc_get_product( $_item['product_id'] );
    184190
     
    191197                    'price' => $product->get_price(),
    192198                    'currency' => get_woocommerce_currency_symbol(),
    193                     'quantity' => $_item['quantity']
     199                    'quantity' => $_item['quantity'],
     200                    'subtotal' => $_item['line_subtotal'],
     201                    'total' => $_item['line_total'],
     202                    'tax' => $_item['line_tax']
    194203                );
    195204                $cart[$product_id] = $item;
     
    203212                'last_name' => $user_meta['last_name'][0],
    204213                'cart' => $cart,
    205                 'ply_wc_restore_cart' => $restore_cart_key
     214                'ply_wc_restore_cart' => $restore_cart_key,
     215                'cart_totals' => isset($cart_data['cart_totals']) ? $cart_data['cart_totals'] : []
    206216            );
    207217
  • platformly-for-woocommerce/trunk/platformly-for-woocommerce.php

    r2304947 r2336028  
    44 * Plugin Name: Platform.ly for WooCommerce
    55 * Description: Easily connect WooCommerce to your Platformly CRM, set up abandoned cart campaigns and access detailed customer reporting: lifetime value and more...
    6  * Version: 1.0
     6 * Version: 1.1
    77 * Author: Platform.ly
    88 * Author URI: https://www.platform.ly/
    99 *
    1010 * WC requires at least: 3.5.0
    11  * WC tested up to: 4.0.1
     11 * WC tested up to: 4.2.2
    1212 *
    1313 * License: GPL-2.0+
     
    867867
    868868    private function set_ply_activity($event) {
    869         if (session_id() === '') {
    870             session_start();
    871         }
    872869        $event['time'] = time();
    873         $_SESSION['ply_activity'][] = $event;
     870        $ply_activity = $this->get_ply_activity();
     871        if(!is_array($ply_activity)){
     872            $ply_activity = [];
     873        }
     874        $ply_activity[] = $event;
     875        platform_wc_set_wc_session('ply_activity', $ply_activity);
    874876    }
    875877
    876878    private function get_ply_activity() {
    877         if (session_id() === '') {
    878             session_start();
    879         }
    880         return !empty($_SESSION['ply_activity']) ? $_SESSION['ply_activity'] : false;
     879        return platform_wc_get_wc_session('ply_activity');
    881880    }
    882881
    883882    private function unset_ply_activity() {
    884         if (isset($_SESSION['ply_activity'])) {
    885             unset($_SESSION['ply_activity']);
    886         }
     883        platform_wc_unset_wc_session('ply_activity');
    887884    }
    888885
  • platformly-for-woocommerce/trunk/readme.txt

    r2304947 r2336028  
    118118
    119119= 1.0 =
    120 Initial release. No previous versions are available.
     120* Initial release. No previous versions are available.
     121
     122= 1.1 =
     123* Updated abandoned cart functionality
    121124
    122125== Upgrade Notice ==
    123126
    124127= 1.0 =
    125 Initial release. No previous versions are available.
     128* Initial release. No previous versions are available.
     129
     130= 1.1 =
     131* Updated abandoned cart functionality
Note: See TracChangeset for help on using the changeset viewer.