Skip to content

Instantly share code, notes, and snippets.

@harishankerr
harishankerr / tnt-express-tracking.php
Last active August 12, 2016 11:13
TNT Express Tracking Workaround for WooCommerce Shipment Tracking Plugin
<?php // Use only if required
// Custom snippet to add TNT Shipping Functionality for the WooCommerce Shipment Traciking Plugin.
add_filter( 'wc_shipment_tracking_get_providers', '_wc_shipment_tracking_tnt_express_domestic' );
function _wc_shipment_tracking_tnt_express_domestic( $providers ) {
$providers['United Kingdom']['TNT Express domestic (consignment)'] = 'https://www.tnt.com/webtracker/tracking.do?cons=%1$s&trackType=CON&respLang=en&respCountry=gb&sourceCountry=gb&requestType=GEN&searchType=CON';
return $providers;
}
@harishankerr
harishankerr / wc-price-free-cart.php
Last active August 12, 2016 11:27
Modify the display of free price 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 ) {
<?php
function social_login_button() {
echo do_shortcode('[woocommerce_social_login_buttons return_url="http://yoursite.com/your-checkout-url"]');
}
add_action( 'woocommerce_before_checkout_billing_form', 'social_login_button' );
?>
@harishankerr
harishankerr / gist:bffd6c211bb6afb23fed9621622d9579
Created August 26, 2016 10:38
Move Location of WooCommerce Variable Products
woocommerce_after_add_to_cart_button
@harishankerr
harishankerr / variable-product-description.php
Last active August 26, 2016 10:40
Move Location of WooCommerce Variable Products
<?php
/* Add this to your theme's functions.php to move the variation description display to a different location
* on the product page.
*/
add_action('plugins_loaded', 'move_variation_description', 50);
function move_variation_description(){
// Remove the hook from the original location
<?php // Remove this if not required.
add_filter( 'wc_shipment_tracking_get_providers', 'custom_woocommerce_shipment_tracking_provider' );
function custom_woocommerce_shipment_tracking_provider( $provider ) {
$provider = array(
'United States' => array(
'UPS'
=> 'http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=%1$s',
<?php // Use only if required.
if ( ! function_exists( 'my_custom_event_function' ) ) {
function my_custom_event_function() {
wc_google_analytics_pro()->get_integration()->custom_event( 'onBannerClick', array(
'hitType' => 'event',
'eventCategory' => 'Outbound Link',
'eventAction' => 'click',
'eventLabel' => 'Shopping-Banner',
'eventValue' => null,
<?php
// usage example: Current Stock: [product_stock id="2525"]
add_shortcode('product_stock', 'product_stock');
function product_stock( $atts ) {
if ( ! $atts['id'] ) {
return '';
}
$product = get_product($atts['id']);
return (int)$product->stock; // prints 19, ie the quantity of product 2525
<?php
// Shortcode to get variation stock. usage example: Current Stock: [variation_stock id="2525"]
// The id being entered should be that of the variation, not the product.
add_shortcode('variation_stock', 'variation_stock');
function variation_stock( $atts ) {
if ( ! $atts['id'] ) {
return '';
}
.single-product div.product form.cart .button {
float: left;
}