Skip to content

Instantly share code, notes, and snippets.

View leewillis77's full-sized avatar

Lee Willis leewillis77

View GitHub Profile
@leewillis77
leewillis77 / enable-gpf-render-cache.php
Created May 4, 2017 11:17
Enable WooCommerce Google Product Feed extension feed item cache.
<?php
/*
Plugin Name: Enable WooCommerce GPF feed item cache.
Plugin URI: http://docs.woothemes.com/document/google-product-feed/
Description: Enables feed item caching in the Google Product Feed extension.
Version: 1.0
Author: Lee Willis
Author URI: https://plugins.leewillis.co.uk/
*/
@leewillis77
leewillis77 / subselect.diff
Created June 28, 2017 20:42
Subselect instead of view proof-of-concept
diff --git a/includes/class-campaigns-db.php b/includes/class-campaigns-db.php
index bc572401..ee2e9892 100644
--- a/includes/class-campaigns-db.php
+++ b/includes/class-campaigns-db.php
@@ -27,10 +27,21 @@ class Affiliate_WP_Campaigns_DB extends Affiliate_WP_DB {
if( defined( 'AFFILIATE_WP_NETWORK_WIDE' ) && AFFILIATE_WP_NETWORK_WIDE ) {
// Allows a single visits table for the whole network
- $this->table_name = 'affiliate_wp_campaigns';
+ $visits_db = 'affiliate_wp_visits';
@leewillis77
leewillis77 / functions.php
Last active June 4, 2020 07:54
How to modify price of items in the Google Product Feed
<?php
function lw_woocommerce_gpf_feed_item_google( $feed_item, $product ) {
// If you need to modify the prices sent in the feed, you can modify the following
// properties of the feed_item object.
// The regular price of the item.
// $feed_item->regular_price_ex_tax
// $feed_item->regular_price_inc_tax
@leewillis77
leewillis77 / functions.php
Created January 9, 2018 10:55
Redirect to cart from cart recovery emails : https://wp-cart-recovery.com
function lw_crfw_return_redirect_url( $redirect_url, $cart ) {
if ( ! function_exists( 'wc_get_cart_url' ) ) {
WC()->frontend_includes();
}
return wc_get_cart_url();
}
add_action( 'crfw_return_redirect_url', 'lw_crfw_return_redirect_url', 10, 2 );
@leewillis77
leewillis77 / functions.php
Created March 23, 2018 13:22
Hide attribute labels on variable products in Google Product Feed titles
<?php
add_filter( 'woocommerce_gpf_include_attribute_labels_in_title', '__return_false' );
@leewillis77
leewillis77 / functions.php
Created March 25, 2018 16:50
Add additional duration to Cart Recovery for WordPress Pro
<?php
function lw_crfwp_timing_options($options) {
$options['604800'] = __( 'One week', 'crwfp' );
return $options;
}
add_filter( 'crfwp_timing_options', 'lw_crfwp_timing_options' );
@leewillis77
leewillis77 / functions.php
Created April 25, 2018 13:59
Remove all shipping dimensions from Google Product Feed
<?php
function lw_gpf_remove_shipping_attrs($elements, $product_id) {
unset($elements['shipping_width']);
unset($elements['shipping_length']);
unset($elements['shipping_height']);
return $elements;
}
add_filter( 'woocommerce_gpf_elements_google', 'lw_gpf_remove_shipping_attrs', 11, 2 );
@leewillis77
leewillis77 / functions.php
Created April 30, 2018 14:14
Remove shipping weight from Google Product Feed
<?php
function lw_exclude_shipping_weight( $feed_item ) {
$feed_item->shipping_weight = null;
return $feed_item;
}
add_filter( 'woocommerce_gpf_feed_item_google', 'lw_exclude_shipping_weight' );
@leewillis77
leewillis77 / functions.php
Created May 11, 2018 19:46
Example of modifying feed description in Google Product Feed extension
<?php
function lw_woocommerce_gpf_feed_item_google( $feed_item, $product ) {
// Modify $feed_item->description here.
return $feed_item;
}
add_filter( 'woocommerce_gpf_feed_item_google', 'lw_woocommerce_gpf_feed_item_google', 10, 2 );
@leewillis77
leewillis77 / functions.php
Created July 31, 2018 15:04
Add custom label to Google Product Feed item
<?php
function lw_woocommerce_gpf_feed_item_google( $feed_item, $product ) {
$feed_item->additional_elements['custom_label_0'] = array( 'My custom label' );
return $feed_item;
}
add_filter( 'woocommerce_gpf_feed_item_google', 'lw_woocommerce_gpf_feed_item_google', 10, 2 );