• Resolved Kamalpreet Singh

    (@boyka_dhaliwal)


    Hello
    I am using lots of Custom fields for the Products. and I am showing it on the cart page along with the product items.
    CART AS PDF button is working but in the PDF doc, on the real Cart page, Products are shown like this https://prnt.sc/qz46ru.

    But in the PDF it shows only PRODUCT NAME, QTY, PRICE, etc. not the extra info that I am showing on the cart page.

    Regards
    Kamalpreet Singh

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

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author David Jensen

    (@dkjensen)

    Hello

    Is this a custom integration of the product addons? If it is not what plugin are you using to add the product options? I would be happy to help you sort this out, though I might need additional information as well as access to your website to integrate the options on the PDF.

    Thread Starter Kamalpreet Singh

    (@boyka_dhaliwal)

    @dkjensen Thankyou so much for the quick response. I am using the Advanced Custom Field plugin. what type of info do you need?
    Please tell me, I will able to do it. I am dev too. I will easily get you. ??

    Plugin Author David Jensen

    (@dkjensen)

    What hook are you using to add the product data to the WooCommerce cart?

    In the PDF you can hook into this to display your cart data:

    do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key );

    And it also renders the cart item data used natively by WooCommerce if you would like to do it this way

    echo wc_get_formatted_cart_item_data( $cart_item ); // PHPCS: XSS ok.

    • This reply was modified 4 years, 9 months ago by David Jensen.
    Thread Starter Kamalpreet Singh

    (@boyka_dhaliwal)

    I am using like

    WC()->cart->add_to_cart( $_POST['product_id'],
    $_POST['quantity'],array(
    'roomType'=>$_POST['roomType'],
    'color'=>$_POST['color'],
    'mount'=>$_POST['mount'],
    'size'=>$_POST['size']).... 

    to insert the custom field into the cart.

    and then fetch the data like

    foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item )

    Plugin Author David Jensen

    (@dkjensen)

    If the cart item data is present it will display on the PDF. I suggest you use the WooCommerce function wc_get_formatted_cart_item_data to display your cart data instead of using your own loop.

    See here

    https://docs.woocommerce.com/wc-apidocs/source-function-wc_get_formatted_cart_item_data.html#3491-3563

    If you don’t want to use this function, simply create a new function and attach it to the hook here like this:


    function your_function_name( $cart_item, $cart_item_key ) {
    print_r( $cart_item ); // Output all cart item data
    }
    add_action( ‘woocommerce_after_cart_item_name’, ‘your_function_name’, 10, 2 );

    • This reply was modified 4 years, 9 months ago by David Jensen.
    Thread Starter Kamalpreet Singh

    (@boyka_dhaliwal)

    Thank you so much for your support. I really appreciate it. Let me check and try to follow your idea and see what I get. ??
    #Thanks

    Plugin Author David Jensen

    (@dkjensen)

    Hey were you able to get this working?

    Plugin Author David Jensen

    (@dkjensen)

    I’m going to mark as resolved since there has been no activity

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Custom Fields Value of the Product Items are not showing’ is closed to new replies.