Plugin Directory

Changeset 2908671


Ignore:
Timestamp:
05/05/2023 06:40:15 PM (3 years ago)
Author:
pushalert
Message:

Featured image as large image in WooCommerce abandoned cart notifications.

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

Legend:

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

    r2881114 r2908671  
    66 * Author: PushAlert
    77 * Author URI: https://pushalert.co
    8  * Version: 2.7.0
     8 * Version: 2.8.0
    99 */
    1010
     
    10321032    }
    10331033
     1034    if(get_option('pushalert_large_image', 0)){
     1035        $user_info['image'] = pushalert_get_product_image_url();
     1036    }
     1037
    10341038    $user_info['total_items'] = (!$total_items ? sizeof(WC()->cart->get_cart()) : $total_items);
    10351039    $pa_check_cookie = filter_input(INPUT_COOKIE, 'pushalert_'.pa_encrypt($curr_user->ID, get_option('pushalert_encrypt_key')));
     
    10451049    }
    10461050
     1051}
     1052
     1053function pushalert_get_product_image_url(){
     1054    $images = [];
     1055    if (!WC()->cart->is_empty()) {
     1056        foreach (WC()->cart->get_cart() as $cart_item) {
     1057            $_product = $cart_item['data'];
     1058            //$link = $_product->get_permalink();
     1059            //$title = $_product->get_title();
     1060            //$price = $_product->get_price();
     1061            $image_id = $_product->get_image_id();
     1062
     1063            $image = wp_get_attachment_image_src($image_id, 'single-post-thumbnail');
     1064            if (!$image) {
     1065                $image = wp_get_attachment_image_url($image_id, 'full');
     1066            } else {
     1067                $image = $image[0];
     1068            }
     1069            $images[] = $image;
     1070        }
     1071    }
     1072
     1073    if (count($images) > 0) {
     1074        return $images[array_rand($images)];
     1075    } else {
     1076        return "";
     1077    }
    10471078}
    10481079
  • pushalert-web-push-notifications/trunk/readme.txt

    r2893516 r2908671  
    55Requires at least: 2.7
    66Tested up to: 6.2
    7 Stable tag: 2.7.0
     7Stable tag: 2.8.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8484
    8585== Changelog ==
     86
     87= 2.8.0 =
     88* Featured image use extended to WooCommerce abandoned cart notifications. Now an image of the product will be shown as large image in the notification.
    8689
    8790= 2.7.0 =
Note: See TracChangeset for help on using the changeset viewer.