• Resolved venya

    (@venya)


    Hello,

    I’m using both standard paypal, and paypal express and during checkout (order summary page) the product name is transferred correctly, but also includes stray code and the product subtitle (book author).

    For example.

    Russian Idea<div class=”subtitlecart”>Alexander Yanov</div>

    The second half gets cut off due to length, but if you hover on it I see text above.

    I would ideally like to have the product displayed as

    Russian Idea (larger font)
    Alexander Yanov

    Or in the very least just the book title, without everything else.

    Hope you can help.
    Thank you.

    https://www.ads-software.com/plugins/woocommerce/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    HTML is not supported in names passed to paypal. In general, html in titles is not recommended at all.

    Do both paypal methods do the same thing? It would be possible to strip tags, but not strip content – it wouldn’t know where to break up the string.

    Thread Starter venya

    (@venya)

    Hi Mike,

    Yes, it’s appearing in regular and express.

    It would already be good to strip the html.

    If just html is stripped would it appear as product name _space_product author?

    If so, that might still look messy and confusing.

    It seem like it might be a better idea to just pull in the product name…

    How can I remove the html and custom field from exporting to Paypal?

    Thanks!

    Thread Starter venya

    (@venya)

    I found a helpful old post that gets me half way there. This code removed all html leaving me with product name and custom field without a space between them.

    How do I remove the custom field as well?

    add_filter( ‘woocommerce_paypal_args’, ‘custom_woocommerce_paypal_args’ );
    function custom_woocommerce_paypal_args( $args ) {
    foreach ( $args as $key => $arg ) {
    if ( strstr( $key, ‘^item_name_’ ) ) {
    $args[ $key ] = strip_tags( $arg );
    }
    }
    return $args;
    }

    Plugin Contributor Mike Jolley

    (@mikejolley)

    Thats the correct approach. Why can you not add the space in the product name itself before the tag?

    Thread Starter venya

    (@venya)

    I could but I have hundreds of products….
    This is the code that put the subtitle with the product name.
    How can I put an exception to just not include subtitle into the paypal process?

    function kia_subtitle_for_woocommerce_products( $title, $product ){
    if( function_exists( ‘get_the_subtitle’ ) && $subtitle = get_the_subtitle( $product->id ) ){
    $title .= ‘<div class=”subtitlecart”>’ . $subtitle . ‘</div>’;
    }
    return $title;
    }
    add_filter( ‘woocommerce_product_title’, ‘kia_subtitle_for_woocommerce_products’, 10, 2 );

    Plugin Contributor Mike Jolley

    (@mikejolley)

    You could add the space to that code no?

    Thread Starter venya

    (@venya)

    I tried that, but doesn’t look good.

    Tried separating with a dash, but then that will also appears in the cart, which I don’t want.

    Based on the code I pasted above, is there a line of code that will prevent the subtitle script from not running on the checkout process?

    Thanks.

    Plugin Contributor Mike Jolley

    (@mikejolley)

    What does not look good?

    I mean changing:

    $title .= '<div class="subtitlecart">' . $subtitle . '</div>';

    to:

    $title .= ' <div class="subtitlecart">' . $subtitle . '</div>';
    Thread Starter venya

    (@venya)

    Thanks Mike.
    Thats exactly what I tried.

    It did put a space between the product and subtitle and its better than the alternative but would rather just remove subtitle altogether.
    Can this be done from the code I pasted earlier?
    Thank you.

    Plugin Contributor Mike Jolley

    (@mikejolley)

    You could make do something like this:

    if( function_exists( 'get_the_subtitle' ) && ( $subtitle = get_the_subtitle( $product->id ) ) $$ ! defined( 'WOOCOMMERCE_CHECKOUT' )  ){
    Thread Starter venya

    (@venya)

    I get the following error:

    Parse error: syntax error, unexpected ‘$’ in …/wp-content/themes/x-child/functions.php on line 293

    function kia_subtitle_for_woocommerce_products( $title, $product ){

    [line293] if( function_exists( ‘get_the_subtitle’ ) && ( $subtitle = get_the_subtitle( $product->id ) ) $$ ! defined( ‘WOOCOMMERCE_CHECKOUT’ ) ){
    $title.= ‘<div class=”subtitlecart”> | ‘ . $subtitle . ‘</div>’;
    }
    return $title;
    }
    add_filter( ‘woocommerce_product_title’, ‘kia_subtitle_for_woocommerce_products’, 10, 2 );

    if( function_exists( ‘get_the_subtitle’ ) && ( $subtitle = get_the_subtitle( $product->id ) ) $$ ! defined( ‘WOOCOMMERCE_CHECKOUT’ ) ){

    Plugin Contributor Mike Jolley

    (@mikejolley)

    Sorry typo, $$ to &&

    Thread Starter venya

    (@venya)

    Brilliant. That did it!
    Thanks for the speedy reply and help!

    Thread Starter venya

    (@venya)

    Hi Mike,
    I updated the paypal express extension and now the darn html and custom fields are back. They do not appear in regular checkout.

    Would you know how to tweak the code to remove html and custom fields on paypal express checkout page?

    Thanks.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Paypal checkout / Order summary has visible code from custom field’ is closed to new replies.