Skip to content

Instantly share code, notes, and snippets.

View woogist's full-sized avatar

WooCommerce.com Documentation woogist

View GitHub Profile
@woogist
woogist / woo-product-custom-fields.php
Last active March 21, 2024 13:36
Display a product custom field within single product pages after the short description
<?php
// Display a product custom field within single product pages after the short description
function woocommerce_custom_field_example() {
if ( ! is_product() ) {
return;
}
@woogist
woogist / woo_remove_product_warranty.php
Last active March 29, 2023 15:06
Remove the product warrant text from above the add to cart button on a product page
add_action( 'woocommerce_before_add_to_cart_button', 'woo_remove_product_warranty', 9);
function woo_remove_product_warranty() {
global $warranty_cart;
remove_action( 'woocommerce_before_add_to_cart_button', array( $warranty_cart, 'show_product_warranty' ) );
}
@woogist
woogist / wc-eu-vat-remove-some-countries.php
Created September 29, 2021 12:01
filter to remove select countries where the VAT number field will show for
add_filter( 'woocommerce_eu_vat_number_country_codes', 'woo_custom_eu_vat_number_country_codes' );
function woo_custom_eu_vat_number_country_codes( $vat_countries ) {
$display_vat = array_diff($vat_countries, ['SE', 'GB']); // remove countries in second array
return array_values($display_vat); // reindex array
}
@woogist
woogist / wc-eu-vat-one-country.php
Created September 29, 2021 12:00
filter the countries where the VAT number field will show for
add_filter( 'woocommerce_eu_vat_number_country_codes', 'woo_custom_eu_vat_number_country_codes' );
function woo_custom_eu_vat_number_country_codes( $vat_countries ) {
// only show field for users in BE
return array( 'BE' );
}
@woogist
woogist / gist:b68ee2d83eb620b301ba44a365afe296
Created May 25, 2020 09:39
wc-table-rate-shipping-compare-prices-after-discounts.php
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 14:16
WooCommerce Shipment Tracking REST API

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
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;
}
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 October 11, 2017 15:02
Documentation: Storefront Filters example: Change the number of products displayed per page
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 October 11, 2017 14:59
Documentation: Storefront Actions example: Adding content below the featured product title