Plugin Directory

Changeset 2671583


Ignore:
Timestamp:
02/02/2022 06:48:48 PM (4 years ago)
Author:
code4life
Message:

Hook improvements and big fix

Location:
disable-cart-page-for-woocommerce/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • disable-cart-page-for-woocommerce/trunk/disable-cart-page-for-woocommerce.php

    r2574129 r2671583  
    77    Author: Code4Life
    88    Author URI: https://code4life.it/
    9     Version: 1.2.4
     9    Version: 1.2.5
    1010    Text Domain: disable-cart-page-for-woocommerce
    1111    Domain Path: /i18n/
     
    1414
    1515    WC requires at least: 2.0
    16     WC tested up to: 5.5
     16    WC tested up to: 6.1
    1717 */
    1818
     
    106106
    107107    // Force WooCommerce to redirect after product added to cart
    108     update_option( 'woocommerce_cart_redirect_after_add', 'yes' );
     108    add_filter( 'pre_option_woocommerce_cart_redirect_after_add', function( $pre_option ) {
     109        return 'yes';
     110    } );
     111
    109112    add_filter( 'woocommerce_product_settings', function( $fields ) {
    110113        foreach ( $fields as $key => $field ) {
     
    119122
    120123    // Empty cart when product is added to cart, so we can't have multiple products in cart
    121     add_action( 'woocommerce_add_cart_item_data', function() {
     124    add_action( 'woocommerce_add_cart_item_data', function( $cart_item_data ) {
    122125        wc_empty_cart();
     126        return $cart_item_data;
    123127    } );
    124128
  • disable-cart-page-for-woocommerce/trunk/readme.txt

    r2574129 r2671583  
    44Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&[email protected]&item_name=Donazione&item_number=Contributo+libero¤cy_code=EUR&lc=it_IT
    55Requires at least: 4.6
    6 Tested up to: 5.8
    7 Stable tag: 1.2.4
     6Tested up to: 5.9
     7Stable tag: 1.2.5
    88WC requires at least: 2.0
    9 WC tested up to: 5.5
     9WC tested up to: 6.1
    1010License: GPLv3
    1111License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    5353For more information, see [Official page](https://code4life.it/shop/plugins/disable-cart-page-for-woocommerce/).
    5454
     55= v1.2.5 =
     56* Added "pre_option_woocommerce_cart_redirect_after_add" hook to force WooCommerce to redirect after product added to cart
     57* Bug fix: added return $cart_item_data variable in "woocommerce_add_cart_item_data" hook
     58
    5559= v1.2.4 =
    5660* Added function to empty cart if error occurs
Note: See TracChangeset for help on using the changeset viewer.