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 / change-product-type.php
Created December 10, 2017 15:00
Change a product's type from "external" to "simple" during a Product Set import/update. [datafeedr][dfrps][dfrpswc]
<?php
/**
* Change product type from 'external' to 'simple'.
*/
function mycode_change_postmeta_product_type( $meta, $post, $product, $set, $action ) {
$meta['_product_type'] = 'simple';
return $meta;
}
@EricBusch
EricBusch / add_product_brand_taxonomy.php
Created November 17, 2017 13:55
This will import the brands into the "product_brand" taxonomy when using the WooCommerce Brands plugin. [datafeedr][dfrpswc]
<?php
/**
* Adds the brand name to the 'product_brand' taxonomy.
*
* This will import the brands into the 'product_brand' taxonomy when using
* the WooCommerce Brands plugin.
*
* @link http://www.woothemes.com/products/brands/
*
@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();
@EricBusch
EricBusch / siteground-ssh-setup.md
Last active July 30, 2024 15:03 — forked from EricBusch/siteground-ssh-setup.md
Here are instructions on setting up SSH access on SiteGround using a Mac.

Open the Terminal app on Mac.

Change directories so that you are in your user's .ssh directory. For example, my user directory is named "Eric" so I would type the following into Terminal:

cd /Users/Eric/.ssh

Now you need to generate your SSH key pairs. Enter the following command into Terminal (source 1, source 2):

ssh-keygen -t rsa -b 4096 -C "[email protected]"

@EricBusch
EricBusch / change_product_price_to_reflect_prices_in_compset.php
Last active December 31, 2017 14:33
Rewrites the price for an WooCommerce product if it contains a Comparison Set setting the highest price found in the Comparison Set to the "Regular" price and setting the lowest sale price found in the Comparison Set to the "Sale" price. [datafeedr][dfrcs]
<?php
/**
* Rewrites the price for an WooCommerce product if it contains a Comparison Set setting the
* highest price found in the Comparison Set to the "Regular" price of the product and setting
* the lowest sale price found in the Comparison Set to the "Sale" price of the product.
*
* This only works for a product which already has a Comparison Set. It does not
* work if the product has never had a Comparison Set created for it.
*
@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 / import_new_products_as_drafts.php
Last active September 24, 2018 16:26
Set newly imported products' post_status field to 'draft' instead of to 'publish'. Only applies to products being imported for the first time, not to already imported products. [datafeedr][dfrpswc]
<?php
/**
* Set newly imported products' post_status field to 'draft' instead
* of to 'publish'. Only applies to products being imported for the first
* time, not to already imported products.
*
* @param array $post Array containing Post information.
* @param array $product Array containing Datafeedr Product information.
* @param array $set Array containing Product Set information.
@EricBusch
EricBusch / add-webp-to-wordpress.php
Created October 6, 2017 18:03
This adds support for webp when importing webp images into WordPress. [datafeedr]
<?php
/**
* Add support for webp to WordPress.
*
* @param array $mime_types
*
* @return array Updated $mime_types array.
*/
add_filter( 'mime_types', 'mycode_mime_types', 20 );
@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 / add_gender_attribute-05.php
Last active September 28, 2022 16:32
Automatically add the product's gender as a gender attribute from multiple fields with defaults and normalize the gender name. [datafeedr][dfrpswc]
<?php
/**
* Add the product's gender as a gender attribute for this product.
*
* 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.