Plugin Directory

Changeset 3410915


Ignore:
Timestamp:
12/04/2025 12:46:08 PM (4 months ago)
Author:
itpathsolutions
Message:

2.1.0

*Release Date 4th December 2025*

  • Improvement – Compatible with latest WordPress version 6.9
  • Fix: Gift wrap price was not being added correctly to the cart total when a simple product was added via AJAX. The calculation logic has now been corrected.
  • Fix - Other small fixes and updates
Location:
gift-pack-for-woocommerce
Files:
88 added
4 edited

Legend:

Unmodified
Added
Removed
  • gift-pack-for-woocommerce/trunk/README.txt

    r3278737 r3410915  
    44Donate link: https://www.itpathsolutions.com
    55Requires at least: 6.0
    6 Tested up to: 6.8
     6Tested up to: 6.9
    77Requires PHP: 7.4
    8 Stable tag: 2.0.2
     8Stable tag: 2.1.0
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    106106* Improvement - Removed the default character limit validation for the Gift Pack Note
    107107
     108= 2.1.0 =
     109
     110*Release Date 4th December 2025*
     111
     112* Improvement – Compatible with latest WordPress version 6.9
     113* Fix: Gift wrap price was not being added correctly to the cart total when a simple product was added via AJAX. The calculation logic has now been corrected.
     114* Fix - Other small fixes and updates
     115
    108116= 2.0.1 =
    109117
  • gift-pack-for-woocommerce/trunk/gift-pack-for-woocommerce.php

    r3278737 r3410915  
    1717 * Plugin URI:        https://wordpress.org/plugins/gift-pack-for-woocommerce/
    1818 * Description:       Allow customers add gift pack/wrapping to individual products from product pages
    19  * Version:           2.0.2
     19 * Version:           2.1.0
    2020 * Author:            IT Path Solutions
    2121 * Author URI:        https://www.itpathsolutions.com/
     
    3737 * Rename this for your plugin and update it as you release new versions.
    3838 */
    39 define( 'GIFT_PACK_FOR_WOOCOMMERCE_VERSION', '2.0.2' );
     39define( 'GIFT_PACK_FOR_WOOCOMMERCE_VERSION', '2.1.0' );
    4040
    4141/**
  • gift-pack-for-woocommerce/trunk/public/class-gift-pack-for-woocommerce-public.php

    r3278737 r3410915  
    100100         */
    101101       
    102             wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/gift-pack-for-woocommerce-public.js', array( 'jquery' ), $this->version, false );
     102            wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/gift-pack-for-woocommerce-public.js?v=1.1', array( 'jquery' ), $this->version, false );
    103103            wp_localize_script($this->plugin_name, 'ajax_object',  array('ajaxurl' => admin_url('admin-ajax.php')));
    104104       
     
    265265    // Front: Set the new calculated cart item price
    266266    public function gpfw_extra_price_add_custom_price($cart) {
     267       
    267268        if (is_admin() && !defined('DOING_AJAX'))
    268269            return;
     
    270271            return;
    271272        foreach($cart->get_cart() as $cart_item) {
     273            // print_r($cart_item['new_price']);exit();
    272274            if (isset($cart_item['new_price']))
    273275                $cart_item['data']->set_price((float) $cart_item['new_price']);
     
    332334            }
    333335            else{
    334                 $gpfw_gift_pack_image_text = __("Giftpack Image 3","gift-pack-for-woocommerce");
     336                $gpfw_gift_pack_image_text = __("Giftpack Image","gift-pack-for-woocommerce");
    335337            }   
    336338            $green_gift_pack = plugin_dir_url(__DIR__) . 'public/images/green_gift_pack.png';
  • gift-pack-for-woocommerce/trunk/public/js/gift-pack-for-woocommerce-public.js

    r3278737 r3410915  
    11jQuery(document).ready(function($) {
     2    console.log('gift-pack-for-woocommerce-public.js loaded');
     3    /**
     4     * Ensure the gift wrap fields always live inside the add-to-cart form.
     5     * Some block themes reposition hooks outside the <form>, which prevents
     6     * the inputs from posting. We relocate them proactively when needed.
     7     */
     8    var gpfwEnsureCartFieldPlacement = function() {
     9        var $cartForm = $('form.cart').first();
     10        if (!$cartForm.length) {
     11            return;
     12        }
     13        $('.gpfw_gift_pack_fields').each(function() {
     14            var $fieldBlock = $(this);
     15            if (!$fieldBlock.closest('form.cart').length) {
     16                $cartForm.prepend($fieldBlock);
     17            }
     18        });
     19    };
     20
     21    var gpfwFieldNames = [
     22        'gift_pack_option',
     23        'gift_pack_wrapper_price',
     24        'active_price',
     25        'gpfw_default_gift_pack_img',
     26        'gpfw_giftpack_uploaded_value',
     27        'gpfw-gift-pack-to',
     28        'gpfw-gift-pack-from',
     29        'gpfw-gift-pack-note'
     30    ];
     31
     32    var gpfwCollectFieldValues = function($form) {
     33        var collected = {};
     34        gpfwFieldNames.forEach(function(name) {
     35            var $fields = $form.find('[name="' + name + '"]');
     36            if (!$fields.length) {
     37                return;
     38            }
     39            var value;
     40            if ($fields.first().is(':radio')) {
     41                var $checkedRadio = $fields.filter(':checked');
     42                if ($checkedRadio.length) {
     43                    value = $checkedRadio.val();
     44                }
     45            } else if ($fields.first().is(':checkbox')) {
     46                var $checkedBox = $fields.filter(':checked');
     47                if ($checkedBox.length) {
     48                    value = $checkedBox.val();
     49                }
     50            } else {
     51                value = $fields.first().val();
     52            }
     53            if (typeof value !== 'undefined' && value !== null && value !== '') {
     54                collected[name] = value;
     55            }
     56        });
     57        return collected;
     58    };
     59
     60    var gpfwCloneValuesIntoForm = function($form) {
     61        if (!$form.length) {
     62            return;
     63        }
     64        $form.find('[data-gpfw-clone="true"]').remove();
     65        var values = gpfwCollectFieldValues($form);
     66        $.each(values, function(name, value) {
     67            $('<input>', {
     68                type: 'hidden',
     69                name: name,
     70                value: value,
     71                'data-gpfw-clone': 'true'
     72            }).appendTo($form);
     73        });
     74    };
     75
     76    var gpfwExtendAjaxPayload = function() {
     77        $(document.body).on('adding_to_cart', function(event, button, data) {
     78            var $form = button.closest('form.cart');
     79            if (!$form.length) {
     80                $form = button.closest('.product, .summary').find('form.cart').first();
     81            }
     82            if (!$form.length) {
     83                return;
     84            }
     85            var values = gpfwCollectFieldValues($form);
     86            $.extend(data, values);
     87        });
     88    };
     89
     90    gpfwEnsureCartFieldPlacement();
     91    gpfwExtendAjaxPayload();
     92
     93    $(document).on('submit', 'form.cart', function() {
     94        gpfwCloneValuesIntoForm($(this));
     95    });
     96
     97    $(document).on('click', 'form.cart button[name="add-to-cart"], form.cart button.single_add_to_cart_button', function() {
     98        gpfwCloneValuesIntoForm($(this).closest('form.cart'));
     99    });
     100
    2101    if($('div.gpwf_popup_enable').length){
    3102        var initPhotoSwipeFromDOM = function(gallerySelector) {
     
    76175                $('.gift-pack_for-woocommerce-parent').html(json_obj.html);
    77176                $('.gpfw-gift-pack-note').prop("required", true);
     177                gpfwEnsureCartFieldPlacement();
    78178               
    79179                if(variable_pro){
     
    134234                var json_obj = JSON.parse(result);
    135235                $('.gift-pack_for-woocommerce-parent').html(json_obj.html);
     236                gpfwEnsureCartFieldPlacement();
    136237               
    137238                if(variable_pro){
     
    191292            }
    192293            $('input[name="active_price"]').val(json_obj.active_price);
     294            gpfwEnsureCartFieldPlacement();
    193295           
    194296        });
Note: See TracChangeset for help on using the changeset viewer.