Use these snippets to customize the appearance and functionality of All Products for WooCommerce Subscriptions.
To use a snippet, download the linked file and activate it as you would with any other plugin. Alternatively, copy the contained code into your child theme’s functions.php file.
Snippets ↑ Back to top
Prevent subscription options from showing up next to cart-items ↑ Back to top
The extension allows customers to switch the subscription plan of individual cart items. If you don’t want to display any subscription plan options next to cart items, use the following snippet:
<?php | |
/** | |
* Plugin Name: All Products for WooCommerce Subscriptions – Hide Cart Item Subscription Options | |
* Plugin URI: https://woocommerce.com/products/all-products-for-woocommerce-subscriptions/ | |
* Description: Use this snippet to hide cart item subscription options. | |
* Version: 1.0 | |
* Author: SomewhereWarm | |
* Author URI: https://somewherewarm.gr/ | |
* Developer: Jason Kytros | |
* | |
* | |
* Copyright: © 2020 Jason Kytros (jask@somewherewarm.gr). | |
* License: GNU General Public License v3.0 | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
add_filter( 'wcsatt_show_cart_item_options', '__return_false' ); |
Prevent coupons from being applied to products on subscription ↑ Back to top
To prevent coupons from being applied to products purchased on subscription, use the following snippet:
<?php | |
/** | |
* Plugin Name: All Products for WooCommerce Subscriptions – Disable Coupons for Products on Subscription | |
* Plugin URI: https://woocommerce.com/products/all-products-for-woocommerce-subscriptions/ | |
* Description: Use this snippet to prevent coupons from applying to cart items on Subscription. | |
* Version: 1.0 | |
* Author: SomewhereWarm | |
* Author URI: https://somewherewarm.gr/ | |
* Developer: Jason Kytros | |
* | |
* | |
* Copyright: © 2020 Jason Kytros (jask@somewherewarm.gr). | |
* License: GNU General Public License v3.0 | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
add_filter( 'woocommerce_coupon_is_valid_for_product', 'apfs_disable_for_products_on_subscription', 10, 4 ); | |
function apfs_disable_for_products_on_subscription( $is_valid, $product, $instance, $values ) { | |
if ( ! empty( $values[ 'wcsatt_data'][ 'active_subscription_scheme' ] ) ) { | |
$is_valid = false; | |
} | |
return $is_valid; | |
} |
It is also possible to prevent coupons from being applied to the cart if one or more products are purchased on subscription:
<?php | |
/** | |
* Plugin Name: All Products for WooCommerce Subscriptions – Disable Coupons When Cart contains products on Subscription | |
* Plugin URI: https://woocommerce.com/products/all-products-for-woocommerce-subscriptions/ | |
* Description: Use this snippet to prevent coupons from applying in the cart if there is at least one product on Subscription there. | |
* Version: 1.0 | |
* Author: SomewhereWarm | |
* Author URI: https://somewherewarm.gr/ | |
* Developer: Jason Kytros | |
* | |
* | |
* Copyright: © 2020 Jason Kytros (jask@somewherewarm.gr). | |
* License: GNU General Public License v3.0 | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
add_filter( 'woocommerce_coupon_is_valid', 'apfs_disable_for_products_on_subscription', 10, 3 ); | |
function apfs_disable_for_products_on_subscription( $is_valid, $coupon, $object ){ | |
$cart_contents = WC()->cart->cart_contents; | |
foreach ( $cart_contents as $cart_item ) { | |
if ( ! empty( $cart_item[ 'wcsatt_data'][ 'active_subscription_scheme' ] ) ) { | |
$is_valid = false; | |
break; | |
} | |
} | |
return $is_valid; | |
} |
Remove subscription details from the catalog price of products with optional subscription plans ↑ Back to top
If a product has optional subscription plans, a suffix is appended to its catalog price to inform customers that it is available on subscription. This suffix can be removed with the following snippet:
<?php | |
/** | |
* Plugin Name: All Products for WooCommerce Subscriptions – Remove Catalog Price Subscription Suffix | |
* Plugin URI: https://woocommerce.com/products/all-products-for-woocommerce-subscriptions/ | |
* Description: Use this snippet to hide cart item subscription options. | |
* Version: 1.0 | |
* Author: SomewhereWarm | |
* Author URI: https://somewherewarm.gr/ | |
* Developer: Jason Kytros | |
* | |
* | |
* Copyright: © 2020 Jason Kytros (jask@somewherewarm.gr). | |
* License: GNU General Public License v3.0 | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
add_filter( 'wcsatt_price_html_suffix', 'apfs_remove_suffix', 10, 3 ); | |
function apfs_remove_suffix( $suffix, $product, $args ) { | |
return ''; | |
} |
Restore “Add to Cart” buttons in the catalog ↑ Back to top
If a product has subscription plans, the plugin replaces its default “Add to Cart” catalog button with a “Select Options” button. When clicked, this takes customers to the product page, where they can choose a purchase plan. In some cases, it might be preferable to display an “Add to Cart” button that customers can click to make a one-time purchase directly. This is possible using the following snippet:
Questions & Support ↑ Back to top
Have a question before you buy? Please fill out this pre-sales form.
Already purchased and need assistance? Get in touch with us via the Help Desk!