Home › Forums › WoodMart support forum › The Product labels not showing
The Product labels not showing
- This topic has 9 replies, 2 voices, and was last updated 1 year, 2 months ago by
Aizaz Imtiaz Awan.
-
AuthorPosts
-
December 7, 2023 at 1:47 am #519253
justinavctParticipantExample product link:
Is it possible to make the “new” label show on the category page? Thanks.
Attachments:
You must be logged in to view attached files.December 7, 2023 at 2:17 pm #519453
Aizaz Imtiaz AwanKeymasterHello,
Sorro to say your given url is not working. Please share the wp login details i will check and give you a possible solution.
Best Regards.
December 8, 2023 at 5:32 am #519601
justinavctParticipantHere is the login details
December 8, 2023 at 2:34 pm #519777
Aizaz Imtiaz AwanKeymasterHello,
There is an issue with the 3rd party plugins. Please deactivate all the 3rd party plugins and activate only theme-required plugins on the site and then check the issue. I am sure your issue will be solved. Then Activate the 3rd party plugins one by one and check which plugin is creating the issue for you.
Otherwise, if the issue still exists then keep the 3rd party plugins deactivated and let me know so I will check and give you a possible solution.
Best Regards.
December 11, 2023 at 8:14 am #520220
justinavctParticipantI have deactivated the plugin one by one it seems not working.
December 11, 2023 at 4:56 pm #520498
Aizaz Imtiaz AwanKeymasterHello,
Please confirm the permission for plugins deactivation, and switch to the parent theme. As soon as we complete the testing of this plugin we will enable it all back, You would better make the full backup of your site.
Best Regards.
December 12, 2023 at 2:42 am #520658
justinavctParticipantSure, I can give you the permission, I already backup the site
December 12, 2023 at 3:28 pm #520891
Aizaz Imtiaz AwanKeymasterHello,
Your issue has been resolved. It is an issue with your child theme. After activating the parent the label is showing fine.
Here is the product link:
https://rantingj11.sg-host.com/product/test/Best Regards.
December 15, 2023 at 4:53 am #521805
justinavctParticipantHi,
Thanks for that, but after activating the parent theme, some of the functions.PHP code is not working for the Parent theme.
It will show this information after I copy and paste the code from the Child theme to the parent theme:
Fatal error: Cannot redeclare woodmart_child_enqueue_styles() (previously declared in /home/customer/www/rantingj11.sg-host.com/public_html/wp-content/themes/woodmart-child/functions.php:6) in /home/customer/www/rantingj11.sg-host.com/public_html/wp-content/themes/woodmart/functions.php on line 76
There has been a critical error on this website.”Can you help to add a conditional statement of the PHP code? Here is the code that I had added to the child theme before:
<?php
/**
* Enqueue script and styles for child theme
*/
function woodmart_child_enqueue_styles() {
wp_enqueue_style( ‘child-style’, get_stylesheet_directory_uri() . ‘/style.css’, array( ‘woodmart-style’ ), woodmart_get_theme_info( ‘Version’ ) );
}
add_action( ‘wp_enqueue_scripts’, ‘woodmart_child_enqueue_styles’, 10010 );// function get_variation_id_by_slug($product_id, $variation_slug) {
// $product = wc_get_product($product_id);// if ($product) {
// $variations = $product->get_available_variations();
// // print_r($variations);// foreach ($variations as $variation) {
// if ($variation[‘attributes’][‘attribute_pa_cabinet-options’] === $variation_slug) {
// return $variation[‘variation_id’];
// }
// }
// }// return 0; // Return 0 if variation not found
// }// function get_stock_status() {
// $variation_slug = $_POST[‘variation_id’];
// $product_id = $_POST[‘product_id’];
// $variation_id = get_variation_id_by_slug($product_id, $variation_slug);
// $variation = wc_get_product($variation_id);// $stock_quantity = $variation->get_stock_quantity();
// if ($stock_quantity === 0) {
// echo ‘outofstock’;
// } elseif ($stock_quantity <= 10) {
// echo ‘lowstock’;
// } else {
// echo ‘instock’;
// }// die();
// }// add_action(‘wp_ajax_get_stock_status’, ‘get_stock_status’);
// add_action(‘wp_ajax_nopriv_get_stock_status’, ‘get_stock_status’);// * archive page stock label
function woocommerce_stock_status_archive_loop()
{
global $product;if ($product->is_type(‘simple’)) {
if (!$product->is_in_stock()) {
echo ‘<div class=”product-labels labels-rounded new”><span class=”out-of-stock product-label”>Out of Stock</span></div>’;
} elseif ($product->is_in_stock() && $product->get_stock_quantity() < 10) {
echo ‘<div class=”product-labels labels-rounded new”><span class=”out-of-stock product-label”>Low Stock</span></div>’;
} else if ($product->is_in_stock() && $product->get_stock_quantity() >= 10) {
echo ‘<div class=”product-labels labels-rounded new”><span class=”out-of-stock product-label”>In Stock</span></div>’;
}
}
}// Add stock status to archive pages
// add_action( ‘woocommerce_before_shop_loop_item’, ‘woocommerce_stock_status_archive_loop’, 10 );// * single product page
function woocommerce_stock_status_single()
{
global $product;
if ($product->is_type(‘simple’)) {
if (!$product->is_in_stock()) {
echo ‘<div class=”stock red”>Out of Stock</div>’;
} elseif ($product->is_in_stock() && $product->get_stock_quantity() < 10) {
echo ‘<div class=”stock orange”>Low Stock</div>’;
} else if ($product->is_in_stock() && $product->get_stock_quantity() >= 10) {
echo ‘<div class=”stock orange”>In Stock</div>’;
}
}
}// Add stock status to single pages
add_action( ‘woocommerce_product_meta_start’, ‘woocommerce_stock_status_single’, 10 );// * stock label
add_action( ‘woocommerce_before_single_variation’, ‘variation_info’ );
function variation_info() {
global $product;
if ( ! $product->is_type( ‘variable’ ) ) return;
echo ‘<div class=”var_info stock”></div>’;
wc_enqueue_js( ”
$(document).on(‘found_variation’, ‘form.cart’, function( event, variation ) {
$(‘.var_info’).addClass(‘show’);
$(‘.var_info’).removeClass(‘hide’);
if(variation.max_qty >= 10){
$(‘.var_info’).html(‘In Stock’);
$(‘.var_info’).addClass(‘in-stock’);
$(‘.var_info’).removeClass(‘low-stock’);
$(‘.var_info’).removeClass(‘out-of-stock’);
}
else if(variation.max_qty < 10 && variation.max_qty > 1 ){
$(‘.var_info’).html(‘Low Stock’);
$(‘.var_info’).removeClass(‘in-stock’);
$(‘.var_info’).addClass(‘low-stock’);
$(‘.var_info’).removeClass(‘out-of-stock’);
}else if(variation.max_qty < 1 ){
$(‘.var_info’).html(‘Out Of Stock’);
$(‘.var_info’).removeClass(‘in-stock’);
$(‘.var_info’).removeClass(‘low-stock’);
$(‘.var_info’).addClass(‘out-of-stock’);
}
});
” );
}function wooc_extra_register_fields() {?>
<p class=”form-row form-row-wide”>
<label for=”reg_billing_phone”><?php _e( ‘Phone’, ‘woocommerce’ ); ?></label>
<input type=”text” class=”input-text” name=”billing_phone” id=”reg_billing_phone” value=”<?php esc_attr_e( $_POST[‘billing_phone’] ); ?>” />
</p>
<p class=”form-row form-row-wide”>
<label for=”reg_billing_business_name”><?php _e( ‘Business name’, ‘woocommerce’ ); ?><span class=”required”>*</span></label>
<input type=”text” class=”input-text” name=”billing_business_name” id=”reg_billing_business_name” value=”<?php if ( ! empty( $_POST[‘billing_business_name’] ) ) esc_attr_e( $_POST[‘billing_business_name’] ); ?>” />
</p>
<div class=”clear”></div>
<?php
}
add_action( ‘woocommerce_register_form_start’, ‘wooc_extra_register_fields’ );
December 15, 2023 at 1:22 pm #521946
Aizaz Imtiaz AwanKeymasterHello,
I regret to inform you that I’m unable to assist with code customizations beyond the scope of our limitations and support policy. Any modifications made to the theme files are undertaken at your own risk, and our support does not extend to addressing issues arising from changes in the theme code.
Thank you for your comprehension.
Best Regards.
-
AuthorPosts
- You must be logged in to create new topics. Login / Register