Skip to content

Instantly share code, notes, and snippets.

View Auke1810's full-sized avatar

Auke Jongbloed Auke1810

View GitHub Profile
@Auke1810
Auke1810 / header.php
Created February 15, 2018 10:35
Easily add the correct structured data using Microdata for Google Merchant, this includes the missing microdata for condition. At the bottom of the header simple add the code below
<?php $meta = get_post_meta(get_the_ID());?>
<?php if (isset($product)){ ?>
<div itemscope itemtype="http://schema.org/Product">
<meta itemprop="name" content="<?php echo get_the_title(get_the_ID()); ?>">
<meta itemprop="productID" content="<?php echo get_the_ID(); ?>">
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<meta itemprop="price" content="<?php echo get_post_meta( get_the_ID(), '_regular_price', true); ?>" />
<meta itemprop="priceCurrency" content="<?php echo get_woocommerce_currency(); ?>" />
<link itemprop="availability" href="http://schema.org/<?php echo $meta['_stock_status'][0] ? 'InStock' : 'OutOfStock'; ?>" />
<meta itemprop="itemCondition" itemtype="http://schema.org/OfferItemCondition" content="http://schema.org/NewCondition" />
@Auke1810
Auke1810 / wpmf-mapping-exlude.php
Last active February 27, 2018 09:36
We added the "wppfm_category_mapping_exclude", "wppfm_category_mapping_exclude_tree" and "wppfm_category_mapping_max_categories" filters. You can use these filters to limit the number of categories in the Category Mapping list on the Edit Feed page.
// If you want to remove the categories with ids 10, 12, 14 and 16 from the Category Mapping, including their children categories,
// you could use the following code in your functions.php file
// hook the remove_cats function to the wppfm_category_mapping_exclude_tree event
add_filter( 'wppfm_category_mapping_exclude_tree', 'remove_cats' );
function remove_cats() {
// return a comma separated string or an array with the category ids you want to exclude
return "10,12,14,16";
}
@Auke1810
Auke1810 / set-image-link-feed-manager.php
Last active March 27, 2018 12:19
set image link feed manager
@Auke1810
Auke1810 / make-item-title-lower-case.php
Last active March 31, 2018 09:04
Make title attribute lowercase
/**
* Alter Product feed item
* Make the title attribute lowercase
*/
function alter_feed_item( $attributes, $feed_id, $product_id ) {
// lowercase
$title = $attributes['title'];
$title = strtolower($title); //make lower case
$title = ucfirst($title) // maken first character capitalized
<?php
// wppfm feed ides in queue Filter
//
function only_last_week_ids( $ids ) {
$index = 0; // set the index
foreach( $ids as $id ) {
$post_date = get_the_date( 'U', $id ); // get the posts published date
@Auke1810
Auke1810 / convert-attribute-to-uppercase.php
Last active August 3, 2018 11:26
Convert Attribute to Uppercase
<?php
/**
* Alter Product feed item
* Uppercase a source value (attribute_pa_cup) and combine with an other source value in the size attribute
*/
function alter_feed_item( $attributes, $feed_id, $product_id ) {
// get values
$attribute_pa_band = $attributes['custom_label_0']; //add the attribute_pa_band to attribute "custom_label_0"
@Auke1810
Auke1810 / woocomerce-multipl-currencies-support.php
Last active July 27, 2018 16:38
This little script will help you to use the woocomerce multiple currencies with our woocommerce product feed manager. You are able to create several feeds with different currencies.
<?php
function alter_feed_item( $attributes, $feed_id, $product_id ) {
// In this example I have added the "custom_label_0" to each feed.
// Custom_label_0 is filled with a ISO currency code as a static value
// Forinstance the ISO currency code for the US is USD.
// uses wmc_get_price() from woocomerce multiple currencies
//get the correct price in the correct currency.
@Auke1810
Auke1810 / alter_feed_price_item_remove_thousand_seperator.php
Last active June 13, 2022 19:43
remove the thousand seperator from the price item in a feed created with wp product feed manager.
<?php
function alter_feed_price_item_remove_thousand_seperator( $attributes, $feed_id, $product_id ) {
global $product;
$product = wc_get_product( $product_id );
$product_price = $attributes['price'];
// show price without thousand separator and . as decimal separator
$attributes['price'] = number_format( $product_price, 2, '.', '') . " EUR";
// price will look like 1234.57
@Auke1810
Auke1810 / header.php
Last active January 16, 2019 09:18
Easily add the correct structured data using JSON-LD Google Merchant, this includes the missing microdata for condition.
<?php
// Locate the file header.php in your theme
// Before editing header.php, always make a backup so that you can roll back if something goes wrong.
// At the bottom of the header, simple add the code below
// Verify that you have done it correctly by checking the page with Google’s Structured Data Testing Tool
// https://search.google.com/structured-data/testing-tool
if (isset($product)){
$meta = get_post_meta(get_the_ID());
$_product = new WC_Product(get_the_ID());
if ($_product->regular_price!=NULL){
@Auke1810
Auke1810 / gist:202a0a96614f5ae36625516ccd4a0ffc
Created February 13, 2019 22:29
The wppfm_cdata_keys() function makes it possible to add attributes to be included in CDATA bracket.
function expand_cdata_attributes( $cdata_attributes ) {
// price and availability attributes are added to the list of attributes that are included in a CDATA bracket
array_push( $cdata_attributes, 'price', 'availability' );
return $cdata_attributes;
}
add_filter( 'wppfm_cdata_keys', 'expand_cdata_attributes' );