Skip to content

Instantly share code, notes, and snippets.

Avatar

Stuart Duff stuartduff

View GitHub Profile
@thenbrent
thenbrent / custom-subscription-interval.php
Last active Apr 2, 2021
Add a new billing interval to WooCommerce Subscriptions to allow for longer intervals between subscription renewal payments. Specifically a new "8" interval to allow you to sell a subscription that renews every 8 days, weeks, months or years.
View custom-subscription-interval.php
<?php
/**
* Plugin Name: WooCommerce Subscription Custom Interval
* Description: Add a custom 8 week subscription interval to WooCommerce Subscriptions
* Author: Brent Shepherd
* Version: 1.0
* License: GPL v2
*/
function eg_add_custom_subscription_interval( $subscription_intervals ) {
View gist:d3e0a40e7a39b59cad24
add_filter( 'woocommerce_dynamic_pricing_is_cumulative', 'wcdp_cumulative_pricing', 10, 2 );
function wcdp_cumulative_pricing( $cumulative, $module_id ) {
if ( $module_id == 'advanced_category' || $module_id == 'simple_membership' ) {
$cumulative = true;
}
return $cumulative;
}
add_filter('wc_dynamic_pricing_load_modules', 'custom_dynamic_pricing_module_order');
View gist:d954b16f8aad6cc87c21
add_filter( 'woocommerce_dynamic_pricing_is_cumulative', 'wcdp_cumulative_pricing', 10, 2 );
function wcdp_cumulative_pricing( $cumulative, $module_id ) {
if ( $module_id == 'simple_category' || $module_id == 'simple_membership' ) {
$cumulative = false;
}
return $cumulative;
}
View gist:e734ceb21cbab0bec173
add_filter('woocommerce_dynamic_pricing_is_cumulative', 'on_woocommerce_dynamic_pricing_is_cumulative', 10, 3);
function on_woocommerce_dynamic_pricing_is_cumulative($cumulative, $discounter_name, $cart_item) {
if ($discounter_name == 'simple_category' || $discounter_name == 'simple_membership') {
$cumulative = false;
}
return $cumulative;
}
@jaybuys
jaybuys / woo-slider-content-filter.php
Last active Aug 25, 2017
Make WooSlider plugin show full HTML content instead of excerpts in slide layout. Place this code in your WordPress theme functions.php file.
View woo-slider-content-filter.php
<?php
add_filter( 'wooslider_slides_layout_html', 'wooslider_custom_content', 10, 3);
function wooslider_custom_content ( $content, $args, $post ) {
global $post;
$image = get_the_post_thumbnail( get_the_ID() );
if ( 'true' == $args['link_slide'] || 1 == $args['link_slide'] ) {
$wooslider_url = get_post_meta( get_the_ID(), '_wooslider_url', true );
@stuartduff
stuartduff / github-wppembed.php
Created Jul 28, 2012
Easily embed and share Github gists on your WordPress blog
View github-wppembed.php
**
* Usage:
* Paste a gist link into a blog post or page and it will be embedded eg:
* https://gist.github.com/2926827
*
* If a gist has multiple files you can select one using a url in the following format:
* https://gist.github.com/2926827?file=embed-gist.php
*/
wp_embed_register_handler( 'gist', '/https:\/\/gist\.github\.com\/(\d+)(\?file=.*)?/i', 'wp_embed_handler_gist' );