Skip to content

Instantly share code, notes, and snippets.

Avatar

Auke Jongbloed Auke1810

View GitHub Profile
@Auke1810
Auke1810 / shortcoder support
Created Dec 24, 2022
Woocommerce product feed manager snippet so the Shortcoder plugin is supported (https://wordpress.org/plugins/shortcoder/)
View shortcoder support
function wppfm_shortcoder_support( $attributes, $feed_id, $product_id ) {
if ( has_custom_field( $attributes['description'] ) ) {
$description = $attributes['description'];
$attr = [ 'name' => get_shortcode_name_from_description( $description ) ];
//parse shortcodes do_shortcode
$attributes['description'] = process_product_shortcode( $attr, $description, $product_id );
}
@Auke1810
Auke1810 / wppfm_product_category_string_gets_full_category_path.php
Last active Sep 28, 2022
If you want to override the Yoast default category to get the full category path of a product in the "product_type" attribute.
View wppfm_product_category_string_gets_full_category_path.php
<?php
function wppfm_product_category_string_gets_full_category_path( $data, $feed_id, $product_id ) {
$data['product_type'] = WPPFM_Taxonomies::get_shop_categories( $product_id, ' > ' );
// Always return data!
return $data;
}
@Auke1810
Auke1810 / alter-descr-item
Created Aug 25, 2022
Strip &nbsp; from description attributes in the woocommerce product feed manager from wpmarketingrobot.com
View alter-descr-item
<?php
function alter_feed_item( $attributes, $feed_id, $product_id ) {
// Strip &nbsp; from description attributes
$attributes['description'] = str_replace('&nbsp;', ' ', $attributes['description']);
// IMPORTANT! Always return the $attributes
return $attributes;
}
@Auke1810
Auke1810 / gist:ba1f71311df86b19b580ff81c5216d25
Last active Apr 20, 2022
This is an example how to derive Taxonomy data from Wordpress and add this to the product feed created with the Woocommerce product feed manager from wpmarketingrobot.com You will need to edit the variabels in order to make it more readable for your taxonomy.
View gist:ba1f71311df86b19b580ff81c5216d25
/**
*
*/
function wppfm_add_taxonomy_data_to_feed( $data, $feed_id, $product_id ) {
// Get the product_badges taxonomy data.
$taxonomyName = 'product_taxonomy_data'; // use the name of your own taxonomy
$taxonomyData = wp_get_post_terms( $product_id, $taxonomyName );
if ( $taxonomyData ) {
@Auke1810
Auke1810 / uppercase_words_title.php
Last active Nov 24, 2021
Uppercase the first character of each word in the title attribute
View uppercase_words_title.php
<?php
function string_uppercase_title( $attributes, $feed_id, $product_id ) {
// this line changes the title data and removes the " <prompt> " string
$attributes['title'] = ucwords(strtolower($attributes['title']));
// IMPORTANT! Always return the $attributes
return $attributes;
}
@Auke1810
Auke1810 / changecsvseparator.php
Created Oct 17, 2021
CHange the separator in the custom CSV builder
View changecsvseparator.php
<?php
// change the separator in the custom CSV builder from wpmarketingrobot
function change_csv_separator() {
return ';'; //return the separator you want.
}
add_filter( 'wppfm_csv_separator', 'change_csv_separator' );
@Auke1810
Auke1810 / remove-products-from-queue.php
Last active Sep 13, 2021
remove all products in array from feed.
View remove-products-from-queue.php
<php?
function remove_some_products_from_the_queue( $products, $feed_id ) {
// Products to remove from the feed
$products_to_remove = array(
'20890',
'20891',
'20972',
);
View Price including tax.php
<?php
// Price including or excluding tax
function tax_price( $data, $feed_id, $product_id ) {
global $product, $woocommerce;
// Only add this to the feed with id 58
// change the number to the feed you want to affect the prices.
// OR remove the if statement if you want to affect all feeds
if($feed_id == 1){
@Auke1810
Auke1810 / remove_list_products.php
Created Aug 26, 2021
exclude list of products from feed with the use of an array
View remove_list_products.php
<?php
function exclude_list_from_feed( $attributes, $feed_id, $product_id ) {
//Array with the numbers from products we want te exclude
$exclude_array = array(13608, 13632, 16123, 16405);
if (in_array($attributes['id'], $exclude_array,) == false )
{
// Return the $attributes from products not in the exclude list
@Auke1810
Auke1810 / shortcodes_unique_identifiers.php
Last active Mar 9, 2021
Get GTIN or MPN values from products added to products by our product feed manager and create shortcodes to use on website
View shortcodes_unique_identifiers.php
<?php
// MPN shortcode function
function wppfm_brand_shortcode() {
// get MPN value.
//$r = get_post_meta( $post->ID, 'wppfm_product_brand', true );
$r = get_post_meta( get_the_ID(), 'wppfm_product_brand', true );
// return MPN
return $r;