• Resolved gentle2309

    (@gentle2309)


    span> – </span> – Appearing in woocommerce cart page

    View post on imgur.com

    the problem disappears when i disable the plugin , and it appears again when i activate it so the translatepress causes the problem..

    could you please help me !!

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    You might have a bug or conflict with your current theme / plugins.

    Can you please visit TranslatePress -> Settings -> Advanced

    Then, enable these features 1 by 1 in this order and try to see if it makes a difference. Also please disable or clear the cache if you have any.

    1. Fix missing dynamic content
    2. Disable dynamic translation
    3. Fix spaces between HTML attributes
    4. Fix broken HTML

    Cheers,

    Thread Starter gentle2309

    (@gentle2309)

    hello thank you for taking time to answer me, unfortunately, i tried every step but nothing works .

    Hello,

    As I have encountered the problem at other users also i forwarded the issue to the dev team. they will try to fix the problem as soon as possible.

    Kind regards,
    Denis

    Well I have resolved the issue and found its cause, so will post the solution which should be helpful to other users maybe. My theme was implementing a custom ajax cart so it was showing the html <span> tag in the product name. Here is how my product would look in the cart : ProductName <span>-</span> ProductVariation instead of normal ProductName – ProductVariation.

    So the problem lies in this file in the plugin Translate Press translatepress-multilingual/includes/compatibility-functions.php on line 230 in plugin version 1.7.9

    add_filter( 'woocommerce_product_variation_title', 'trp_woo_wrap_variation', 8, 4);
    function trp_woo_wrap_variation($name, $product, $title_base, $title_suffix){
        $separator  = '<span> - </span>';
        return $title_suffix ? $title_base . $separator . $title_suffix : $title_base;
    }

    So of-course a simple fix would be to comment this code. But of-course you will lose separate translations for product name and product variation string. So I did not change here, but changed code in my theme file with custom ajax cart. So my theme had this piece of code for item title to display in cart:

    <h3 class="title14 product-title"><a href="<?php echo esc_url($product_permalink)?>"><?php echo esc_html($product_name)?></a></h3>

    Notice they are escaping the html of the product title (like anyone would normally do). So i just removed the esc_html( call and it solved my problem. Now the <span> tags are parsed as normal html instead of showing in the product title.

    Any fix for this on a website not using a custom ajax cart?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘SPAN – /SPAN – Appearing in woocommerce cart page’ is closed to new replies.