New Landing How can we help? Cardinal tip for use custom field sf_product_description on checkout page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Posted in: Cardinal
  • #128613
    ez
    Member
    Post count: 10

    Hi,
    I’ve used filter to add short description to products in the WooCommerce cart, how could I use sf_product_description instead of post_excerpt (not on product page but on product list)?

    add_filter( ‘woocommerce_get_item_data’, ‘wc_checkout_description_so_15127954’, 10, 2 );

    function wc_checkout_description_so_15127954( $other_data, $cart_item )
    {
    $post_data = get_post( $cart_item[‘product_id’] );
    $other_data[] = array( ‘name’ => $post_data->post_excerpt );
    return $other_data;
    }

    Please help.
    Best regards,
    Ewelina

    Attachments:
    You must be logged in to view attached files.
    #128766
    laranz – SUPPORT
    Member
    Post count: 3186

    Hi,

    You can get it like this

    
    $product_description = sf_get_post_meta( $post->ID, 'sf_product_description', true );

    Let us know,

    Thanks,
    laranz.

    #128809
    ez
    Member
    Post count: 10

    Thanks!
    it works when I’ve changed $post->ID on $cart_item[‘product_id’]

    function wc_checkout_description_so_15127954( $other_data, $cart_item )
    {

    $post_data = get_post( $cart_item[‘product_id’] );
    $other_data[] = array( ‘name’ => $product_description=sf_get_post_meta( $cart_item[‘product_id’], ‘sf_product_description’, true ) );
    return $other_data;
    }

    Best regards,
    e

    #128811
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Great 🙂

    – Kyle

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

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register