This topic has 6 replies, 2 voices, and was last updated 1 years, 1 months ago ago by Rose Tyler
current page looks like this
https://ibb.co/ftFmsVt
there is an option to add stock quantity
https://ibb.co/BLRwJwy
but it looks like this
https://ibb.co/x1R63Xp
how can I edit this to make it look better? I would like the simple In Stock or Available on Backorder instead.
https://ibb.co/2q0PX9b
Thanks in advance!
Hello, PAC,
Thank you for contacting us and for using XStore.
Please provide URL of page and temporary wp-admin access, so we can take a closer look.
To provide wp-admin access, you can create a new user account with administrator role via the Dashboard, and provide us with the username and password via the Private Content area.
Kind Regards,
8theme team
sent
Hello, PAC,
We regret to inform you that the option you are inquiring about is not available by default. However, we are pleased to provide you with a custom code solution that can be implemented to achieve the desired functionality.
Please insert the following code into the xstore-child/functions.php file using an FTP client:
Result – https://prnt.sc/2LUrQIpJOlfg
add_filter('etheme_product_grid_list_product_elements', 'etheme_child_product_grid_list_product_and_hover_elements_filter');
add_filter('etheme_product_grid_list_product_hover_elements', 'etheme_child_product_grid_list_product_and_hover_elements_filter');
function etheme_child_product_grid_list_product_and_hover_elements_filter($elements) {
if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) {
$excerpt_position = array_search('excerpt', array_keys($elements));
if ( $excerpt_position > 1 ) {
$elements = array_slice( $elements, 0, $excerpt_position, true ) +
array( 'stock_status' => esc_html__( 'Show Stock Status', 'xstore' ) ) +
array_slice( $elements, $excerpt_position, count( $elements ) - $excerpt_position, true );
}
else {
$elements['stock_status'] = esc_html__( 'Show Stock Status', 'xstore' );
}
}
return $elements;
}
add_filter('etheme_product_grid_list_product_hover_info_elements', function ($elements) {
$elements[] = 'stock_status';
return $elements;
});
add_action( 'etheme_product_grid_list_product_element_render', 'etheme_child_product_grid_list_product_and_hover_element_render', 10, 4 );
add_action( 'etheme_product_grid_list_product_hover_element_render', 'etheme_child_product_grid_list_product_and_hover_element_render', 10, 4 );
function etheme_child_product_grid_list_product_and_hover_element_render($key, $product, $edit_mode, $main_class) {
switch ($key) {
case 'stock_status':
echo wc_get_stock_html($product);
break;
}
}
add_filter('etheme_product_grid_list_product_hover_info_elements_render', function ($info_elements, $hover_effect, $all_elements) {
if ( in_array($hover_effect, array('info', 'overlay', 'default')) ) {
if ( array_key_exists('stock_status', $all_elements) ) {
$info_elements['stock_status'] = $all_elements['stock_status'];
}
}
return $info_elements;
}, 10, 3);
add_filter('etheme_product_grid_list_product_hover_elements_render', function ($elements, $hover_effect, $info_elements) {
if ( in_array($hover_effect, array('info', 'overlay', 'default')) ) {
if ( array_key_exists('stock_status', $elements) ) {
unset($elements['stock_status']);
}
}
return $elements;
}, 10, 3);
Kind Regards,
8theme team
Amazing work! Thank you all!
Hello, PAC,
You’re welcome!
Kind Regards,
8theme team
The issue related to '‘edit product list widget or add custom stock status’' has been successfully resolved, and the topic is now closed for further responses