Plugin Directory

Changeset 2975548


Ignore:
Timestamp:
10/06/2023 12:03:48 PM (2 years ago)
Author:
pushalert
Message:

Added support for Product Name in abandoned cart notifications.

Location:
pushalert-web-push-notifications/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pushalert-web-push-notifications/trunk/pushalert.php

    r2908671 r2975548  
    66 * Author: PushAlert
    77 * Author URI: https://pushalert.co
    8  * Version: 2.8.0
     8 * Version: 2.8.1
    99 */
    1010
     
    923923
    924924function pa_custom_updated_cart(){
    925     $total_items = sizeof( WC()->cart->get_cart() );
     925    $total_items = WC()->cart->get_cart_contents_count();
    926926    if(current_filter()=="woocommerce_cart_item_removed" && $total_items==0){
    927927        //handled by woocommerce_cart_is_empty
     
    940940function pa_custom_cart_quantity_zero($cart_item_key){
    941941
    942     $total_items = sizeof( WC()->cart->get_cart() );
     942    $total_items = WC()->cart->get_cart_contents_count();
    943943    if($total_items-1>0){
    944944        //pa_clear_abandoned_cart();
     
    10321032    }
    10331033
    1034     if(get_option('pushalert_large_image', 0)){
    1035         $user_info['image'] = pushalert_get_product_image_url();
    1036     }
    1037 
    1038     $user_info['total_items'] = (!$total_items ? sizeof(WC()->cart->get_cart()) : $total_items);
     1034    $product_info = pushalert_get_cart_product_info();
     1035    if(get_option('pushalert_large_image', 0) && $product_info['image']!=""){
     1036        $user_info['image'] = $product_info['image'];
     1037    }
     1038    $user_info['product_name'] = $product_info['title'];
     1039
     1040    $user_info['total_items'] = (!$total_items ? WC()->cart->get_cart_contents_count() : $total_items);
    10391041    $pa_check_cookie = filter_input(INPUT_COOKIE, 'pushalert_'.pa_encrypt($curr_user->ID, get_option('pushalert_encrypt_key')));
    10401042    if($curr_user->ID!=0 && isset($pa_check_cookie) && $pa_check_cookie=='1'){
     
    10511053}
    10521054
    1053 function pushalert_get_product_image_url(){
     1055function pushalert_get_cart_product_info(){
     1056    $titles = [];
    10541057    $images = [];
    10551058    if (!WC()->cart->is_empty()) {
     
    10571060            $_product = $cart_item['data'];
    10581061            //$link = $_product->get_permalink();
    1059             //$title = $_product->get_title();
     1062            $title = $_product->get_title();
    10601063            //$price = $_product->get_price();
    10611064            $image_id = $_product->get_image_id();
     
    10681071            }
    10691072            $images[] = $image;
     1073            $titles[] = $title;
    10701074        }
    10711075    }
    10721076
    10731077    if (count($images) > 0) {
    1074         return $images[array_rand($images)];
     1078        $sel_index = array_rand($images);
     1079        return array("title"=>$titles[$sel_index], "image"=>$images[$sel_index]);
    10751080    } else {
    1076         return "";
     1081        return array("title"=>"", "image"=>"");
    10771082    }
    10781083}
     
    12411246
    12421247                global $woocommerce;
    1243                 $total_items = sizeof( WC()->cart->get_cart() );
     1248                $total_items = WC()->cart->get_cart_contents_count();
    12441249                if($total_item>0){
    12451250                    pa_clear_abandoned_cart();
     
    12841289
    12851290                global $woocommerce;
    1286                 $total_items = sizeof( WC()->cart->get_cart() );
     1291                $total_items = WC()->cart->get_cart_contents_count();
    12871292                if($total_items>0){
    12881293                    pa_clear_abandoned_cart();
  • pushalert-web-push-notifications/trunk/readme.txt

    r2943849 r2975548  
    55Requires at least: 2.7
    66Tested up to: 6.3
    7 Stable tag: 2.8.0
     7Stable tag: 2.8.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8484
    8585== Changelog ==
     86
     87= 2.8.1 =
     88* Added support for Product Name in abandoned cart notifications.
    8689
    8790= 2.8.0 =
Note: See TracChangeset for help on using the changeset viewer.