• Resolved jakariaahmed118477

    (@jakariaahmed118477)


    Hi,
    Recently i read your this post below.
    Post- https://www.skyverge.com/blog/change-woocommerce-additional-information-tab/

    Now I need a help. When I add this code on my function.php file, it replace comma(, ) between two term of attribute. And it applied to my all attributes. But I want to apply it to some specific attributes. How can I do it? Help me…..

    Applied codes:

    function skyverge_change_attribute_list_display( $output, $attributes, $values ) {

    return wpautop( wptexturize( implode( ‘<br />’, $values ) ) );
    }
    add_filter( ‘woocommerce_attribute’, ‘skyverge_change_attribute_list_display’, 10, 3 );

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor tamarazuk

    (@tamarazuk)

    Hi?@jakariaahmed118477,

    Thanks for writing to us! I apologize for the delay in getting back to you. I am happy to help out here. ??

    You can check for specific a specific attribute by checking the $attribute->get_name() ( the $attributes from the code in the post should really read $attribute).

    I hope that’s helpful!

    Tamara ??

    Thread Starter jakariaahmed118477

    (@jakariaahmed118477)

    where i need to add this “$attribute->get_name()” code? Should i add this code after my applied code?

    Plugin Contributor tamarazuk

    (@tamarazuk)

    Hi @jakariaahmed118477,

    Sure, I’m happy to provide some tips here. You can update the code like so:

    
    function skyverge_change_attribute_list_display( $output, $attributes, $values ) {
    
    	if ( 'Specific Attribute Name' === $attribute->get_name() ) {
    		$output = wpautop( wptexturize( implode( ‘<br />’, $values ) ) );
    	}
    	
    	return $output;
    }
    add_filter( 'woocommerce_attribute', 'skyverge_change_attribute_list_display', 10, 3 );
    
    

    Here you would replace Specific Attribute Name with the name of your attribute such as Color or Size.

    I hope that’s helpful ??

    Stay safe,
    Tamara

    Thread Starter jakariaahmed118477

    (@jakariaahmed118477)

    When i add this code on my functions.php, then shows “There has been a critical error on your website.”.
    How i can do it? Do you have any other code?

    Plugin Contributor tamarazuk

    (@tamarazuk)

    Hi @jakariaahmed118477,

    Sorry about that, seems like two characters got mangled as I copy/pasted the code from your original sample. Please try the following:

    
    function skyverge_change_attribute_list_display( $output, $attributes, $values ) {
    
    	if ( 'Specific Attribute Name' === $attribute->get_name() ) {
    		$output = wpautop( wptexturize( implode( '<br />', $values ) ) );
    	}
    
    	return $output;
    }
    add_filter( 'woocommerce_attribute', 'skyverge_change_attribute_list_display', 10, 3 );
    

    Thanks

    Thread Starter jakariaahmed118477

    (@jakariaahmed118477)

    I tried this code also, again it shows the same message.

    Plugin Contributor tamarazuk

    (@tamarazuk)

    @jakariaahmed118477 Do you still have the original code in place or did you replace it with the above?

    Thread Starter jakariaahmed118477

    (@jakariaahmed118477)

    I was only replace with attribute name.

    Plugin Contributor tamarazuk

    (@tamarazuk)

    Hi @jakariaahmed118477,

    Would you please check the email that was sent to your WordPress admin email for the full error message? Alternatively, you can also enable WP Debug Mode to see the errors directly or in a log file.

    Please be sure to remove any identifying information from the error logs if you want to paste them here ??

    Thanks,
    Tamara

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Woocommerce attribute problem’ is closed to new replies.