This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Display the Savings discount for a product that's on sale on product list pages. | |
*/ | |
add_action( 'woocommerce_after_shop_loop_item', 'mycode_show_discount_in_product_lists' ); | |
function mycode_show_discount_in_product_lists() { | |
global $product; | |
$salediscount = get_post_meta( $product->id, '_dfrps_salediscount', true ); | |
if ( $salediscount > 0 ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add "Sort by discount" to sorting options. Defaults to biggest to smallest discount. | |
*/ | |
add_filter( 'woocommerce_get_catalog_ordering_args', 'mycode_woocommerce_add_salediscount_to_catalog_ordering_args' ); | |
function mycode_woocommerce_add_salediscount_to_catalog_ordering_args( $args ) { | |
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); | |
if ( 'discount' == $orderby_value ) { | |
$args['orderby'] = 'meta_value_num'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add the product's brand as an attribute. | |
* | |
* The attribute "Brand" with a slug of "brand" 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_brand or pa_shoe-size | |
* @param array $post An array of post data including ID, post_title, post_status, etc... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Replace all product images in a Comparison Set that use HTTP instead of HTTPS with | |
* the default WooCommerce placeholder image. | |
* | |
* @param string $html <img> tag. | |
* @param array $p Datafeedr product array. | |
* | |
* @return string Updated $html. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This modifies the affiliate link and redirects the link back to the site's | |
* homepage with specific query parameters added. | |
*/ | |
add_filter( 'dfrapi_after_affiliate_id_insertion', 'mycode_redirect_to_exit_page', 20, 3 ); | |
function mycode_redirect_to_exit_page( $url, $product, $affiliate_id ) { | |
$args = array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# | |
# Script to deploy from Github to WordPress.org Plugin Repository | |
# A modification of a number of different sources: | |
# @link https://github.com/deanc/wordpress-plugin-git-svn | |
# @link https://github.com/GaryJones/wordpress-plugin-svn-deploy | |
# @link https://github.com/thenbrent/multisite-user-management/blob/master/deploy.sh | |
# | |
# Accompanying Tutorial Here: | |
# @link https://ericbusch.net/?p=106 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Hide specific attributes from the Additional Information tab on single | |
* WooCommerce product pages. | |
* | |
* @param WC_Product_Attribute[] $attributes Array of WC_Product_Attribute objects keyed with attribute slugs. | |
* @param WC_Product $product | |
* | |
* @return WC_Product_Attribute[] |