Skip to content

Instantly share code, notes, and snippets.

<?php // only copy if needed
/**
* Modifies the delivery estimate label; $label = "day" / "days"
*
* @param string $label the label for the day estimate
* @param int $days number of dates for the estimate
* @return string - updated label
*/
function sv_wc_shipping_estimate_modify_label( $label, $days ) {
@bekarice
bekarice / wcs-minute-renewals.php
Created June 2, 2016 05:05
Add minute / hour subscription renewals for testing
<?php // only copy if needed
/**
* Add the minute / hour into available subscription period options
*
* @param array $subscription periods associative array of available periods
* @return array - updated periods
*/
function sv_subs_new_subscription_period( $subscription_periods ) {
@bekarice
bekarice / wc-free-price-cart.php
Created May 31, 2016 22:11
Modify free price display in cart
<?php // only copy if needed
/**
* Change cart price display for free products
*
* @param string $price_html the price display html
* @param \WC_Product
* @return string - updated pricing html
*/
function sv_wc_free_cart_price( $price_html, $product ) {
@bekarice
bekarice / memberships-get-rules-sample.php
Created April 19, 2016 20:57
memberships: get plan restriction rules, check for product categories
<?php
// get plan restriction rules if we have an ID, could be used in member area for example
$plan = wc_memberships_get_membership_plan( $plan_id );
$product_rules = $plan->get_product_restriction_rules();
foreach ( $product_rules as $rule ) {
// get the ids of restricted items from the rules
$restricted_items = $rule->get_object_ids();
@bekarice
bekarice / woocommerce-updated-email-order-items-table.php
Created March 30, 2016 05:37
WooCommerce Order Emails: Add product images to the order email (WooCommerce 2.5+)
<?php // only copy this line if needed
/**
* Adds product images to the WooCommerce order emails table
* Uses WooCommerce 2.5 or newer
*
* @param string $output the buffered email order items content
* @param \WC_Order $order
* @return $output the updated output
*/
function sww_add_images_woocommerce_emails( $output, $order ) {
@bekarice
bekarice / woocommerce-product-retailers-buttons.css
Created March 25, 2016 18:24
Changes WooCommerce Product Retailers buttons (Note: this example relies on FontAwesome being loaded already)
/*---------------------------------------
WooCommerce Product Retailers adjustments
---------------------------------------*/
.wc-product-retailers-wrap > p {
text-align: right;
font-weight: 700;
font-size: 110%;
margin: 15px 0 5px 0;
}
@bekarice
bekarice / woocommerce-upsells-shortcode.php
Last active August 12, 2022 12:30
WooCommerce Upsells Shortcode: outputs product upsells when the [woocommerce_product_upsells] shortcode is used
<?php
/**
* Plugin Name: WooCommerce Upsells Shortcode
* Plugin URI: http://skyver.ge/51
* Description: Adds a shortcode to output WooCommerce product upsells; removes them from the original location when used
* Author: SkyVerge
* Author URI: https://www.skyverge.com/
* Version: 1.0.0
*
* Copyright: (c) 2016 SkyVerge, Inc. (info@skyverge.com)
@bekarice
bekarice / woocommerce-upsells-widget.php
Last active April 17, 2020 12:10
WooCommerce Upsells widget: Shows upsells in a widget on product pages, and removes the default upsell position when active
<?php
/**
* Plugin Name: WooCommerce Upsells Widget
* Plugin URI: https://www.skyverge.com/blog/moving-woocommerce-upsells-on-product-pages/
* Description: Adds a widget to display product upsells in a widget instead of below the product description
* Author: SkyVerge
* Author URI: https://www.skyverge.com/
* Version: 1.1.0
* Text Domain: woocommerce-upsells-widget
*
@bekarice
bekarice / wc-add-order-files-download-list.php
Last active August 21, 2021 04:54
WooCommerce: Add a list of custom files for an order (uses Download Monitor shortcode)
<?php // only copy this line if needed!
/**
* Adds a section with custom downloadable files to the "View Order Screen"
* if the order has a "custom_file" custom field with a download ID
* Requires Download Monitor
*
* SEE https://jilt.com/blog/selling-custom-files-woocommerce/
*
@bekarice
bekarice / wc-add-order-files-download-action.php
Last active July 12, 2019 11:35
WooCommerce: Add an order action to download custom order files
<?php // only copy this line if needed!
/**
* Adds a custom order action in the "Recent Orders" table of the WooCommerce account
* if a download ID is entered as a "custom_file" order custom field
* Button downloads custom files for the order
* Requires Download Monitor
*
* @param array $actions the actions available for the order