Plugin Directory

Changeset 3402792


Ignore:
Timestamp:
11/25/2025 08:09:27 PM (4 months ago)
Author:
Molongui
Message:

2.6.4 (2025-11-25)

  • Fixed: Plain string comparison replaced with version_compare().
Location:
molongui-bump-offer/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • molongui-bump-offer/trunk/README.txt

    r3402326 r3402792  
    173173
    174174== Changelog ==
     175
     176= 2.6.4 (2025-11-25) =
     177
     178* **Fixed**: Plain string comparison replaced with `version_compare()`.
    175179
    176180= 2.6.3 (2025-11-25) =
  • molongui-bump-offer/trunk/includes/hooks/bump/add-to-cart.php

    r2965404 r3402792  
    11<?php
    2 defined( 'ABSPATH' ) or exit;
     2
     3defined( 'ABSPATH' ) or exit; // Exit if accessed directly
    34function mbo_ajax_add_to_cart()
    45{
     6    if ( empty( $_POST['bump_id'] ) )
     7    {
     8        wp_die();
     9    }
    510    $deal_id = apply_filters( 'mbo/add_to_cart/deal_id', absint( $_POST['bump_id'] ) );
    611    $deal = mbo_get_bump( $deal_id, 'publish' );
    7     if ( !$deal ) wp_die();
    8     $deal_type         = apply_filters( 'mbo/add_to_cart/deal_type', $deal->_molongui_deal_type, $deal_id );
    9     $product_id        = apply_filters( 'mbo/add_to_cart/deal_product', absint( $deal->_molongui_bump_product ), $deal_id );
    10     $product_quantity  = apply_filters( 'mbo/add_to_cart/deal_quantity', absint( $deal->_molongui_deal_quantity ), $deal_id );
     12    if ( ! $deal )
     13    {
     14        wp_die();
     15    }
     16    $deal_type        = apply_filters( 'mbo/add_to_cart/deal_type', $deal->_molongui_deal_type, $deal_id );
     17    $product_id       = apply_filters( 'mbo/add_to_cart/deal_product', absint( $deal->_molongui_bump_product ), $deal_id );
     18    $product_quantity = apply_filters( 'mbo/add_to_cart/deal_quantity', absint( $deal->_molongui_deal_quantity ), $deal_id );
    1119
    1220    $passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, 1 );
    1321    $product_status    = get_post_status( $product_id );
    1422    $cart_item_key = WC()->cart->add_to_cart( $product_id, $product_quantity );
    15     if ( $passed_validation and $cart_item_key and 'publish' === $product_status )
     23
     24    if ( $passed_validation && $cart_item_key && 'publish' === $product_status )
    1625    {
    1726        do_action( 'woocommerce_ajax_added_to_cart', $product_id );
     
    1928        woocommerce_mini_cart();
    2029        $mini_cart = ob_get_clean();
     30
    2131        $data = array
    2232        (
    23             'fragments' => apply_filters( 'woocommerce_add_to_cart_fragments', array
    24             (
    25                 'div.widget_shopping_cart_content' => '<div class="widget_shopping_cart_content">' . $mini_cart . '</div>',
    26             )),
    27             'cart_hash' => WC()->cart->get_cart_hash(),
     33            'fragments' => apply_filters(
     34                'woocommerce_add_to_cart_fragments',
     35                array
     36                (
     37                    'div.widget_shopping_cart_content' => '<div class="widget_shopping_cart_content">' . $mini_cart . '</div>',
     38                )
     39            ),
     40            'cart_hash'      => WC()->cart->get_cart_hash(),
     41            'added_item_key' => $cart_item_key,
    2842        );
    29         $data['added_item_key'] = $cart_item_key;
    30         if ( !headers_sent() ) mbo_setcookie( 'molongui_added_order_bump_'.$_POST['bump_id'], $cart_item_key, 0, $path = "/", "", null, false, 'strict' );
    31         wp_send_json( $data );
     43        if ( ! headers_sent() )
     44        {
     45            mbo_setcookie(
     46                'molongui_added_order_bump_' . $deal_id,
     47                $cart_item_key,
     48                0,
     49                '/',
     50                '',
     51                null,
     52                false,
     53                'strict'
     54            );
     55        }
     56
     57        wp_send_json( $data ); // exits.
    3258    }
    33     else
    34     {
    35         $data = array
    36         (
    37             'error'       => true,
    38             'product_url' => apply_filters( 'woocommerce_cart_redirect_after_error', get_permalink( $product_id ), $product_id )
    39         );
     59    $data = array
     60    (
     61        'error'       => true,
     62        'product_url' => apply_filters(
     63            'woocommerce_cart_redirect_after_error',
     64            get_permalink( $product_id ),
     65            $product_id
     66        ),
     67    );
    4068
    41         echo wp_send_json( $data );
    42     }
    43 
    44     wp_die();
     69    wp_send_json( $data ); // exits.
    4570}
    4671add_action( 'wp_ajax_nopriv_mbo_ajax_add_to_cart', 'mbo_ajax_add_to_cart' );  // Allows to use this function for non-logged in users.
     
    4873function mbo_add_deal_data( $cart_item_data, $product_id )
    4974{
    50     if ( !isset( $_POST['bump_id'] ) ) return $cart_item_data;
     75    if ( ! isset( $_POST['bump_id'] ) )
     76    {
     77        return $cart_item_data;
     78    }
    5179    $deal_id = apply_filters( 'mbo/add_to_cart/deal_id', absint( $_POST['bump_id'] ) );
    5280    $deal = mbo_get_bump( $deal_id, 'publish' );
    53     if ( !$deal ) return $cart_item_data;
     81    if ( ! $deal )
     82    {
     83        return $cart_item_data;
     84    }
    5485    $deal_type           = apply_filters( 'mbo/add_to_cart/deal_type', $deal->_molongui_deal_type, $deal_id );
    5586    $deal_product        = apply_filters( 'mbo/add_to_cart/deal_product', absint( $deal->_molongui_bump_product ), $deal_id );
     
    70101function mbo_overwrite_deal_price( $cart_object )
    71102{
    72     if ( is_admin() and !defined( 'DOING_AJAX' ) ) return;
     103    if ( is_admin() && ! defined( 'DOING_AJAX' ) )
     104    {
     105        return;
     106    }
     107    if ( ! WC()->session || WC()->session->__isset( 'reload_checkout' ) )
     108    {
     109        return;
     110    }
    73111
    74     if ( !WC()->session->__isset( "reload_checkout" ) )
     112    $is_wc_3_or_newer = version_compare( WC()->version, '3.0.0', '>=' );
     113    foreach ( $cart_object->get_cart() as $key => $value )
    75114    {
    76         $wc_version = WC()->version;
    77         foreach ( $cart_object->cart_contents as $key => $value )
     115        if ( isset( $value['order_bump_price'] ) && isset( $value['data'] ) && is_object( $value['data'] ) )
    78116        {
    79             if ( isset( $value['order_bump_price'] ) )
     117            if ( ! $is_wc_3_or_newer )
    80118            {
    81                 if ( $wc_version < "3.0.0" )
    82                 {
    83                     $value['data']->price = $value['order_bump_price'];
    84                 }
    85                 else
    86                 {
    87                     $value['data']->set_price( $value['order_bump_price'] );
    88                     $value['data']->set_sold_individually( true );
    89                 }
     119                $value['data']->price = $value['order_bump_price'];
     120            }
     121            else
     122            {
     123                $value['data']->set_price( $value['order_bump_price'] );
     124                $value['data']->set_sold_individually( true );
    90125            }
    91126        }
     
    96131{
    97132
    98     if ( !empty( $cart_item['order_bump_price'] ) ) return wc_price( $cart_item['order_bump_price'] );
     133    if ( !empty( $cart_item['order_bump_price'] ) )
     134    {
     135        return wc_price( (float) $cart_item['order_bump_price'] );
     136    }
    99137
    100138    return $price;
  • molongui-bump-offer/trunk/molongui-bump-offer.php

    r3402326 r3402792  
    11<?php
    2 defined( 'ABSPATH' ) or exit;
    32
    43/*!
     4 * Molongui Order Bump for WooCommerce
     5 *
     6 * @package              Molongui Order Bump for WooCommerce
     7 * @author               Molongui
     8 * @copyright            2015 Molongui
     9 * @license              GPL-3.0-or-later
     10 *
     11 * @wordpress-plugin
    512 * Plugin Name:          Order Bump for WooCommerce
     13 * Plugin URI:           https://www.molongui.com/order-bump-for-woocommerce/
    614 * Description:          Boost your sales showing exclusive one-time offers on the Checkout page. With just one click the offer gets added to customer's Order.
    7  * Plugin URI:           https://www.molongui.com/order-bump-for-woocommerce/
    8  * Text Domain:          molongui-bump-offer
    9  * Domain Path:          /i18n/
    10  * Requires PHP:         5.5.0
     15 * Version:              2.6.4
    1116 * Requires at least:    5.2.0
    1217 * Tested up to:         6.8
    1318 * WC requires at least: 2.5.0
    1419 * WC tested up to:      10.3
     20 * Requires PHP:         5.5.0
    1521 * Author:               Molongui
    16  * Author URI:           https://www.molongui.com/
     22 * Author URI:           https://www.molongui.com
     23 * Text Domain:          molongui-bump-offer
     24 * Domain Path:          /i18n
    1725 * License:              GPL v3 or later
    1826 * License URI:          http://www.gnu.org/licenses/gpl-3.0.txt
    19  * Version:              2.6.3
    2027 *
    2128 * This plugin is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
     
    2633 *
    2734 * You should have received a copy of the GNU General Public License along with this plugin. If not, see
    28  * http://www.gnu.org/licenses/
     35 * http://www.gnu.org/licenses.
    2936 */
     37
     38defined( 'ABSPATH' ) or exit; // Exit if accessed directly
    3039add_action( 'plugins_loaded', 'molongui_bump_offer_load_plugin_textdomain' );
    3140if ( version_compare( PHP_VERSION, '5.5', '<' ) )
     
    3948else
    4049{
    41     define( 'MOLONGUI_BUMP_OFFER_VERSION', '2.6.3' );
     50    define( 'MOLONGUI_BUMP_OFFER_VERSION', '2.6.4' );
    4251    define( 'MOLONGUI_BUMP_OFFER_FILE', __FILE__ );
    4352    define( 'MOLONGUI_BUMP_OFFER_DIR', plugin_dir_path( MOLONGUI_BUMP_OFFER_FILE ) );
Note: See TracChangeset for help on using the changeset viewer.