• Resolved CanadianKevbo

    (@canadiankevbo)


    Hi There,

    I have been trying to set this up correctly for 2 days now. I have no syncing issues, products are being uploaded to pinterest. However, the descriptions it’s pulling are just attributes from my woocommerce products. It is skipping over the actual product description entirely and just pulling attributes from the variations to show that in the product pin on pinterest.

    I have tried modifying both the plugin and my functions.php to try to resolve this, and to ensure it pulls the info from the short or long descriptions, and am having zero luck. Has anyone else noticed these issues?

    I’m using woocommerce attribute swatches plugin as well. I don’t think this is interfering, but there is a chance. That being said, I would prefer not to go and deactivate that to test if unnecessary.

    Is there a developer on here that has had this issue before and resolved it? Do you have suggestions on how I could approach this?

    Here is a link to my feed file, to check it out. I will continue to work on it after posting this question, so it may be resolved by the time this is responded to.

    Thank you in advance.

    https://archetypeforms.com/wp-content/uploads/pinterest-for-woocommerce-.xml

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter CanadianKevbo

    (@canadiankevbo)

    Finally found a solution. I’m putting it here in case anyone else needs it. I haven’t fully tested if there are bugs, but it all seems good. This takes the short description in your product and makes sure it puts it as the <description> in the product feed generated, it also appears for any variations of those items. I’m sure the logic can be used for other purposes. So you may want to refer to it. I simply put it in my child theme’s functions.php but it could go in a plugin. I’ll wait till my feed gets updated to Pinterest then come back and confirm if everything is good.

    //pulls short description and puts it in pinterest for woocommerce product feed
    function use_short_description_in_pinterest_feed( $xml, $product ) {
    // Ensure we're working with the correct product (parent if necessary)
    if ( $product->is_type('variation') ) {
    $product = wc_get_product( $product->get_parent_id() );
    }

    // Retrieve the short description
    $short_description = $product->get_short_description();

    // Fallback to excerpt if short description is empty
    if ( empty( $short_description ) ) {
    $short_description = get_the_excerpt( $product->get_id() );
    }

    // Sanitize and prepare the description for XML
    $description = '<![CDATA[' . wp_strip_all_tags( $short_description ) . ']]>';

    // Replace the existing <description> tag with the short description
    $xml = preg_replace( '/<description>.*?<\/description>/', '<description>' . $description . '</description>', $xml );

    return $xml;
    }

    // Hook into the Pinterest feed generation to apply the short description
    add_filter( 'pinterest_for_woocommerce_feed_item_xml', 'use_short_description_in_pinterest_feed', 10, 2 );

    Hello @canadiankevbo,

    Glad to know that the issue has been resolved now and thank you for sharing the solution and contributing to the WooCommerce Community.

    Should you have further inquiries, kindly?create a new topic here.

    Cheers!

    Thread Starter CanadianKevbo

    (@canadiankevbo)

    My feed updated last night and had the short description in the details properly with no errors. I hope the code above helps!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.