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
/* Derek's Sum Code */ | |
// Add Shortcode | |
function calculator_shortcode() { | |
$post_args = array( | |
'post_type' => 'post', | |
'posts_per_page' => 10000, | |
'no_found_rows' => true, | |
'update_post_term_cache' => false, |
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
/******************************** MODELS SHORTCODE ********************************/ | |
function models_shortcode($atts){ | |
extract( shortcode_atts( array( | |
'expand' => '', | |
), $atts) ); | |
$mod_args = array( | |
'post_type' => 'model', | |
'orderby' => 'menu_order', | |
'order' => 'ASC', |
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
/* CHECK IF PRODUCT IS IN ORDER TEMPLATE */ | |
function tb_check_order_product_id( $order_id ){ | |
$order = new WC_Order( $order_id ); | |
$items = $order->get_items(); | |
foreach ( $items as $item ) { | |
$product_id = $item['product_id']; | |
if ( $product_id == XYZ ) { | |
// do something | |
} | |
} |
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
/* FREE PRODUCTS SIMPLIFY CHECKOUT */ | |
function mtpt_free_checkout_fields() { | |
// Bail we're not at checkout, or if we're at checkout but payment is needed | |
if ( function_exists( 'is_checkout' ) && ( ! is_checkout() || ( is_checkout() && WC()->cart->needs_payment() ) ) ) { | |
return; | |
} | |
// remove coupon forms since why would you want a coupon for a free 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
/* CHANGE USER ROLE FOR NEW CUSTOMERS */ | |
/* 1. ADD NEW ROLE */ | |
add_role( 'pending', __('Pending' ),array( | |
'read' => true, | |
) | |
); | |
/* 2. ASSIGN NEW ROLE */ | |
function tb_assign_custom_role($args) { |
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
/* ADD TO CART REDIRECT PER PRODUCT */ | |
/* STEP 1 - REMOVE ADD TO CART BUTTON ON PRODUCT ARCHIVE (SHOP) */ | |
function remove_loop_button(){ | |
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); | |
} | |
add_action('init','remove_loop_button'); | |
/*STEP 2 -ADD NEW BUTTON THAT LINKS TO PRODUCT PAGE FOR EACH PRODUCT */ | |
function replace_add_to_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
/* HIDE CATEGORY FROM SHOP */ | |
add_action( 'pre_get_posts', 'custom_pre_get_posts_query' ); | |
function custom_pre_get_posts_query( $q ) { | |
if ( ! $q->is_main_query() ) return; | |
if ( ! $q->is_post_type_archive() ) return; | |
if ( ! is_admin() && is_shop() ) { |
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
/* Hide all shipping options when free shipping is available */ | |
/* @param array $available_methods*/ | |
function hide_all_shipping_when_free_is_available( $available_methods ) { | |
if( isset( $available_methods['free_shipping'] ) ) : | |
// Get Free Shipping array into a new array | |
$freeshipping = array(); | |
$freeshipping = $available_methods['free_shipping']; |
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
/******************************** FOOTER COPYRIGHT ********************************/ | |
function tb_footer_copyright() { | |
?> | |
<p> | |
© <?php echo date("Y"); echo " "; echo "Sunado Vans"; ?> <a href="/privacy-policy/" title="Our Privacy Policy" class="Privacy">Privacy Policy</a> | |
</p> | |
<?php | |
} | |
add_filter( 'generate_copyright','tb_footer_copyright' ); |
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
/* Display products pagination */ | |
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 18;' ), 20 ); |
NewerOlder