Skip to content

Instantly share code, notes, and snippets.

Eric Busch EricBusch

Block or report user

Report or block EricBusch

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@EricBusch
EricBusch / replace-buy-button-with-details-button.php
Last active Jul 11, 2019
Replace [Buy product] button with [More details] button for WooCommerce External/Affiliate links
View replace-buy-button-with-details-button.php
add_action( 'woocommerce_before_shop_loop_item', function () {
global $product;
if ( 'external' == $product->get_type() ) {
add_action( 'woocommerce_after_shop_loop_item', 'mycode_more_details_button' );
}
} );
@EricBusch
EricBusch / prevent-attribute-overwrite-on-product-set-update.php Prevent taxonomy-based attributes from being overwritten when a Product Set updates a product already in your store. [datafeedr]
View prevent-attribute-overwrite-on-product-set-update.php
<?php
/**
* Prevent taxonomy-based attributes from being overwritten when a Product Set
* updates a product already in your store.
*
* @see wc_get_product_terms()
* @link http://stackoverflow.com/a/13454788/2489248
*
* @param array|string $value The current value of the $attribute for this $post.
@EricBusch
EricBusch / Mycode_Replace_Missing_Images_With_External_Images.php
Last active May 22, 2019
Replaces any placeholder images with hotlinked image from merchant's server. [dfrpswc][datafeedr]
View Mycode_Replace_Missing_Images_With_External_Images.php
<?php
/**
* Class Mycode_Replace_Missing_Images_With_External_Images
*
* Replaces any placeholder images with hotlinked image from merchant's server.
*
* @since 1.0.0
*/
class Mycode_Replace_Missing_Images_With_External_Images {
@EricBusch
EricBusch / optimize-and-prune.php
Last active Feb 26, 2019
Automatically optimize specific WordPress tables and prune specific rows from the "options" table. Use with caution and with backups in place!
View optimize-and-prune.php
<?php
/**
* Adds a new cron interval to the cron $schedules array.
*
* @param array $schedules
*
* @return array
*/
function mycode_my_custom_cron_schedules( $schedules ) {
@EricBusch
EricBusch / display-data-single-product-page.php
Created Dec 3, 2018
Display Datafeedr Product data on single product page in WooCommerce.
View display-data-single-product-page.php
<?php
/**
* Display product fields before the "buy" button on single product page.
*
* @global WC_Product $product
*/
function mycode_display_extra_data_on_single_product_page() {
global $product;
@EricBusch
EricBusch / display-data-in-loop.php
Created Dec 3, 2018
Display Datafeedr Product Data in WooCommerce Loop
View display-data-in-loop.php
<?php
/**
* Display product fields before the product's title in the Loop.
*
* @global WC_Product $product
*/
function mycode_display_extra_data_in_loop() {
global $product;
@EricBusch
EricBusch / mycode_import_age_group_attribute-1.php
Created Jul 23, 2018
Preferred Terms, Term Variants and Excluded Terms [dfrpswc][datafeedr]
View mycode_import_age_group_attribute-1.php
<?php
/**
* Add the product's Age Group as an attribute.
*
* The attribute "Age Group" with a slug of "age-group" must already exist here: WordPress Admin Area > Products > Attributes
*
* @param array|string $value The current value of the $attribute for this $post.
* @param string $attribute The slug of the attribute. Examples: pa_color or pa_shoe-size
* @param array $post An array of post data including ID, post_title, post_status, etc...
@EricBusch
EricBusch / mycode_import_gender_attribute-2.php
Created Jul 23, 2018
Providing a Default Value if No Terms Found [dfrpswc][datafeedr]
View mycode_import_gender_attribute-2.php
<?php
/**
* Add the product's gender as an attribute.
*
* The attribute "Gender" with a slug of "gender" must already exist here: WordPress Admin Area > Products > Attributes
*
* @param array|string $value The current value of the $attribute for this $post.
* @param string $attribute The slug of the attribute. Examples: pa_color or pa_shoe-size
* @param array $post An array of post data including ID, post_title, post_status, etc...
@EricBusch
EricBusch / mycode_import_color_attribute-4.php
Created Jul 23, 2018
Import Attribute From Multiple Fields with Preferred Terms [dfrpswc][datafeedr]
View mycode_import_color_attribute-4.php
<?php
/**
* Add the product's color as an attribute.
*
* The attribute "Color" with a slug of "color" must already exist here: WordPress Admin Area > Products > Attributes
*
* @param array|string $value The current value of the $attribute for this $post.
* @param string $attribute The slug of the attribute. Examples: pa_color or pa_shoe-size
* @param array $post An array of post data including ID, post_title, post_status, etc...
@EricBusch
EricBusch / mycode_import_color_attribute-3.php
Created Jul 23, 2018
Adding a Fallback Field When Attribute Variants Aren't Found [dfrpswc][datafeedr]
View mycode_import_color_attribute-3.php
<?php
/**
* Add the product's color as an attribute.
*
* The attribute "Color" with a slug of "color" must already exist here: WordPress Admin Area > Products > Attributes
*
* @param array|string $value The current value of the $attribute for this $post.
* @param string $attribute The slug of the attribute. Examples: pa_color or pa_shoe-size
* @param array $post An array of post data including ID, post_title, post_status, etc...
You can’t perform that action at this time.