Skip to content

Instantly share code, notes, and snippets.

View Auke1810's full-sized avatar
🏠
Working from home

Auke Jongbloed Auke1810

🏠
Working from home
View GitHub Profile
@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 / 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"
<?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 / 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
@Auke1810
Auke1810 / set-image-link-feed-manager.php
Last active March 27, 2018 12:19
set image link feed manager
@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 / 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 / Alter Product feed price item
Last active December 19, 2017 11:17
Use the price including tax in the price attribute for the woocommerce product feed manager
/**
* Alter Product feed item
* Use the price including tax in the price attribute
*/
function alter_feed_item( $attributes, $feed_id, $product_id ) {
global $product;
$product = wc_get_product( $product_id );
// show price including tax
$attributes['price'] = $product->get_price_including_tax() . " USD";
@Auke1810
Auke1810 / Alter feed items
Last active October 2, 2019 19:23
Example how to use the wppfm_feed_item_value filter for woocommerce product feed manager
<?php
function alter_feed_item( $attributes, $feed_id, $product_id ) {
// The $attributes variable is an array that contains all the product data that goes into the feed. Each item
// can be accessed by it's feed key. So if in the feed file an item has a key like 'description', you
// can access that specific item by $attributes['description'].
// The $feed_id (string) makes it possible to only edit a specific feed. You can find the id of a feed in the
// url of the Feed Editor, right after id=.
// The $product_id (string) makes it possible to select a specific product id that you want to filter.
@Auke1810
Auke1810 / more_products.php
Created August 18, 2017 12:08
Te vinden in shelflife/includes/
<?php
/**
* More Products Component
*
* Display X more products.
*
* @author Matty
* @since 1.0.0
* @package WooFramework
* @subpackage Component