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
| // 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 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_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 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_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 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_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 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_filter( 'woocommerce_bundle_requires_input', 'wc_ninja_require_bundle_input', 10, 2 ); | |
| function wc_ninja_require_bundle_input( $requires_input, $product ) { | |
| if ( ! $product->contains( 'mandatory' ) && $product->contains( 'optional' ) ) { | |
| $requires_input = true; | |
| } | |
| return $requires_input; | |
| } |
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_action( 'restrict_manage_posts', 'wc_ninja_create_filter_dropdown' ); | |
| function wc_ninja_create_filter_dropdown(){ | |
| $type = 'product'; | |
| if ( isset( $_GET['post_type'] ) ) { | |
| $type = $_GET['post_type']; | |
| } | |
| if ( 'product' == $type ){ | |
| $values = array( | |
| 'Catalog & search' => 'visible', |
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_filter( 'the_author_posts_link', 'wc_ninja_change_author_url' ); | |
| function wc_ninja_change_author_url($link) { | |
| $username = get_the_author_meta('login'); | |
| return "<a href='http://twitter.com/" . $username . "'>" . get_the_author() . "</a>"; | |
| } |
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_filter( 'woocommerce_sortable_taxonomies','wt_sort_brands' ); | |
| function wt_sort_brands( $sortable ) { | |
| $sortable[] = 'product_brand'; | |
| return $sortable; | |
| } |
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_action( 'woocommerce_single_product_summary', 'wc_ninja_add_brand_to_product_page', 19 ); | |
| function wc_ninja_add_brand_to_product_page() { | |
| echo do_shortcode('[product_brand width="64px" height="64px" class="alignright"]'); | |
| } |
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
| function wc_ninja_role_base_shipping_method( $rates, $package ) { | |
| // Make sure flat rate is available | |
| if ( isset( $rates['flat_rate'] ) && ! current_user_can( 'wholesale' ) ) { | |
| unset($rates['flat_rate']); | |
| } | |
| return $rates; | |
| } | |
| add_filter( 'woocommerce_package_rates', 'wc_ninja_role_base_shipping_method', 10, 2 ); |