Plugin Directory

Changeset 3479021


Ignore:
Timestamp:
03/10/2026 11:46:55 AM (3 weeks ago)
Author:
forge12
Message:

2.3.6

  • Fix: Hidden products (catalog visibility set to "hidden") no longer show blank spaces in accessory displays.
  • Fix: Draft, private and trashed products excluded from all accessory templates regardless of user role.
  • Fix: Array to string conversion warning in cart crossselling when multiple products with accessories are in the cart.
  • Fix: Cart crossselling template now uses a flat, deduplicated accessory ID list for consistent rendering.
  • New: f12_woo_accessories_cart_template filter allows Pro layouts (Slider, Accordion, Tabs) to override the cart template.
  • Improved: Autoplay setting uses toggle switch instead of checkbox for better UX consistency.
Location:
f12-wc-accessories/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • f12-wc-accessories/trunk/Accessories.class.php

    r3475601 r3479021  
    1111     * Plugin URI: https://www.forge12.com/product/woocommerce-zubehoer/
    1212     * Description: Add optional and required accessories for WooCommerce products and categories. The only plugin that combines optional + required + category-based accessories + cart crossselling.
    13      * Version: 2.3.5
     13     * Version: 2.3.6
    1414     * Author: Forge12 Interactive GmbH
    1515     * Author URI: https://www.forge12.com
     
    2424     * License URI: https://www.gnu.org/licenses/gpl-2.0.html
    2525     */
    26     define('FORGE12_ACCESSORIES_VERSION', '2.3.5');
     26    define('FORGE12_ACCESSORIES_VERSION', '2.3.6');
    2727    define('FORGE12_ACCESSORIES_SLUG', 'f12-woo-accessoires');
    2828    define('FORGE12_ACCESSORIES_BASENAME', plugin_basename(__FILE__));
  • f12-wc-accessories/trunk/Readme.txt

    r3475601 r3479021  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 2.3.5
     7Stable tag: 2.3.6
    88WC requires at least: 6.0
    99WC tested up to: 9.5
     
    134134
    135135== Changelog ==
     136
     137= 2.3.6 =
     138* Fix: Hidden products (catalog visibility set to "hidden") no longer show blank spaces in accessory displays.
     139* Fix: Draft, private and trashed products excluded from all accessory templates regardless of user role.
     140* Fix: Array to string conversion warning in cart crossselling when multiple products with accessories are in the cart.
     141* Fix: Cart crossselling template now uses a flat, deduplicated accessory ID list for consistent rendering.
     142* New: `f12_woo_accessories_cart_template` filter allows Pro layouts (Slider, Accordion, Tabs) to override the cart template.
     143* Improved: Autoplay setting uses toggle switch instead of checkbox for better UX consistency.
    136144
    137145= 2.3.5 =
     
    311319== Upgrade Notice ==
    312320
     321= 2.3.6 =
     322Fixes hidden and draft products showing blank spaces in accessory displays, array to string conversion warning in cart crossselling, and adds cart template filter for Pro layout support.
     323
    313324= 2.3.5 =
    314325Fixes fatal error when WooCommerce is not active. Plugin now gracefully skips frontend features if WooCommerce functions are unavailable.
  • f12-wc-accessories/trunk/includes/Frontend/AccessoriesCart.class.php

    r3475601 r3479021  
    103103             * Get all Accessories for the products
    104104             */
     105            $flat_collected = array();
    105106            foreach ($list_of_products as $cart_item) {
    106                 // Get optional and required ids
    107                 $accessory_ids[$cart_item['product_id']] = apply_filters('f12_woo_accessories_cart', $accessory_ids, $cart_item['product_id'], $accessory_ids_already_added);
     107                // Pass flat array of already-collected IDs to avoid nested array issues
     108                $result = apply_filters('f12_woo_accessories_cart', $flat_collected, $cart_item['product_id'], $accessory_ids_already_added);
     109                $accessory_ids[$cart_item['product_id']] = $result;
     110                $flat_collected = array_merge($flat_collected, $result);
    108111            }
    109112
     
    121124            if (!$template) {
    122125                $template = FORGE12_ACCESSORIES_PATH . 'templates/woo-accessories-cart.php';
     126            }
     127
     128            // Allow Pro plugin to override the cart template based on layout setting
     129            $template = apply_filters('f12_woo_accessories_cart_template', $template, $accessory_ids);
     130
     131            // Flatten accessory IDs for layout templates that expect a flat array
     132            $accessoire_ids = array();
     133            foreach ($accessory_ids as $product_id => $ids) {
     134                $accessoire_ids = array_merge($accessoire_ids, $ids);
     135            }
     136            $accessoire_ids = array_unique($accessoire_ids);
     137
     138            // Provide $product for layout templates (use first cart product as context)
     139            $product = null;
     140            $first_product_id = array_key_first($accessory_ids);
     141            if ($first_product_id) {
     142                $product = wc_get_product($first_product_id);
    123143            }
    124144
  • f12-wc-accessories/trunk/includes/UI/UIOptionalAccessories.class.php

    r3468706 r3479021  
    370370                            <div id="layout-slider-settings" style="<?php echo $settings['layout'] !== 'slider' ? 'display:none;' : ''; ?>margin-top:10px;">
    371371                                <p>
    372                                     <input id="slider_autoplay" type="checkbox" name="slider_autoplay"
    373                                            value="1" <?php echo isset($settings['slider_autoplay']) && (int) $settings['slider_autoplay'] == 1 ? 'checked="checked"' : ''; ?>
    374                                     />
     372                                    <label class="f12-toggle">
     373                                        <input id="slider_autoplay" type="checkbox" name="slider_autoplay"
     374                                               value="1" <?php echo isset($settings['slider_autoplay']) && (int) $settings['slider_autoplay'] == 1 ? 'checked="checked"' : ''; ?>
     375                                        />
     376                                        <span class="f12-toggle-slider"></span>
     377                                    </label>
    375378                                    <label for="slider_autoplay"><?php _e('Autoplay', 'f12-woo-accessories'); ?></label>
    376379                                </p>
  • f12-wc-accessories/trunk/templates/woo-accessories-cart.php

    r3468706 r3479021  
    3131<?php woocommerce_product_loop_start(); ?>
    3232
    33 <?php foreach ($accessory_ids as $product_id => $accessories) : ?>
    34     <?php foreach ($accessories as $accessory_id): ?>
    35         <?php
    36         $post_object = get_post($accessory_id);
     33<?php foreach ($accessoire_ids as $accessory_id): ?>
     34    <?php
     35    $accessory = wc_get_product($accessory_id);
    3736
    38         if (!$post_object) {
    39             continue;
    40         }
     37    if (!$accessory || $accessory->get_status() !== 'publish' || !$accessory->is_purchasable() || !$accessory->is_in_stock() || $accessory->get_catalog_visibility() === 'hidden') {
     38        continue;
     39    }
    4140
    42         setup_postdata($GLOBALS['post'] =& $post_object); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited, Squiz.PHP.DisallowMultipleAssignments.Found
     41    $post_object = get_post($accessory_id);
    4342
    44         wc_get_template_part('content', 'product');
    45         ?>
    46     <?php endforeach; ?>
     43    if (!$post_object) {
     44        continue;
     45    }
     46
     47    setup_postdata($GLOBALS['post'] =& $post_object); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited, Squiz.PHP.DisallowMultipleAssignments.Found
     48
     49    wc_get_template_part('content', 'product');
     50    ?>
    4751<?php endforeach; ?>
    4852
  • f12-wc-accessories/trunk/templates/woo-accessories-checkbox.php

    r3468706 r3479021  
    117117            // Collect filter reasons
    118118            $filter_reasons = array();
     119            if ($accessory->get_status() !== 'publish') {
     120                $filter_reasons[] = __('not published', 'f12-woo-accessories');
     121            }
    119122            if (!$accessory->is_purchasable()) {
    120123                $filter_reasons[] = __('not purchasable', 'f12-woo-accessories');
     
    122125            if (!$accessory->is_in_stock()) {
    123126                $filter_reasons[] = __('out of stock', 'f12-woo-accessories');
     127            }
     128            if ($accessory->get_catalog_visibility() === 'hidden') {
     129                $filter_reasons[] = __('hidden from catalog', 'f12-woo-accessories');
    124130            }
    125131
  • f12-wc-accessories/trunk/templates/woo-accessories-inline.php

    r3468706 r3479021  
    7878            // Collect filter reasons
    7979            $filter_reasons = array();
     80            if ($accessory->get_status() !== 'publish') {
     81                $filter_reasons[] = __('not published', 'f12-woo-accessories');
     82            }
    8083            if (!$accessory->is_purchasable()) {
    8184                $filter_reasons[] = __('not purchasable', 'f12-woo-accessories');
     
    8386            if (!$accessory->is_in_stock()) {
    8487                $filter_reasons[] = __('out of stock', 'f12-woo-accessories');
     88            }
     89            if ($accessory->get_catalog_visibility() === 'hidden') {
     90                $filter_reasons[] = __('hidden from catalog', 'f12-woo-accessories');
    8591            }
    8692
  • f12-wc-accessories/trunk/templates/woo-accessories.php

    r3468706 r3479021  
    9090    // Collect filter reasons
    9191    $filter_reasons = array();
     92    if ($accessory->get_status() !== 'publish') {
     93        $filter_reasons[] = __('not published', 'f12-woo-accessories');
     94    }
    9295    if (!$accessory->is_purchasable()) {
    9396        $filter_reasons[] = __('not purchasable', 'f12-woo-accessories');
     
    9598    if (!$accessory->is_in_stock()) {
    9699        $filter_reasons[] = __('out of stock', 'f12-woo-accessories');
     100    }
     101    if ($accessory->get_catalog_visibility() === 'hidden') {
     102        $filter_reasons[] = __('hidden from catalog', 'f12-woo-accessories');
    97103    }
    98104
Note: See TracChangeset for help on using the changeset viewer.