Skip to content

Instantly share code, notes, and snippets.

View woogist's full-sized avatar

WooCommerce.com Documentation woogist

View GitHub Profile
@woogist
woogist / gist:7302382
Created November 4, 2013 13:24
WooCommerce - rename additional information tab
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
global $product;
if( $product->has_attributes() || $product->has_dimensions() || $product->has_weight() ) { // Check if product has attributes, dimensions or weight
$tabs['additional_information']['title'] = __( 'Product Data' ); // Rename the additional information tab
}
@woogist
woogist / fue-template.html
Created December 2, 2016 09:12
Follow-up emails template name
<!-- Template Name: Unique name of your choosing -->
@woogist
woogist / gist:6267983
Created August 19, 2013 11:06
WooCommerce - Display checkout custom field on the order edition page
/**
* Display field value on the order edition page
**/
add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 );
function my_custom_checkout_field_display_admin_order_meta($order){
echo '<p><strong>'.__('My Field').':</strong> ' . $order->order_custom_fields['My Field'][0] . '</p>';
}
add_action( 'woocommerce_new_booking', 'wooninja_send_pending_confirmation_email', 10, 1 );
function wooninja_send_pending_confirmation_email( $booking_id ) {
$what_that = get_wc_booking( $booking_id );
$vendor_id = $what_that->custom_fields["_booking_vendor"];
$vendor_id = intval($vendor_id[0]);
$GLOBALS['pending_conf_vendor'] = $vendor_id;
add_filter( 'woocommerce_email_recipient_new_booking', 'wc_send_new_booking_multiple_addresses' );
@woogist
woogist / gist:1128a0803928edc4bd0f
Last active June 8, 2020 23:11
WooCommerce: change "add to cart" button text by product type
<?php
add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
/**
* custom_woocommerce_template_loop_add_to_cart
*/
function custom_woocommerce_product_add_to_cart_text() {
global $product;
$product_type = $product->product_type;
@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
@woogist
woogist / functions.php
Created June 16, 2015 07:47
Autocomplete all WooCommerce orders
/**
* Auto Complete all WooCommerce orders.
*/
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
add_filter( 'woocommerce_gforms_strip_meta_html', 'configure_woocommerce_gforms_strip_meta_html' );
function configure_woocommerce_gforms_strip_meta_html( $strip_html ) {
$strip_html = false;
return $strip_html;
}
function wc_subscriptions_custom_price_string( $pricestring ) {
global $product;
$products_to_change = array( 45, 90, 238 );
if ( in_array( $product->id, $products_to_change ) ) {
$pricestring = str_replace( 'every 3 months', 'per season', $pricestring );
}
return $pricestring;