This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'wp', 'wc_ninja_test' ); | |
function wc_ninja_test() { | |
$main_instance = WC_OD(); | |
$checkout_class = $main_instance->checkout(); | |
remove_action( 'woocommerce_checkout_shipping', array( $checkout_class, 'checkout_content' ), 99 ); | |
add_action( 'woocommerce_checkout_shipping', array( $checkout_class, 'checkout_content' ), 15 ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'storefront_page', 'wc_ninja_add_pages_byline', 11 ); | |
function wc_ninja_add_pages_byline() { | |
?> | |
<div class="author"> | |
<?php | |
echo '<span class="label">' . esc_attr( __( 'Written by', 'storefront' ) ) . ' </span>'; | |
the_author_posts_link(); | |
echo "<br>"; | |
storefront_posted_on(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_applied_coupon', 'wc_ninja_chain_a_coupon' ); | |
function wc_ninja_chain_a_coupon( $coupon_code ) { | |
$first_coupon = 'coupon-code-1'; | |
$chained_coupon = 'coupon-code-2'; | |
if ( $first_coupon == $coupon_code ) { | |
WC()->cart->add_discount( $chained_coupon ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hook in to add notices to the cart and checkout pages | |
add_action( 'woocommerce_before_cart_contents', 'wc_ninja_add_cart_notice' ); | |
add_action( 'woocommerce_before_checkout_form', 'wc_ninja_add_cart_notice' ); | |
/** | |
* Add the cart/checkout notice | |
*/ | |
function wc_ninja_add_cart_notice() { | |
$message = "Sorry, you cannot purchase products from the clothing and music category together."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_get_price_html', 'wc_ninja_customize_price_html', 2, 10 ); | |
function wc_ninja_customize_price_html( $price, $product ) { | |
// Enter your product's ID here | |
$product_id = 87; | |
if ( $product_id == $product->id ) { | |
$price .= ' ($2.00 per piece)'; | |
} | |
return $price; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_after_cart_table', 'wc_ninja_remove_cart_addons', 10 ); | |
function wc_ninja_remove_cart_addons() { | |
global $sfn_cart_addons; | |
remove_action( 'woocommerce_after_cart_table', array( $sfn_cart_addons, 'cart_display_addons' ), 20 ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rename the flat rate shipping label when the cost is $0 | |
function wc_ninja_change_flat_rate_label( $label, $method ) { | |
if ( 'flat_rate' == $method->method_id && $method->cost <= 0 ) { | |
$label = "Free Shipping"; | |
} | |
return $label; | |
} | |
add_filter( 'woocommerce_cart_shipping_method_full_label', 'wc_ninja_change_flat_rate_label', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const watched = document.querySelectorAll( '.video.completed' ); | |
let totalSeconds = 0; | |
// Loop over each video watched. | |
watched.forEach( video => { | |
let videoTime = video.querySelector( 'span.duration' ).textContent.split( ':' ); | |
// Turn minutes:seconds into just seconds and append to totalSeconds. | |
videoTime.map( array => { | |
totalSeconds += ( parseInt( array[0] ) * 60 ) + parseInt( array[1] ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_after_add_to_cart_button', 'wc_ninja_add_extra_button', 20 ); | |
function wc_ninja_add_extra_button() { | |
echo "<a href='#' class='button'>Return to shop</a>"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wc_ninja_add_to_billing_address( $formatted_billing_address, $type, $order ) { | |
if ( $order->billing_phone ) { | |
$formatted_billing_address .= "<br>" . $order->billing_phone; | |
} | |
if ( $order->billing_email ) { | |
$formatted_billing_address .= "<br>" . $order->billing_email; | |
} | |
return $formatted_billing_address; |