Home Forums WoodMart support forum How to Fix Product Description Changes in WooCommerce When Adding New Products

How to Fix Product Description Changes in WooCommerce When Adding New Products

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #640220

    kruajeng
    Participant

    I’m working on WooCommerce, and I want to replace the Tabs with an accordion. I’m trying to change the menu from Tabs, and I’ve used the shortcode [product_description]

    I’m using this PHP code, which displays the product description on my current product details page. However, when I add a new product, the product description changes, and when I go back to the previous product, the description has been updated to match the new product.

    How can I fix this?

    Thank you

    add_shortcode( ‘product_description’, ‘display_product_description’ );

    function display_product_description( $atts ){
        $atts = shortcode_atts( array(
            ‘id’ => null, // Default to null, explicitly check for it
        ), $atts, ‘product_description’ );
        $product_id = $atts[‘id’];
        if ( ! $product_id ) {
            // If no ID is provided, try to get it from the current post if it’s a product
            if ( is_product() ) {
                $product_id = get_the_ID();
            } else {
              return ”; // or a message like “Product ID not provided”
            }
        }
        $product = wc_get_product( $product_id );
        if ( ! $product || ! $product->is_visible() ) { // Check if the product exists and is visible
            return ”; // or a message like “Product not found”
        }
        return $product->get_description();
    }

    #640372

    Hung Pham
    Keymaster

    Hi kruajeng,

    First of all, I’m really sorry have taken long time to reply you due to the weekend.

    Unfortunately, customization is out of our basic support.

    Thanks for understanding our limitations. Let me know if you have any questions.

    Best Regards,

Viewing 2 posts - 1 through 2 (of 2 total)