This file contains hidden or 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
<?php | |
function ik_wc_discount_total() { | |
global $woocommerce; | |
$discount_total = 0; | |
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values) { | |
$_product = $values['data']; | |
if ( $_product->is_on_sale() ) { | |
$regular_price = $_product->get_regular_price(); |
This file contains hidden or 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
<?php | |
/** | |
* product title with sku | |
*/ | |
function woo_product_title_with_sku() { | |
global $product; | |
echo '<span class="loop-title-sku">Sku: ' . $product->get_sku() . '</span><br>'; | |
} |
This file contains hidden or 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
<?php | |
/* | |
custom action hook | |
*/ | |
do_action( 'my_custom_action' ); | |
//Place the code for the action when fired | |
function my_action_something_cool() { |
This file contains hidden or 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
<?php | |
/* | |
custom filter hook | |
*/ | |
function custom_filter_something_cool() { | |
$output = 'Hello World'; | |
return apply_filters('my_custom_filter', $output); |
This file contains hidden or 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
<?php | |
/* | |
update cart on quantity field value change | |
*/ | |
function wc_qty_change_update_cart(){?> | |
<script> | |
jQuery(".qty").blur(function(){ | |
jQuery("[name='update_cart']").trigger("click"); |
This file contains hidden or 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
<?php | |
/* | |
update checkout on billing postcode field blur | |
*/ | |
function wc_field_blur_update_checkout(){?> | |
<script> | |
jQuery("#billing_postcode").blur(function(){ | |
jQuery( 'body' ).trigger( 'update_checkout' ); |
This file contains hidden or 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
<?php | |
/* | |
update cart on quantity field value change | |
*/ | |
add_action( 'wp_footer', 'wc_qty_change_update_cart' ); | |
function wc_qty_change_update_cart() { | |
if (is_cart()) : | |
?> |
This file contains hidden or 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
<?php | |
/* | |
* Notification on order processing to cancelled status change | |
*/ | |
function ci_cancelled_notification( $order_id ) { | |
$order = wc_get_order( $order_id ); | |
// load the mailer class |
This file contains hidden or 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
<?php | |
/** | |
* Insert the new endpoint into the My Account menu. | |
* | |
* @param array $items | |
* @return array | |
*/ | |
function ci_custom_account_menu_items( $items ) { | |
// Remove the logout menu item. | |
$logout = $items['customer-logout']; |
This file contains hidden or 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
<?php | |
/* | |
*Add WooCommerce checkout Custom shipping field | |
*/ | |
add_filter( 'woocommerce_checkout_fields' , 'ci_custom_override_checkout_fields' ); | |
// Our hooked in function - $fields is passed via the filter! | |
function ci_custom_override_checkout_fields( $fields ) { | |
$fields['shipping']['shipping_fax'] = array( |