Plugin Directory

Changeset 3337697


Ignore:
Timestamp:
08/01/2025 10:00:43 AM (7 months ago)
Author:
worldweb
Message:

1.1.7 (Aug 1, 2025)

  • A new attribute allow_category has been added.
  • It allows you to display orders belonging to specific categories.
Location:
recently-purchased-products-for-woo
Files:
36 added
3 edited

Legend:

Unmodified
Added
Removed
  • recently-purchased-products-for-woo/trunk/includes/class-rppw-public.php

    r3273024 r3337697  
    3434         * @author     World Web Technology <[email protected]>
    3535         */
    36         public function get_recently_order($limit = 5, $order = 'DESC')
    37         {
    38             $args = array(
    39                 'post_type' => 'shop_order',
    40                 'post_status' => array('wc-completed', 'wc-processing'),
    41                 'posts_per_page' => $limit,
    42                 'orderby' => 'ID',
    43                 'order' => $order,
    44             );
    45             $orders_list = wc_get_orders($args);
    46             return $orders_list;
     36        public function get_recently_order($limit = 5, $order = 'DESC', $allow_category = '') {
     37            $args = array(
     38                'post_type' => 'shop_order',
     39                'post_status' => array('wc-completed', 'wc-processing'),
     40                'posts_per_page' => -1,
     41                'orderby' => 'ID',
     42                'order' => $order,
     43            );
     44
     45            $all_orders = wc_get_orders($args);
     46            $filtered_orders = array();
     47
     48            // Convert allow_category to array and trim values
     49            $allowed_categories = array_filter(array_map('trim', explode(',', $allow_category)));
     50
     51            foreach ($all_orders as $order) {
     52                $items = $order->get_items();
     53                $has_category_product = false;
     54
     55                foreach ($items as $item) {
     56                    $product_id = $item->get_product_id();
     57                    $terms = get_the_terms($product_id, 'product_cat');
     58
     59                    if (!empty($terms) && !is_wp_error($terms)) {
     60                        foreach ($terms as $term) {
     61                            // if term ID matches any allowed category ID.
     62                            if (empty($allow_category) ||
     63                                in_array($term->term_id, $allowed_categories) ||
     64                                in_array(strval($term->term_id), $allowed_categories)) {
     65                                    $has_category_product = true;
     66                                    break 2;
     67                            }
     68                        }
     69                    }
     70                }
     71
     72                if ($has_category_product) {
     73                    $filtered_orders[] = $order;
     74                    if (count($filtered_orders) >= $limit) {
     75                        break;
     76                    }
     77                }
     78            }
     79
     80            return $filtered_orders;
    4781        }
    4882        /**
     
    66100                'price' => 'show',
    67101                'category' => 'show',
     102                'allow_category' => '',
    68103                'cart' => 'show',
    69104                'rating' => 'show',
     
    114149            } else {
    115150                $category = '';
     151            }
     152
     153            if(!empty($atts['allow_category'])) {
     154                $allow_category = $atts['allow_category'];
     155            } else {
     156                $allow_category = '';
    116157            }
    117158
     
    147188                $out .= '<div class="rppw_order_title">' . esc_html($title) . '</div>';
    148189            }
    149             $orders_list = $this->get_recently_order($limit, $order);
     190            $orders_list = $this->get_recently_order($limit, $order, $allow_category);
    150191            wp_enqueue_style('rppw-css');
    151192            $columns = $col_class = '';
     
    290331                'limit' => 5,
    291332                'category' => 'show',
     333                'allow_category' => '',
    292334                'cart' => 'show',
    293335                'rating' => 'show',
     
    316358            $price = strtolower($atts['price']);
    317359            $category = strtolower($atts['category']);
     360            $allow_category = $atts['allow_category'];
    318361            $cart = strtolower($atts['cart']);
    319362            $customer_info = strtolower($atts['customer_info']);
     
    331374                $out .= '<div class="rppw_order_title"><h2>' . sanitize_text_field(trim($title)) . '</h2></div>';
    332375            }
    333             $orders_list = $this->get_recently_order($limit, $order);
     376            $orders_list = $this->get_recently_order($limit, $order, $allow_category);
    334377            //Load Slick plugin CSS file
    335378            wp_enqueue_style('rppw-slick-style');
  • recently-purchased-products-for-woo/trunk/readme.txt

    r3273024 r3337697  
    1010Requires PHP:      7.4
    1111Tested up to:      6.8
    12 Stable tag:        1.1.6
     12Stable tag:        1.1.7
    1313License:           GPLv2 or later
    1414License URI:       https://www.gnu.org/licenses/gpl-2.0.html
    15 Version:           1.1.6
     15Version:           1.1.7
    1616
    1717Display Recently Purchased Products For Woocommerce using Widget and Shortcode
     
    3434You can use the shortcode to dispaly list of recently purchased products. Here's an example of how you can show the recently purchased 6 products with grid view:
    3535
    36 `[recently_purchased_products limit="8" view="grid" category="hide" grid_cols="4" img_size="150" img_type="product" cart="Show" rating="show" customer_info="show"]`
     36`[recently_purchased_products allow_category="" limit="8" view="grid" category="hide" grid_cols="4" img_size="150" img_type="product" cart="Show" rating="show" customer_info="show"]`
    3737
    3838Below are the shortcode supported options:
    3939
    4040* title: Display the title on top of listing. Default is empty.
     41* allow_category: It allows you to display orders belonging to specific categories. Leave blank to display for all categories.
    4142* limit: Used to limit the number of products. Default is 5.
    4243* order: Order of listing either ASC or DESC. Default is DESC.
     
    5556Here's an example of how you can show the recently purchased 6 products with Slider view:
    5657
    57 `[recently_purchased_products_slider title="" limit="6" category="show" cart="Show" rating="hide" order="DESC"  img="show" img_size'="150"  img_type="product" customer_info="first_name" date="show" price="show"  slidestoshow="4" slidestoscroll="1" autoplay="true" dots="true" arrow="true" infinite="true"]`
     58`[recently_purchased_products_slider title="" allow_category="" limit="6" category="show" cart="Show" rating="hide" order="DESC"  img="show" img_size'="150"  img_type="product" customer_info="first_name" date="show" price="show"  slidestoshow="4" slidestoscroll="1" autoplay="true" dots="true" arrow="true" infinite="true"]`
    5859
    5960Below are the shortcode supported options:
    6061
    6162* title: Display the title on top of Slider. Default is empty.
     63* allow_category: It allows you to display orders belonging to specific categories. Leave blank to display for all categories.
    6264* limit: Used to limit the number of products. Default is 5.
    6365* category: Show or hide the product category. Default is Show.
     
    153155== Changelog ==
    154156
     157= 1.1.7 (Aug 1, 2025) =
     158* A new attribute allow_category has been added.
     159* It allows you to display orders belonging to specific categories.
     160
    155161= 1.1.6 (Apr 15, 2025) =
    156162* Fixes depreciation errors with WordPress version 6.8 and PHP 8.2
  • recently-purchased-products-for-woo/trunk/recently-purchased-products-for-woo.php

    r3273024 r3337697  
    44 * Plugin URI: https://wordpress.org/plugins/recently-purchased-products-for-woo
    55 * Description: Display Recently Purchased Products For Woocommerce using Widget and Shortcode
    6  * Version: 1.1.6
     6 * Version: 1.1.7
    77 * Author: World Web Technology
    88 * Author URI: http://www.worldwebtechnology.com
     
    3333 */
    3434if( !defined( 'RPPW_VERSION' ) ) {
    35     define( 'RPPW_VERSION', '1.1.6' ); // Plugin Version
     35    define( 'RPPW_VERSION', '1.1.7' ); // Plugin Version
    3636}
    3737
Note: See TracChangeset for help on using the changeset viewer.