Skip to content

Instantly share code, notes, and snippets.

View leewillis77's full-sized avatar

Lee Willis leewillis77

View GitHub Profile
@leewillis77
leewillis77 / functions.php
Last active October 16, 2019 04:35
Modify the product_type element in the Google Product Feed
<?php
function lw_woocommerce_gpf_feed_item_google( $feed_item, $product ) {
// Modify $feed_item->additional_elements['product_type'] here, e.g.
$feed_item->additional_elements['product_type'] = [
'Product ID ' . $product->get_id(),
];
return $feed_item;
}
add_filter( 'woocommerce_gpf_feed_item_google', 'lw_woocommerce_gpf_feed_item_google', 10, 2 );
@leewillis77
leewillis77 / functions.php
Last active October 31, 2019 20:26
Add additional option to discount expiry code options in Cart Recovery for WordPress Pro plugin
<?php
add_filter( 'crfwp_discount_code_expiry_options', function( $options ) {
$options['864000'] = array(
'value' => '864000', // Length discount code is valid for (in seconds)
'selected' => '', // Leave blank
'description' => __( 'Ten days', 'crfwp' ), // Description of discount edpiry period
);
return $options;
} );
@leewillis77
leewillis77 / functions.php
Created December 3, 2019 12:08
Modify the query args used to pull products in WooCommerce Google Product Feed plugin
<?php
add_filter( 'woocommerce_gpf_wc_get_products_args', function ($args) {
// Modify the query args here.
return $args;
});
@leewillis77
leewillis77 / function.php
Last active December 13, 2019 10:08
Control whether variations are included for products
<?php
add_filter( 'woocommerce_gpf_include_variations', function ($include_variations, $wc_product) {
// Return true if you want to include variations for this $wc_product
// Return false if you do not want to include variations for this $wc_product
// Return $include_variations to honour the standard behaviour according to the extension settings.
return $include_variations;
}, 10, 2 );
@leewillis77
leewillis77 / functions.php
Created February 26, 2020 08:33
How to modify store info properties in Google Product Feed extension
<?php
add_filter( 'woocommerce_gpf_store_info', function ( $store_info ) {
// Modify store info properties here.
return $store_info;
} );
@leewillis77
leewillis77 / functions.php
Created March 4, 2020 08:44
Show how to modify google_product_category element in Google Product Feed
<?php
add_filter( 'woocommerce_gpf_elements_google', function ( $elements, $general_id, $specific_id ) {
// Customise/add $elements['google_product_category'] here. e.g.
// $elements['google_product_category'] = [ 'My actual category' ];
return $elements;
}, 10, 3 );
@leewillis77
leewillis77 / enable-say-what-multilingual.php
Created March 17, 2020 14:57
Enable per-language string replacements in Say What? Pro
<?php
/*
* Plugin Name: Language-specific replacements for Say What? Pro
* Plugin URI: https://plugins.leewillis.co.uk/
* Description: Enables language-specific replacements in the Say What? Pro plugin
* Version: 1.0
* Author: Ademti Software Ltd
* Author URI: https://www.ademti-software.co.uk/
*/
@leewillis77
leewillis77 / functions.php
Created March 17, 2020 16:10
Re-order MSRP display on product pages (WooCommerce MSRP extension)
<?php
add_action( 'init', function () {
global $woocommerce_msrp_frontend;
remove_action(
'woocommerce_single_product_summary',
[ $woocommerce_msrp_frontend, 'show_msrp' ],
7
);
add_action(
@leewillis77
leewillis77 / functions.php
Created April 3, 2020 08:18
Override whether products are excluded in the Google Product Feed
<?php
function lw_gpf_exclude_product($excluded, $product_id, $feed_format) {
// Return TRUE to specifically exclude a product
// Return FALSE to specifically include it
// Return $excluded to use the default behaviour as calculated by the extension
return $excluded;
}
add_filter( 'woocommerce_gpf_exclude_product', 'lw_gpf_exclude_product', 11, 3);
@leewillis77
leewillis77 / functions.php
Created April 7, 2020 08:36
Mark field as able to prepopulate
<?php
/*
* Plugin Name: Mark GPF fields as pre-populatable
* Plugin URI: http://docs.woothemes.com/document/google-product-feed/
* Description: Example of how to mark a field as pre-populatable in the Google Product Feed plugin.
* Version: 1.0
* Author: Ademti Software
* Author URI: https://www.ademti-software.co.uk/
*/