Skip to content

Instantly share code, notes, and snippets.

View EricBusch's full-sized avatar

Eric Busch EricBusch

  • Owen Sound, Ontario
View GitHub Profile
@EricBusch
EricBusch / add-rel-nofollow-to-woocommerce-product-links.php
Created July 25, 2017 12:22 — forked from EricBusch/add-rel-nofollow-to-woocommerce-product-links.php
This code allows you to add a rel="nofollow" to your WooCommerce products that appear in the loop. [datafeedr]
@EricBusch
EricBusch / import-product-image-during-product-set-update.php
Created July 25, 2017 12:23 — forked from EricBusch/import-product-image-during-product-set-update.php
Import a product's image during a Product Set import/update instead of after the product is imported. Use with CAUTION. This may cause product imports to be drastically slower or fail. [datafeedr][dfrpswc]
<?php
/**
* Import a product's image during a Product Set import/update instead
* of after the product is imported.
*
* Use with CAUTION. This may cause product imports to be drastically slower or fail.
*
* @see do_action_ref_array(), get_post()
*
@EricBusch
EricBusch / move_comparison_set_immediately_below_product_title.php
Created July 25, 2017 12:23 — forked from EricBusch/move_comparison_set_immediately_below_product_title.php
This code removes a Datafeedr Comparison Set from appearing below the product's details on the WooCommerce product page and adds it immediately below the product's title on single product pages.
<?php
/**
* Remove Comparison Sets from WooCommerce Product pages.
*
* @see remove_action(), dfrcs_wc_compset_priority()
*/
add_action( 'wp_head', 'mycode_remove_compset_from_woocommerce_product_pages' );
function mycode_remove_compset_from_woocommerce_product_pages() {
remove_action( 'woocommerce_after_single_product_summary', 'dfrcs_wc_single_product_page_compset', 0 );
@EricBusch
EricBusch / force-insert-affiliate-id-plugins-deactivated.php
Last active September 1, 2017 14:25
Forces the insertion of your affiliate ID into the affiliate link even if the Datafeedr API plugin has been deactivated or uninstalled. [datafeedr][dfrapi][dfrpswc]
<?php
/**
* Forces the insertion of your affiliate ID into the affiliate link even
* if the Datafeedr API plugin has been deactivated or uninstalled.
*
* This should be added to your My Custom Code plugin.
* @link https://datafeedrapi.helpscoutdocs.com/article/32-creating-your-own-custom-plugin
*
* @see mycode_dfrapi_url()
@EricBusch
EricBusch / prevent_product_price_override.php
Created September 1, 2017 15:33
Prevent the price of a product from being overridden during a Product Set update. [datafeedr][dfrpswc]
<?php
/**
* Prevent the price of a product from being overridden during a Product Set update.
*
* This code will allow the product's price to be imported when the product is first imported but
* upon all subsequent Product Set updates, the product's price will not be updated. Instead it will
* rely on the price already in the database.
*
* @param array $meta An array containing postmeta data for this $post.
@EricBusch
EricBusch / geargrabber.php
Created September 19, 2017 16:50
GearGrabber Custom Plugin - The following code is used on https://www.geargrabber.net/ to further customize various Datafeedr elements. [datafeedr]
<?php
/**
* Plugin Name: GearGrabber
* Plugin URI: https://www.geargrabber.net/
* Description: Custom code for https://www.geargrabber.net/
* Text Domain: geargrabber
* Domain Path: /languages
* Version: 1.0.12
*
* @package geargrabber
@EricBusch
EricBusch / add_product_tags.php
Last active September 19, 2017 19:21
Adds specific product fields as product tags. This code will get the values from specific product fields and then set those values as tags for the product. [datafeedr][dfrpswc]
<?php
/**
* Adds specific product fields as product tags.
*
* This code will get the values from specific product fields and then
* set those values as tags for the product.
*
* @param array $taxonomies An array keyed by taxonomy name and having values of taxonomy values.
* @param array $post An array of post data including ID, post_title, post_status, etc...
@EricBusch
EricBusch / mycode_dfrapi_url.php
Last active October 31, 2017 13:16
Custom function that returns the affiliate URL with inserted affiliate ID for any Datafeedr product imported by the Product Sets plugin and saved as a WooCommerce External Product. [datafeedr]
<?php
/**
* Returns the affiliate URL with inserted affiliate ID for any
* Datafeedr product imported by the Product Sets plugin and
* saved as a WooCommerce Product.
*
* Usage: $url = mycode_dfrapi_url( $product );
*
* Returns an empty string if no Datafeedr product exists.
@EricBusch
EricBusch / add-merchant-logo-to-loop.php
Last active November 3, 2017 15:11 — forked from EricBusch/add-merchant-logo-to-loop.php
This code will add the merchant logo (if the logo exists) to the loop between product thumbnail and product name. [datafeedr]
<?php
/**
* Add merchant logo (if it exists) to the Loop between product thumbnail and product name.
*/
add_action( 'woocommerce_before_shop_loop_item_title', 'mycode_add_merchant_logo_to_loop', 20 );
function mycode_add_merchant_logo_to_loop() {
global $product;
if ( dfrpswc_is_dfrpswc_product( $product->get_id() ) ) {
$postmeta = get_post_meta( $product->get_id(), '_dfrps_product', true );
@EricBusch
EricBusch / @plan.md
Last active November 15, 2017 20:09 — forked from dillinghamio/@plan.md
Laravel Spark @plan Blade Directive - Create new Blade Directive (conditional)

@plan Blade Directive For Laravel Spark

Works with user & team billing

Add this to the boot() method of your AppServiceProvider

\Blade::directive('plan', function($plans) {

 $model = auth()-&gt;user();