Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • This kind of issue usually a plugin conflict issue.

    You can try to deactivate all plugins except WooCommerce, and then test it again.

    If it doesn’t work, you can try to re-install WooCommerce plugin, just in case your WooCommerce installation is corrupt.

    I don’t know what happens with your website. Needs to be checked why it gives you different results every time. Something should be happens in your website. First check, you can go to WooCommerce – System Status to see if there is any warning message there that need your attention.

    If you want same 4 products all the time, it is better to add it manually using product IDs. It can be achieved with something like this:

    Featured Products
    
    [products ids="1,2,3,4" columns="4"]
    
    Top Sellers
    
    [products ids="5,6,7,8" columns="4"]

    You can changes ids parameter with your product IDs, separated by comma.

    you need to remember the differences between your price input and your “displayed” price.

    when adding/editing price in your product, do not use thousand separator and always use point for decimal separator. this is the safest way to do.

    for example: 2500.50

    this is the format that is used for your database.

    if you need comma for your decimal separator, this can be configured from WooCommerce – Settings – General page. This setting will be used to format your “displayed” price using wc_price function. You can changed the format anytime when you need it.

    So, 2500.50 (in database) = 2.500,50 (displayed) or 2,500.50 (displayed), depends on your settings

    Note: I tried to put 2500,50 when editing my product and later version of WooCommerce looks convert it to 2500.50, which is good.

    From your experience, it is clearly to see that option 2) is better for you because it is designed for WooCommerce only.

    The full idea of adding all labels is, you can change not only the menu name but also all related labels to make it consistent. You only need to change all “Product Categories” and “Product Category” to your custom name. But, if you only need to change the menu label, then I simplify it for you.

    add_filter( 'woocommerce_taxonomy_args_product_cat', 'custom_wc_taxonomy_label_product_cat' );
    function custom_wc_taxonomy_label_product_cat( $args ) {
    	$args['label'] = 'My Categories';
    	$args['labels'] = array(
            'name' => 'My Categories',
            'singular_name' => 'My Categories',
            'menu_name' => 'My Categories'
    	);
    
    	return $args;
    }

    @pocket Flan,

    I see two points in your code above.

    1) the code above works only when WooCommerce is active when product_cat taxonomy is active. When you update your WooCommerce, the plugin will be deactivated by WordPress for updating purpose, and this code will trigger an error/warning.

    2) The specific error that you get above comes from PHP5.4. If you use shared hosting, it could be your hosting update PHP version in the server and then produce this error. Please do check with your hosting.

    I second Mike that the code is not “perfect” in this situation and it is not related with WooCommerce. There are two ways to solve it.

    1) you can update your code and check if product_cat taxonomy is active. For example,

    add_action( 'init', 'custom_wc_product_cat_label' );
    function custom_wc_product_cat_label() {
        global $wp_taxonomies;
    
        if ( isset( $wp_taxonomies['product_cat'] ) ) {
    	    $cat = $wp_taxonomies['product_cat'];
    	    $cat->label = 'My Categories';
    	    $cat->labels->singular_name = 'My Category';
    	    $cat->labels->name = $cat->label;
    	    $cat->labels->menu_name = $cat->label;
    	}
    
    }

    2) You can use WooCommerce filter that Mike provided. For example

    add_filter( 'woocommerce_taxonomy_args_product_cat', 'custom_wc_taxonomy_args_product_cat' );
    function custom_wc_taxonomy_args_product_cat( $args ) {
    	$args['label'] = __( 'Product Categories', 'woocommerce' );
    	$args['labels'] = array(
            'name' 				=> __( 'Product Categories', 'woocommerce' ),
            'singular_name' 	=> __( 'Product Category', 'woocommerce' ),
            'menu_name'			=> _x( 'Categories', 'Admin menu name', 'woocommerce' ),
            'search_items' 		=> __( 'Search Product Categories', 'woocommerce' ),
            'all_items' 		=> __( 'All Product Categories', 'woocommerce' ),
            'parent_item' 		=> __( 'Parent Product Category', 'woocommerce' ),
            'parent_item_colon' => __( 'Parent Product Category:', 'woocommerce' ),
            'edit_item' 		=> __( 'Edit Product Category', 'woocommerce' ),
            'update_item' 		=> __( 'Update Product Category', 'woocommerce' ),
            'add_new_item' 		=> __( 'Add New Product Category', 'woocommerce' ),
            'new_item_name' 	=> __( 'New Product Category Name', 'woocommerce' )
    	);
    
    	return $args;
    }
Viewing 5 replies - 1 through 5 (of 5 total)