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
Created June 8, 2020 13:46
Disable unrecovered cart emails in WP Cart Recovery / WP Cart Recovery Pro plugin
<?php
// Examples of the filter to use to disable recovered cart notifications.
add_filter( 'crfw_send_recovered_cart_notifications', '__return_false' );
// Examples of the filter to use to disable unrecovered cart notifications.
add_filter( 'crfwp_send_unrecovered_cart_notifications', '__return_false' );
@leewillis77
leewillis77 / functions.php
Last active June 4, 2020 14:51
Example of adding fixed g:shipping tag to Google Product Feed
<?php
add_filter( 'woocommerce_gpf_feed_item_google', function ( $feed_item, $wc_product ) {
$feed_item->additional_elements['shipping'] = [
[
'country' => 'GB',
'region' => 'Cumbria',
'service' => 'Royal Mail',
'price' => '1.99 GBP',
]
@leewillis77
leewillis77 / functions.php
Last active May 6, 2020 08:13
Modify the number of product detail data entry fields available
<?php
add_filter( 'woocommerce_gpf_number_of_product_detail_fields', function ($x) {
// Change 5 to your desired number.
return 5;
});
@leewillis77
leewillis77 / functions.php
Last active April 21, 2020 08:17
Set custom label 1 same as title in Google Product Feed
<?php
add_filter( 'woocommerce_gpf_feed_item_google', function ($feed_item, $wc_product) {
if (!empty($feed_item->title) && empty($feed_item->additional_elements['custom_label_1'])) {
$feed_item->additional_elements['custom_label_1'] = [ $feed_item->title ];
}
return $feed_item;
}, 10, 2 );
@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/
*/
@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 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 / 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 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 / 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;
} );