Skip to content

Instantly share code, notes, and snippets.

Avatar

WooCommerce.com Documentation woogist

View GitHub Profile
@woogist
woogist / gist:b68ee2d83eb620b301ba44a365afe296
Created May 25, 2020
wc-table-rate-shipping-compare-prices-after-discounts.php
View gist:b68ee2d83eb620b301ba44a365afe296
add_filter( 'woocommerce_table_rate_compare_price_limits_after_discounts', '__return_true' );
@woogist
woogist / woocommerce-shipment-tracking-rest-api-doc.md
Last active May 22, 2020
WooCommerce Shipment Tracking REST API
View woocommerce-shipment-tracking-rest-api-doc.md

Shipment Tracking REST API

The shipment tracking REST API allows you to create, view, and delete individual shipment tracking. The endpoint is /wp-json/wc-shipment-tracking/v3/.

Shipment Tracking Properties

Attribute Type Description
tracking_id string Unique identifier for shipment tracking read-only
tracking_number string Tracking number required
View change_default_provider.php
add_filter( 'woocommerce_shipment_tracking_default_provider', 'custom_woocommerce_shipment_tracking_default_provider' );
function custom_woocommerce_shipment_tracking_default_provider( $provider ) {
$provider = 'USPS';
return $provider;
}
View hide_unused_providers.php
add_filter( 'wc_shipment_tracking_get_providers', 'custom_shipment_tracking' );
function custom_shipment_tracking( $providers ) {
unset($providers['Australia']);
unset($providers['Austria']);
unset($providers['Brazil']);
unset($providers['Belgium']);
unset($providers['Canada']);
unset($providers['Czech Republic']);
@woogist
woogist / change-products-per-page-storefront.php
Created Oct 11, 2017
Documentation: Storefront Filters example: Change the number of products displayed per page
View change-products-per-page-storefront.php
function alter_sf_products_per_page() {
// Return the number of products per page ( default: 12 ).
return 8;
}
add_filter('storefront_products_per_page', 'alter_sf_products_per_page' );
@woogist
woogist / storefront-add-featured-product-text-example.php
Created Oct 11, 2017
Documentation: Storefront Actions example: Adding content below the featured product title
View storefront-add-featured-product-text-example.php
@woogist
woogist / prevent_registered_learners_from_starting_courses.php
Created Feb 10, 2017
This code prevents Sensei learners from starting a course unless they've been specifically added to that course by a site administrator or a teacher.
View prevent_registered_learners_from_starting_courses.php
<?php
function sensei_display_start_course_form_when_admin_or_teacher( $should_display_start, $course_id ) {
global $current_user;
if ( empty( $current_user ) ) {
$current_user = wp_get_current_user();
}
if ( !( $current_user instanceof WP_User ) || 0 === $current_user->ID ) {
@woogist
woogist / fue-template.html
Created Dec 2, 2016
Follow-up emails template name
View fue-template.html
<!-- Template Name: Unique name of your choosing -->
@woogist
woogist / functions.php
Created Oct 26, 2016
Dynamic Pricing - Product Ineligible for Discounts
View functions.php
add_filter('woocommerce_dynamic_pricing_process_product_discounts', 'exclude_some_products', 10, 4);
function is_product_eligible( $eligible, $product, $discounter_name, $discounter_object ) {
if ($product->ID == 200){
$eligible = false;
}
return $eligible;
}
@woogist
woogist / functions.php
Created Oct 15, 2015
Remove the extra 'Quiz' on the single quiz page
View functions.php
add_filter( 'sensei_single_title', 'sensei_dl_custom_double_quiz_remove' );
function sensei_dl_custom_double_quiz_remove( $title ){
if( 'quiz' == get_post_type()
&& 1 < substr_count( strtoupper( $title ), 'QUIZ' ) ){
// remove all possible appearances of quiz
$title_with_no_quizzes = str_replace( 'quiz', '', $title );
$title_with_no_quizzes = str_replace( 'Quiz', '', $title_with_no_quizzes );
You can’t perform that action at this time.