Home / Admin / Disallow store credits if cart has subscription product
Duplicate Snippet

Embed Snippet on Your Site

Disallow store credits if cart has subscription product

This snippet will remove the store credit option if the cart has a subscription product

Code Preview
php
<?php
/**
 * Disallow store credits if cart has subscription product.
 */
add_filter('acfw_is_allow_store_credits', function($value) {
    // check if cart has subscription product
    $cart = WC()->cart->get_cart_contents();
    foreach ( $cart as $cart_item ) {
        $product = $cart_item['data'];
        // disallow store credits if cart has subscription product.
        if ( $product->is_type( 'subscription' ) || $product->is_type( 'subscription_variation' ) ) {
            return false;
        }
    }
    return $value;
});

Comments

Add a Comment