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 / import-woocommerce-gallery-images.php
Last active January 19, 2018 13:41
Imports additional product images for an array of given fields as gallery images for a WooCommerce product. [datafeedr][dfrps][dfrpswc]
@EricBusch
EricBusch / add-pricemesh-pids.php
Last active January 5, 2018 14:43
Add '_pricemesh_pids' during product set inserts and updates. [datafeedr][dfrps][dfrpswc]
<?php
/**
* Add '_pricemesh_pids' during product set inserts and updates.
*
* @param array $meta An array containing postmeta data for this $post.
* @param array $post Array containing WordPress Post information.
* @param array $product Array containing Datafeedr Product information.
* @param array $set Array containing Product Set information.
* @param string $action Either "update" or "insert" depending on what the Product Set is doing.
@EricBusch
EricBusch / prevent-content-override.php
Created January 5, 2018 13:57 — forked from EricBusch/prevent-content-override.php
Prevent the product name, product description and product excerpt from being overwritten during a Product Set update. [datafeedr]
<?php
/**
* Prevent product titles, descriptions & excerpts from being overwritten during Product Set updates.
*
* @param array $post Array containing WordPress Post information.
* @param array $product Array containing Datafeedr Product information.
* @param array $set Array containing Product Set information.
* @param string $action Either "update" or "insert" depending on what the Product Set is doing.
*
@EricBusch
EricBusch / hide-price-if-compset-exists.php
Created January 2, 2018 20:26
Hide a product's price from display on single Product pages if a product contains a cached Comparison Set that meets the minimum number of results requirement. [datafeedr][dfrcs][woocommerce]
<?php
/**
* Hide a product's price from display on single Product pages
* if a product contains a cached Comparison Set that meets the minimum number of
* results requirement.
*
* @param string $price HTML containing product price markup.
* @param WC_Product $product
*
@EricBusch
EricBusch / display-compset-under-product-name.php
Created January 2, 2018 20:09
Put the Comparison Set immediately below a Product's Name. [datafeedr][dfrcs]
<?php
/**
* Put the Comparison Set immediately below a Product's Name.
*
* The following 2 actions and 1 function will move a Comparison Set from displaying underneath the WooCommerce
* product's short description to below the product's name and above it's price.
*
* @see remove_action(), dfrcs_wc_compset_priority()
*/
@EricBusch
EricBusch / replace-buy-url-with-cheapest-from-compset.php
Last active March 5, 2021 14:02
Replace product's [Buy Now] button URL with link to lowest priced product from the Comparison Set. [datafeedr][dfrcs][woocommerce]
<?php
/**
* Replace product's [Buy Now] button URL with link to lowest priced product from
* the Comparison Set.
*
* If a Comparison Set does not exist for the product or one has not been cached
* or the number of products returned does not meet the minimum required products
* specified in the "Minimum Number of Results" field, then this will just return
* the default $url.
@EricBusch
EricBusch / add-comparison-set-price-to-product.php
Last active October 25, 2019 22:39
This code updates a WooCommerce product's price (including sale price) with data from its Comparison Set when the Comparison Set is created or its cached updated. [datafeedr][dfrcs]
<?php
/**
* This code changes a WooCommerce product's price (including sale price) with data
* from its Comparison Set when the Comparison Set is created or its cache is updated and
* the Comparison Set has a highest and lowest price.
*
* This code modifies all of a WooCommerce Product's pricing fields.
*
* @param Dfrcs $compset
@EricBusch
EricBusch / import-image-during-product-set-update.php
Last active September 26, 2018 14:32
Import a product image during a Product Set update. [datafeedr]dfrps][dfrpswc]
<?php
/**
* Import a product image during a Product Set update.
*
* This WILL cause product set updates to be slower.
*
* @param array $post Array containing WordPress Post information.
* @param array $product Array containing Datafeedr Product information.
* @param array $set Array containing Product Set information.
@EricBusch
EricBusch / set_update_hours.php
Created December 20, 2017 17:14
Configure the hours in which Product Sets should update. [datafeedr][dfrps]
<?php
/**
* Configure the hours in which Product Sets should
* do updates.
*
* @param array $post
*
* @return array $post
*/
@EricBusch
EricBusch / update-image-meta.php
Created December 11, 2017 14:11
Update the attached image's description, caption & alt text with values from the product. [datafeedr][dfrps]
<?php
/**
* Update the attached image's description, caption &
* alt text with values from the product when the image is imported.
*
* @param integer $attachment_id Attachment ID of imported image.
* @param Dfrps_Image_Importer $image_importer
*/
function mycode_update_image_meta( $attachment_id, $image_importer ) {