Skip to content
PHP

How To Customize the Store Front Theme In HTML

A
Author
Dec 21, 2022 · 18 min read
How To Customize the Store Front Theme In HTML
<?php
/**

Storefront WooCommerce hooks
*

@package storefront
*/

/**

Homepage
*

@see storefront_product_categories()

@see storefront_recent_products()

@see storefront_featured_products()

@see storefront_popular_products()

@see storefront_on_sale_products()

@see storefront_best_selling_products()
*/
add_action( 'homepage', 'storefront_product_categories', 20 );
add_action( 'homepage', 'storefront_recent_products', 30 );
add_action( 'homepage', 'storefront_featured_products', 40 );
add_action( 'homepage', 'storefront_popular_products', 50 );
add_action( 'homepage', 'storefront_on_sale_products', 60 );
add_action( 'homepage', 'storefront_best_selling_products', 70 );

/**

Layout
*

@see storefront_before_content()

@see storefront_after_content()

@see woocommerce_breadcrumb()

@see storefront_shop_messages()
*/
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
//remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
add_action( 'woocommerce_before_main_content', 'storefront_before_content', 10 );
add_action( 'woocommerce_after_main_content', 'storefront_after_content', 10 );
add_action( 'storefront_content_top', 'storefront_shop_messages', 15 );
add_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10 );

add_action( 'woocommerce_after_shop_loop', 'storefront_sorting_wrapper', 9 );
//add_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
//add_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 );
add_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 );
add_action( 'woocommerce_after_shop_loop', 'storefront_sorting_wrapper_close', 31 );

add_action( 'woocommerce_before_shop_loop', 'storefront_sorting_wrapper', 9 );
//add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
//add_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
//add_action( 'woocommerce_before_shop_loop', 'storefront_woocommerce_pagination', 30 );
add_action( 'woocommerce_before_shop_loop', 'storefront_sorting_wrapper_close', 31 );

add_action( 'storefront_footer', 'storefront_handheld_footer_bar', 999 );

// Legacy WooCommerce columns filter.
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.3', '<' ) ) {
add_filter( 'loop_shop_columns', 'storefront_loop_columns' );
add_action( 'woocommerce_before_shop_loop', 'storefront_product_columns_wrapper', 40 );
add_action( 'woocommerce_after_shop_loop', 'storefront_product_columns_wrapper_close', 40 );
}

/**

Products
*

@see storefront_edit_post_link()

@see storefront_upsell_display()

@see storefront_single_product_pagination()

@see storefront_sticky_single_add_to_cart()
*/
add_action( 'woocommerce_single_product_summary', 'storefront_edit_post_link', 60 );

remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary', 'storefront_upsell_display', 15 );

//remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 6 );

add_action( 'woocommerce_after_single_product_summary', 'storefront_single_product_pagination', 30 );
add_action( 'storefront_after_footer', 'storefront_sticky_single_add_to_cart', 999 );

/**

Header
*

@see storefront_product_search()

@see storefront_header_cart()
*/
add_action( 'storefront_header', 'storefront_product_search', 40 );
add_action( 'storefront_header', 'storefront_header_cart', 60 );

/**

Cart fragment
*

@see storefront_cart_link_fragment()
*/
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '2.3', '>=' ) ) {
add_filter( 'woocommerce_add_to_cart_fragments', 'storefront_cart_link_fragment' );
} else {
add_filter( 'add_to_cart_fragments', 'storefront_cart_link_fragment' );
}

/**

Integrations
*

@see storefront_woocommerce_brands_archive()

@see storefront_woocommerce_brands_single()

@see storefront_woocommerce_brands_homepage_section()
*/
if ( class_exists( 'WC_Brands' ) ) {
add_action( 'woocommerce_archive_description', 'storefront_woocommerce_brands_archive', 5 );
add_action( 'woocommerce_single_product_summary', 'storefront_woocommerce_brands_single', 4 );
add_action( 'homepage', 'storefront_woocommerce_brands_homepage_section', 80 );
}

// breadcrumb
add_filter( 'woocommerce_breadcrumb_defaults', 'ts_woocommerce_breadcrumbs_change' );

function ts_woocommerce_breadcrumbs_change() {
return array(
'wrap_before' => '

',
'before' => '', 'after' => '',
'home' => _x( 'Home', ' ' ,'breadcrumb', 'woocommerce' ),
);
}

//Shop Hook

remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_pricee', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 10 );
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cartt', 10 );
add_action( 'woocommerce_after_shop_loop_item', 'closeMyDiv', 20 );

remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10);
add_action( 'woocommerce_before_shop_loop_item','bellini_before_woo_product_archive_item_one',1 );
function bellini_before_woo_product_archive_item_one() {
?>

<?php
}

add_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_thumbnail', 10);
if ( ! function_exists( 'woocommerce_template_loop_product_thumbnail' ) ) {
function woocommerce_template_loop_product_thumbnail() {
echo woocommerce_get_product_thumbnail();
}
}
if ( ! function_exists( 'woocommerce_get_product_thumbnail' ) ) {
function woocommerce_get_product_thumbnail( /$size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0/ ) {
global $post; global $product,$woocommerce ;
$output .= '';
if (has_post_thumbnail() ) {
$output .= '

        }

        return $output;
}

}
function closeMyDiv(){ echo '';

}

// Price *
/add_filter( 'woocommerce_variable_sale_price_html', 'woocommerce_template_loop_pricee', 10, 2 ); add_filter( 'woocommerce_variable_price_html', 'woocommerce_template_loop_pricee', 10, 2 ); add_filter( 'woocommerce_get_price_html', 'woocommerce_template_loop_pricee', 10, 2 );/

function woocommerce_template_loop_pricee() {
global $post; global $product,$woocommerce ;

    $regular_price=$product->get_regular_price();
    $sale_price=$product->get_sale_price();
    $price.='<div class="prize__text">';
    /*if( $product->is_on_sale() ) {
        $get_sale_price=$product->get_sale_price();
        $price.='<span class="orange_text"><i class="fas fa-rupee-sign"></i> '.$get_sale_price.'</span>';
    }
    $price.='<span class="line-throgh"><i class="fas fa-rupee-sign"></i>'.$product->get_regular_price().'</span>';*/

     $_reg_price = floatval( strip_tags($regular_price) );
$_sale_price = floatval( strip_tags($sale_price) );

// Percentage calculation and text
$percentage = round( ( $_reg_price - $_sale_price ) / $_reg_price * 100 ).'%';
$percentage_txt = ' ' . __(' Save ', 'woocommerce' ) . $percentage;

$formatted_regular_price = is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price;
$formatted_sale_price    = is_numeric( $sale_price )    ? wc_price( $sale_price )    : $sale_price;

    $price.='<span class="line-throgh p-1"><i classs="fas fa-rupee-signn"></i>' . $formatted_regular_price . '</span> <span class="orange_text"><i classs="fas fa-rupee-signn"></i>' . $formatted_sale_price .  '</span> <span class="blink-text">'.$percentage_txt .'</span>';

    $price.='</div>';
    $price.='<div class="row"><div class="col-9 add_cartmain">';
    echo  $price;

}
add_action( 'wp', 'thecreativecoders_remove_storefront_actions' );

function thecreativecoders_remove_storefront_actions() {
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 6 );
}
// Loop Product Add To Cart *
function woocommerce_template_loop_add_to_cartt(){
global $post; global $product,$woocommerce,$args ;
//Add to Cart
//
echo ''.woocommerce_template_loop_add_to_cart().''.do_shortcode("[yith_wcwl_add_to_wishlist]").'';
}

// Loop Product Title *
remove_action( 'woocommerce_shop_loop_item_title','woocommerce_template_loop_product_title', 10 );
add_action('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
function woocommerce_template_loop_product_title() {
//echo '

' . get_the_title() . '';
//echo '

' . get_the_title() . '';
// echo '

' . get_the_title() . '

//

' .get_the_excerpt() . '';
echo '

' . substr(get_the_title(),0,90) . '…';
}
add_filter( 'woocommerce_show_page_title', 'yash_hide_shop_page_title' );

function yash_hide_shop_page_title( $title ) {
// if ( is_shop() )
$title = false;
return $title;
}

remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
add_action( 'woocommerce_before_single_product', 'wc_print_notices', 10 );

add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );

add_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );

add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );

// function woocommerce_template_single_add_to_cart() generates the following 4 actions
add_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );
add_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
add_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
add_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );

add_action( 'woocommerce_single_variation', 'woocommerce_single_variation', 10 );
add_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );

add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
// //* Single Page *
// remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );

// //attach my open 'section' function to the before product summary action
// /*add_action( 'woocommerce_before_single_product_summary', 'my_non_image_content_wrapper_start', 20 );

// //This function opens a new css section tag called "no-image-wrap" to the page HTML before all of the woocommerce "stuff" except images
// function my_non_image_content_wrapper_start() {
// echo '';

// }*/

// add_filter( 'woocommerce_single_product_image_gallery_classes', 'filter_woocommerce_single_product_image_gallery_classes', 10, 1 );
// function filter_woocommerce_single_product_image_gallery_classes( $array ) {
// // make filter magic happen here…
// $array[]='col-md-5';
// return $array;
// };

// //add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 20 );
// remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
// add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
// function woocommerce_output_related_products(){
// //woocommerce_output_product_data_tabs();
// global $product; //
// if( ! is_a( $product, 'WC_Product' ) ){
// $product = wc_get_product(get_the_id());
// }

// $args = array(
// 'posts_per_page' => 4,
// 'columns' => 4,
// 'orderby' => 'rand',
// 'order' => 'desc',
// );

// $args['related_products'] = array_filter( array_map( 'wc_get_product', wc_get_related_products( $product->get_id(), $args['posts_per_page'], $product->get_upsell_ids() ) ), 'wc_products_array_filter_visible' );
// $args['related_products'] = wc_products_array_orderby( $args['related_products'], $args['orderby'], $args['order'] );

// // Set global loop values.
// wc_set_loop_prop( 'name', 'related' );
// wc_set_loop_prop( 'columns', $args['columns'] );

// wc_get_template( 'single-product/related.php', $args );

// }

add_filter('woocommerce_checkout_fields', 'addBootstrapToCheckoutFields' );
function addBootstrapToCheckoutFields($fields) {
foreach ($fields as &$fieldset) {
foreach ($fieldset as &$field) {
// if you want to add the form-group class around the label and the input
$field['class'][] = 'form-group';

        // add form-control to the actual input
        $field['input_class'][] = 'form-control';
    }
}
return $fields;

}

//* Cart Page**
add_filter( 'woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment' );

function woocommerce_header_add_to_cart_fragment( $fragments ) {
ob_start();
?>
cart->cart_contents_count ; ?>

<?php

$fragments['sup.cartcnt'] = ob_get_clean();

return $fragments;

}
add_filter( 'woocommerce_order_item_class', 'additional_class_to_order_item_classes', 10, 3 );
function additional_class_to_order_item_classes ( $class, $item, $order ) {
if ( $item->get_meta('_wc_pao_addon_name') ) {
$class .= ' fl-addon-item';
}
return $class;
}

//

add_filter('woocommerce_checkout_fields' , 'custom_override_checkout_fields');
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_first_name']);
unset($fields['shipping']['shipping_first_name']);
unset($fields['billing']['billing_last_name']);
unset($fields['shipping']['shipping_last_name']);
unset($fields['billing']['billing_email']);
unset($fields['shipping']['shipping_email']);
unset($fields['billing']['billing_phone']);
unset($fields['shipping']['shipping_phone']);
unset($fields['billing']['billing_address_1']);
unset($fields['shipping']['shipping_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['shipping']['shipping_address_2']);
unset($fields['billing']['billing_company']);
unset($fields['shipping']['shipping_company']);
unset($fields['billing']['billing_postcode']);
unset($fields['shipping']['shipping_postcode']);
unset($fields['billing']['billing_country']);
unset($fields['shipping']['shipping_country']);
unset($fields['billing']['billing_city']);
unset($fields['shipping']['shipping_city']);
unset($fields['billing']['billing_state']);
unset($fields['shipping']['shipping_state']);
unset($fields['order']['order_comments']);

    //ADD PHONE AND EMAIL IN SHIPPING CHECKUOUT PAGE AND OREDER EDIT

    $fields['billing']['billing_phone'] = array(
        'label'     => __('Phone', 'woocommerce'),
        'input_class'=>array('form-control'),
        'placeholder'   => _x('Phone', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        );          
    $fields['billing']['billing_city'] = array(
        'label'     => __('City', 'woocommerce'),
        'input_class'=>array('form-control'),
        'placeholder'   => _x('City', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        );  
    $fields['billing']['billing_state'] = array(
        'label'     => __('State', 'woocommerce'),
         //'type' => 'state',
        'input_class'=>array('form-control'),
        'placeholder'   => _x('State', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6 '),
        'clear'     => true
        );     
    $fields['billing']['billing_postcode'] = array(
        'label'     => __('Post Code', 'woocommerce'),
        'input_class'=>array('form-control'),
        'placeholder'   => _x('Post Code', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        ); 
    $fields['billing']['billing_address_1'] = array(
        'label'     => __('Adress', 'woocommerce'),
        'input_class'=>array('form-control'),
        'placeholder'   => _x('Adress', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        ); 
    $fields['billing']['billing_country'] = array(
        'label'     => __('Country', 'woocommerce'),
        'type' => 'country',
        'input_class'=>array('country_to_state form-control'),
       // 'input_class'=>array('country_to_state country_select form-control'),
        'placeholder'   => _x('Country', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        );      
     $fields['billing']['billing_first_name'] = array(
        'input_class'=>array('form-control'),
        'placeholder'   => _x('First Name', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        );
     $fields['billing']['billing_last_name'] = array(
        'input_class'=>array('form-control'),
        'placeholder'   => _x('Last Name', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        ); 
     $fields['billing']['billing_company'] = array(
        'label'     => __('Company', 'woocommerce'),
        'input_class'=>array('form-control'),
        'placeholder'   => _x('Company', 'placeholder', 'woocommerce'),
        'required'  => false,
        'class'     => array('col-md-6'),
        'clear'     => true
        );  
    $fields['billing']['billing_email'] = array(
        'label'     => __('Email', 'woocommerce'),
        'input_class'=>array('form-control'),
        'placeholder'   => _x('Email', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        );          

     /*echo "<pre>";
    print_r($fields);
    die;*/
    //Shipping

    $fields['shipping']['shipping_postcode'] = array(
        'label'     => __('Post Code', 'woocommerce'),
        'input_class'=>array(' form-control'),
        'placeholder'   => _x('Post Code', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        ); 
    $fields['shipping']['shipping_city'] = array(
        'label'     => __('City', 'woocommerce'),
        'input_class'=>array(' form-control'),
        'placeholder'   => _x('City', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        );
    $fields['shipping']['shipping_state'] = array(
        'label'     => __('State', 'woocommerce'),
        'input_class'=>array(' form-control'),
        'placeholder'   => _x('State', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        );
    $fields['shipping']['shipping_address_1'] = array(
        'label'     => __('Adress', 'woocommerce'),
        'input_class'=>array(' form-control'),
        'placeholder'   => _x('Adress', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        );  
    $fields['shipping']['shipping_country'] = array(
        'type' => 'country',
        'label'     => __('Country', 'woocommerce'),
        'input_class'=>array('country_to_state form-control'),
        'placeholder'   => _x('Country', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        ); 
    $fields['shipping']['shipping_first_name'] = array(
        'label'     => __('First Name', 'woocommerce'),
        'input_class'=>array(' form-control'),
        'placeholder'   => _x('First Name', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        ); 
    $fields['shipping']['shipping_last_name'] = array(
        'input_class'=>array(' form-control'),
        'placeholder'   => _x('Last Name', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('col-md-6'),
        'clear'     => true
        ); 
    $fields['shipping']['shipping_company'] = array(
        'label'     => __('Company', 'woocommerce'),
        'input_class'=>array('form-control'),
        'placeholder'   => _x('Company', 'placeholder', 'woocommerce'),
        'required'  => false,
        'class'     => array('col-md-6'),
        'clear'     => true
        );  
    $fields['order']['order_comments'] = array(
        'input_class'=>array('form-control'),
        'placeholder'   => _x('Notes', 'placeholder', 'woocommerce'),
        'required'  => false,
        'class'     => array('col-md-12'),
        'clear'     => true
        ); 

    return $fields;
}

/* function show_ship_add_for_local_pickup( $needs_address, $hide ) {
print_r($needs_address);
print_r($needs_address);
echo $needs_address = true;

die;
return $needs_address;

}
add_filter( 'woocommerce_order_needs_shipping_address', 'show_ship_add_for_local_pickup', 10, 2 );*/

add_filter('woocommerce_after_checkout_pickup', 'custom_checkout_field_pickup');
function custom_checkout_field_pickup($checkout){
    echo '<div id="woocommerce-billing-fields__field-wrapper" class="row"><h4>&nbsp;</h4>';
    woocommerce_form_field( 'height_type',
        array(
            'type'=> 'select',
            //'class' => array('form-row form-row-first validate-required'),
            'class' => array('form-row form-row-first'),
            'label'=> __('Height Type'),
            //'required'=>'true',
            'options'=> array('' => __('Select*', 'woocommerce' ),'Millimeters' => __('Millimeters', 'woocommerce' ),'Centimeters' => __('Centimeters', 'woocommerce' ),'Meters' => __('Meters', 'woocommerce' ),'Inches' => __('Inches', 'woocommerce' ),'Feet' => __('Feet', 'woocommerce' ))
            )
        );
    woocommerce_form_field('height', 
        array(
            'type' => 'text',
            'class' => array('form-row form-row-last '),
            'label' => __('Height') ,
            'placeholder' => __('Height *')
           // 'required'=>'true'
            )); 
             echo '</div>';           
     echo '<div id="" class="row">';   
    woocommerce_form_field( 'width_type', 
        array(
            'type'=> 'select',
            'class' => array('form-row form-row-first'),
            'label'=> __('Width Type'),
           // 'required'=>'true',
            'options'=> array('' => __('Select*', 'woocommerce' ),'Millimeters' => __('Millimeters', 'woocommerce' ),'Centimeters' => __('Centimeters', 'woocommerce' ),'Meters' => __('Meters', 'woocommerce' ),'Inches' => __('Inches', 'woocommerce' ),'Feet' => __('Feet', 'woocommerce' ))
            ));
    woocommerce_form_field('width', 
        array(
            'type' => 'text',
            'class' => array('form-row form-row-last '),
            'label' => __('Width') ,
            'placeholder' => __('Width *')
            //'required'=>'true'
            ));
     echo '</div>';        
}

add_filter('woocommerce_after_checkout_shipping', 'custom_checkout_field');
function custom_checkout_field($checkout){
echo '<div id="woocommerce-billing-fields__field-wrapper"  class="row"><h4>&nbsp;</h4>';
    woocommerce_form_field( 'depth_type', 
        array(
            'type'=> 'select',
            'class' => array('form-row form-row-first '),
            'label'=> __('Depth Type'),
            //'required'=>'true',
            'options'=> array('' => __('Select*', 'woocommerce' ),'Millimeters' => __('Millimeters', 'woocommerce' ),'Centimeters' => __('Centimeters', 'woocommerce' ),'Meters' => __('Meters', 'woocommerce' ),'Inches' => __('Inches', 'woocommerce' ),'Feet' => __('Feet', 'woocommerce' ))
            )/*, 
        $checkout->get_value( 'depth_type' )*/);
    woocommerce_form_field('depth', 
        array(
            'type' => 'text',
            'class' => array('form-row form-row-last '),
            'label' => __('Depth') ,
            'placeholder' => __('Depth *')
            //'required'=>'true'
            )/*,
        $checkout->get_value('depth')*/); 
     echo '</div>';           
     echo '<div id="" class="row">';      
    woocommerce_form_field( 'weight_type', 
        array(
            'type'=> 'select',
            'class' => array('form-row form-row-first '),
            'label'=> __('Weight Type'),
            //'required'=>'true',
            'options'=> array('' => __('Select*', 'woocommerce' ),'Grams' => __('Grams', 'woocommerce' ),'Kilograms' => __('Kilograms', 'woocommerce' ),'Quintals' => __('Quintals', 'woocommerce' ),'Tonnes' => __('Tonnes', 'woocommerce' ),'Ounces' => __('Ounces', 'woocommerce' ),'Pounds' => __('Pounds', 'woocommerce' ))
            )/*, 
        $checkout->get_value( 'weight_type' )*/);
    woocommerce_form_field('weight', 
        array(
            'type' => 'text',
            'class' => array('form-row form-row-last '),
            'label' => __('Weight') ,
            'placeholder' => __('Weight *')
           // 'required'=>'true'
            )/*,
        $checkout->get_value('weight')*/); 
    echo '</div>';
} 

add_filter('woocommerce_after_checkout_billing', 'custom_checkout_field2');
function custom_checkout_field2($checkout){
    session_start();
    //print_r($_SESSION);
echo '<div id="woocommerce-billing-fields__field-wrapper row"><h3>' . __('Couriers Info') . '</h3>';
    woocommerce_form_field('time', 
    array(
            'type' => 'text',
            'class' => array('form-row form-row-first validate-required'),
            'label' => __('Time') ,'placeholder' => __('Time *'),
            'required'=>'true',
            'custom_attributes' => array('readonly'=>'readonly'),
            'default'=>$_SESSION["time"]
        )/*,
    $checkout->get_value('time')*/
    );

    woocommerce_form_field('distance', 
        array(
            'type' => 'text',
            'class' => array('form-row form-row-last validate-required'),
            'label' => __('Distance') ,
            'placeholder' => __('Distance *'),
            'required'=>'true',
            'custom_attributes' => array('readonly'=>'readonly'),
            'default'=>$_SESSION["distance"]
            )/*,
        $checkout->get_value('distance')*/);
    woocommerce_form_field('pickupaddress',
        array(
            'type' => 'text',
            'class' => array('form-row form-row-first validate-required'),
            'label' => __('Pickup Address') ,
            'placeholder' => __('Pickup Address*'),
            'required'=>'true',
            'custom_attributes' => array('readonly'=>'readonly'),
            'default'=>$_SESSION["pickupadress"]
            )/*,
        $checkout->get_value('pickupaddress')*/);
    woocommerce_form_field('destinationaddress', 
        array(
            'type' => 'text',
            'class' => array('form-row form-row-last validate-required'),
            'label' => __('Destination Address') ,
            'placeholder' => __('Destination Address *'),
            'required'=>'true',
            'custom_attributes' => array('readonly'=>'readonly'),
            'default'=>$_SESSION["destinationaddress"]
            )/*,
        $checkout->get_value('destinationaddress')*/); 
    echo '</div>';
}

//remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
//remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );

add_filter( 'woocommerce_format_sale_price', 'woocommerce_custom_sales_price', 10, 3 );
function woocommerce_custom_sales_price( $price, $regular_price, $sale_price ) {
// Getting the clean numeric prices (without html and currency)
$_reg_price = floatval( strip_tags($regular_price) );
$_sale_price = floatval( strip_tags($sale_price) );

// Percentage calculation and text
$percentage = round( ( $_reg_price - $_sale_price ) / $_reg_price * 100 ).'%';
$percentage_txt = ' ' . __(' Save ', 'woocommerce' ) . $percentage;

$formatted_regular_price = is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price;
$formatted_sale_price    = is_numeric( $sale_price )    ? wc_price( $sale_price )    : $sale_price;

echo '<del class="price_line">' . $formatted_regular_price . '</del>'.$formatted_sale_price.' <ins class="blink-text">' . $percentage_txt . '</ins>';

}

add_action('woocommerce_checkout_shipping', 'ts_checkout_shipping');
function ts_checkout_shipping() {
}

add_action( 'template_redirect', 'woo_custom_redirect_after_purchase' );
function woo_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && !empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( 'https://bionfit.com/woocommerce/thank-you/' );
exit;
}
}

/**

@snippet Remove "Default Sorting" Dropdown @ StoreFront Shop & Archive Pages



*/

add_action( 'init', 'thecreativecoders_remove_default_sorting_storefront' );

function thecreativecoders_remove_default_sorting_storefront() {
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
}

A
Author

Author at The Creative Coders.

The monthly build log

One email a month. New posts, lessons, and the occasional strong opinion. No spam.