Hi. How can we help?

Add Request a quote widget in Storefront theme header

To replace the cart widget with the YITH WooCommerce Request a Quote widget in Storefront theme header, please, follow these steps:

First of all, you have to add this code into the functions.php file of Storefront (better if it is a child):

//Add our custom widget
add_action( 'storefront_header', 'storefront_header_raq', 60 );
if ( ! function_exists( 'storefront_header_raq' ) ) {

function storefront_header_raq() {
if ( storefront_is_woocommerce_activated() ) {
echo do_shortcode( '[yith_ywraq_mini_widget_quote]' );
}
}
}

//set footer link
add_filter( 'storefront_handheld_footer_bar_links', 'set_raq_link_footer' );
if ( ! function_exists( 'set_raq_link_footer' ) ) {

function set_raq_link_footer( $links ) {

unset( $links['cart'] );
$links['raq'] = array(
'priority' => 30,
'callback' => 'storefront_handheld_footer_bar_raq_link',
);

return $links;

}

}

//render footer link
if ( ! function_exists( 'storefront_handheld_footer_bar_raq_link' ) ) {

function storefront_handheld_footer_bar_raq_link() {
?>
<a class="ywraq_number_items_container" href="<?php echo esc_url( YITH_Request_Quote()->get_raq_page_url() ) ?>">
<?php echo do_shortcode( '[yith_ywraq_number_items class="ywraq_number_items" show_url="no" item_name="" item_plural_name=""]' ); ?>
</a>
<?php
}

}

Now, the new widget is visible in the header but you have to adjust its style. So, by adding the following snippet, you can make it look like the cart widget:

//customize style
add_action( 'wp_enqueue_scripts', 'my_yith_wraq_style', 25 );
if ( ! function_exists( 'my_yith_wraq_style' ) ) {
function my_yith_wraq_style() {

$storefront_customizer = new Storefront_Customizer();
$storefront_theme_mods = $storefront_customizer->get_storefront_theme_mods();

$css = '
.widget_ywraq_mini_list_quote {
width: 21.7391304348%;
float: right;
margin: 0 !important;
}

.yith-ywraq-list-widget-wrapper .raq-info {
margin: 0;
padding: 1.618em 0;
border: 0 none;
}

.yith-ywraq-list-widget-wrapper .raq_label{
display:block;
}

.yith-ywraq-list-widget-wrapper .raq_label:after {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
display: inline-block;
font-style: normal;
font-variant: normal;
font-weight: normal;
line-height: 1;
vertical-align: -.125em;
font-family: "Font Awesome 5 Free";
font-weight: 900;
line-height: inherit;
vertical-align: baseline;
content: "\f46d";
height: 1em;
float: right;
line-height: 1.618;
}

.yith-ywraq-list-widget-wrapper .raq-info .handler-label {
float: left;
margin: 0 5px 0 0
}

.yith-ywraq-list-wrapper {
right: 0;
}

@media screen and (max-width:767px){

.widget_ywraq_mini_list_quote{
display:none;
}

}


li.raq .ywraq_number_items_container{
height: 4.235801032em;
display: block;
position: relative;
text-indent: -9999px;
z-index: 999;
border-right: 1px solid rgba(255,255,255,.2);
}

li.raq .ywraq_number_items_container:before{
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
display: inline-block;
font-style: normal;
font-variant: normal;
font-weight: normal;
line-height: 1;
vertical-align: -.125em;
font-family: "Font Awesome 5 Free";
font-weight: 900;
line-height: inherit;
vertical-align: baseline;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
text-align: center;
line-height: 2.618046972;
font-size: 1.618em;
text-indent: 0;
display: block;
cursor: pointer;
content: "\f46d";
}

li.raq .ywraq_number_items_container div{
text-indent: 0;
display: block;
width: 2em;
height: 2em;
line-height: 2;
box-sizing: content-box;
font-size: .75em;
position: absolute;
top: .875em;
left: 50%;
border-radius: 100%;
border: 1px solid;
background-color: ' . $storefront_theme_mods['header_link_color'] . ';
color: ' . $storefront_theme_mods['header_background_color'] . ';
border-color: ' . $storefront_theme_mods['header_background_color'] . ';
}

';
wp_add_inline_style( 'yith_ywraq_frontend', $css );

}
}

Finally, remove the cart widget, with this snippet:

//remove cart widget
remove_action( 'storefront_header', 'storefront_header_cart', 60 );
Was this article helpful?
0 out of 0 found this helpful

Back to Help Center >

Powered by Zendesk