Plugin Directory

Changeset 3401163


Ignore:
Timestamp:
11/23/2025 07:27:25 AM (4 months ago)
Author:
shibhuplugins
Message:

1.4.3 bug fixes

Location:
elegant-labels
Files:
439 added
3 edited

Legend:

Unmodified
Added
Removed
  • elegant-labels/trunk/elegant-labels.php

    r3390102 r3401163  
    44 * Description: Labels and Badges for WooCommerce
    55 * Author: shibhuplugins
    6  * Version: 1.4.2
     6 * Version: 1.4.3
    77 * Text Domain: elegant-labels
    88 * Requires Plugins: woocommerce
  • elegant-labels/trunk/inc/class-elegant-badge-integration.php

    r3382659 r3401163  
    152152    /**
    153153     * Display badges on product loop (shop/category pages)
     154     * FIXED: Properly setup post data for each product in loop
    154155     */
    155156    public function display_badges_on_product_loop() {
    156157        global $product;
    157158       
     159        // Ensure we have the correct product in loop context
    158160        if (!$product || !is_a($product, 'WC_Product')) {
    159             return;
     161            // Try to get product from current post
     162            $product = wc_get_product(get_the_ID());
     163            if (!$product) {
     164                return;
     165            }
    160166        }
    161167       
    162168        $product_id = $product->get_id();
     169       
     170        // Make sure we're working with the correct product
     171        if (get_the_ID() != $product_id) {
     172            $product = wc_get_product(get_the_ID());
     173            if (!$product) {
     174                return;
     175            }
     176            $product_id = $product->get_id();
     177        }
     178       
    163179        $badges = $this->get_applicable_badges_by_placement($product_id, 'check1');
    164 
    165180       
    166181        if (empty($badges)) {
     
    177192    /**
    178193     * Display badges on single product image gallery
     194     * FIXED: Only display on main product page, skip in loops
    179195     */
    180196    public function display_badges_on_single_gallery() {
     197        // Only show on actual single product page
     198        if (!is_product()) {
     199            return;
     200        }
     201       
    181202        global $product;
    182203       
     
    185206        }
    186207       
    187         $product_id = $product->get_id();
    188         $badges = $this->get_applicable_badges_by_placement($product_id, 'check2');
     208        // Get the main queried product ID
     209        $main_product_id = get_queried_object_id();
     210        $current_product_id = $product->get_id();
     211       
     212        // Only show badges on the main product being viewed
     213        if ($main_product_id !== $current_product_id) {
     214            return;
     215        }
     216       
     217        $badges = $this->get_applicable_badges_by_placement($current_product_id, 'check2');
    189218       
    190219        if (empty($badges)) {
     
    201230    /**
    202231     * Display badges on single product details section
     232     * FIXED: Only display on main product page, skip in loops
    203233     */
    204234    public function display_badges_on_single_details() {
     235        // Only show on actual single product page
     236        if (!is_product()) {
     237            return;
     238        }
     239       
    205240        global $product;
    206241       
     
    209244        }
    210245       
    211         $product_id = $product->get_id();
    212         $badges = $this->get_applicable_badges_by_placement($product_id, 'check3');
     246        // Get the main queried product ID
     247        $main_product_id = get_queried_object_id();
     248        $current_product_id = $product->get_id();
     249       
     250        // Only show badges on the main product being viewed
     251        if ($main_product_id !== $current_product_id) {
     252            return;
     253        }
     254       
     255        $badges = $this->get_applicable_badges_by_placement($current_product_id, 'check3');
    213256       
    214257        if (empty($badges)) {
     
    226269     * Get badges that apply to a specific product and placement
    227270     * This is public so helper functions can access it
     271     * FIXED: Properly preserve and restore global $product variable
    228272     *
    229273     * @param int $product_id The WooCommerce product ID
     
    232276     */
    233277    public function get_applicable_badges_by_placement($product_id, $placement_check) {
     278        global $product, $post;
     279       
     280        // Store the current product and post to restore later
     281        $original_product = $product;
     282        $original_post = $post;
     283       
    234284        // Query all published labels that have conditions
    235285        $labels_query = new WP_Query([
     
    269319       
    270320        wp_reset_postdata();
     321       
     322        // CRITICAL FIX: Restore the original product and post globals
     323        $product = $original_product;
     324        $post = $original_post;
     325       
     326        // Also ensure post data is properly set up
     327        if ($original_post) {
     328            setup_postdata($original_post);
     329        }
    271330       
    272331        return $applicable_badges;
     
    324383    /**
    325384     * Render a single badge with proper HTML structure and classes
     385     * FIXED: Ensure we're using the correct product in loop context
    326386     *
    327387     * @param array $badge The badge data
     
    330390    private function render_badge($badge, $context = 'loop') {
    331391        global $product;
     392       
     393        // For loop context, ensure we have the correct product from the current post
     394        if ($context === 'loop') {
     395            $current_post_id = get_the_ID();
     396            if ($product && $product->get_id() != $current_post_id) {
     397                $product = wc_get_product($current_post_id);
     398            }
     399        }
    332400       
    333401        // Build CSS classes for the badge
  • elegant-labels/trunk/readme.txt

    r3390102 r3401163  
    1 === Elegant Labels - Unlimited free Labels and Badges for WooCommerce ===
     1=== Unlimited Product Labels and Product Badges for WooCommerce - Elegant Labels ===
    22Contributors: shibhuplugins
    3 Tags: woocommerce, labels, badges, woocommerce labels
     3Tags: woocommerce, labels, badges, woocommerce labels, product labels, product badges
    44Requires at least: 4.0
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 1.4.2
     7Stable tag: 1.4.3
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1414Transform your WooCommerce store with stunning, eye-catching product labels and badges that drive sales and enhance customer experience. Elegant Labels for WooCommerce provides a comprehensive solution for creating beautiful, customizable labels that highlight special offers, new arrivals, bestsellers, and more.
    1515
    16 ✅ **Beautiful Label Designs**
    17 Create stunning product labels with our intuitive settings. Choose from a variety of pre-designed templates or add your own unique labels using our extensive customization options. With support for custom colors, fonts, shapes, your products will stand out from the competition.
    1816
    19 ✅ **Smart Label Automation**
    20 Set up intelligent rules to automatically display labels based on product conditions. Show "Sale" badges for discounted items, "New" labels for recently added products, "Hot" badges for trending items, or "Limited Stock" warnings when inventory runs low. Save time with automated label assignment that works 24/7.
     17[Live Demo](https://www.ammuthemes.com/random-theme-test/) | [Get PRO](https://www.ammuthemes.com/downloads/elegant-labels-pro/) | [PRO Demo](https://www.ammuthemes.com/elegant-labels-pro/)
    2118
    22 ✅ **Strategic Positioning**
    23 Position labels exactly where you want them on product images. Choose from corner placements, center overlays, or create floating badges that grab attention without overwhelming your product presentation.
    2419
    25 Perfect For
     20## Main Features =
    2621
    27 E-commerce Store Owners looking to increase conversion rates and highlight special products
    28 Marketing Teams who want to promote sales, new arrivals, and featured items effectively
    29 Store Managers seeking to improve product visibility and customer engagement
    30 Web Designers who need flexible, professional labeling solutions for client projects
     22✅ **Unlimited Labels/Badges**: Create unlimited product labels and badges
     23✅ **Text labels**: Create unlimited custom text product labels
     24✅ **Text Variables**: use text labels to display product information like  **stock status, stock quantity, coupon codes, discount percentage, sale ends in, shipping class, price, sold quantity and much more**
     25✅ **Shapes**: 5 pre built text label shapes included.
     26✅ **Image labels/badges**: Create unlimited image label/badges.
     27✅ **Custom image**: Option to upload your custom image badge
     28✅ **Better placements**: Labels can be displayed in three place. **1. on product image, 2. on product image in product page, 3. Product page details**
     29✅ **Label Posotions**: Place your label on top left, top right, bottom left, bottom right.
     30✅ **Customize**: Can customize label however you like. over 900+ Google fonts included. You can change **Font, font size, background color, text color, writing mode, line height, letter spacing, margin and padding**
     31✅ **Conditions**: show labels based on conditions like **All products, specific products, based on product categories, based on product tags, based on price**. Combine logic conditions to ‘AND’ and ‘OR’ groups to create more complex rules.
     32✅ **Live Preview**: Live preivew helps to create labels.
     33✅ **Theme Support**: Works with almost all themes.
     34✅ **Responsive**: Works in all mobile, gadgets and computers.
     35✅ **Speed**: Labels uses css only. plugin loads fast and doesn’t slow your website.
    3136
    32 Why Choose Elegant Labels?
    33 Unlike other labeling plugins that offer limited customization, Elegant Labels provides enterprise-level features with user-friendly simplicity. Our plugin integrates seamlessly with WooCommerce, follows WordPress best practices, and is translation-ready for global stores. Whether you're running a small boutique or a large marketplace, Elegant Labels scales with your business needs.
    34 Boost your sales today with labels that convert browsers into buyers. Create urgency with limited-time offers, build trust with quality badges, and guide customers to your best products with eye-catching highlights.
     37
     38## Premium Features =
     39
     40✅ **Premium Shapes**: 15+ pre built premium text label shapes included.
     41✅ **Premium Image badges**: 30+ pre built premium image labels
     42✅ **Emojis**: More than 500+ emojis included.
     43✅ **More Conditions**: More conditions included to create complex rules
     44✅ **Dedicated support**: Get dedicated supports from our site
     45
     46[Get PRO](https://www.ammuthemes.com/downloads/elegant-labels-pro/) | [PRO Demo](https://www.ammuthemes.com/elegant-labels-pro/)
    3547
    3648== Installation ==
     
    4860
    4961== Changelog ==
     62
     63= 1.4.3 ( 23.11.2025 ) =
     64* Fix: Related products bug fixed
     65* Fix: readme file updated
     66
    5067
    5168= 1.4.2 ( 05.11.2025 ) =
Note: See TracChangeset for help on using the changeset viewer.