• Resolved pwasielewski

    (@pwasielewski)


    Hi,
    My website use custom “add_to_cart” function because i need to pass custom data for products. But when i am using it, i am not getting [dnd-wc-file-upload] array in my cart item variable.

    This is the WooCommerce function i use to push new product to the cart:

    WC()->cart->add_to_cart($product_id, $quantity, $variation_id, $variation, $cart_item_data);

    Can you help me and tell what should i do to get array with files i uploaded to product?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Glen Don Mongaya

    (@glenwpcoder)

    Hello @pwasielewski ,

    Sorry for the late reply.

    You can try this approach.

    $cart_items = WC()->cart->get_cart();
    foreach( $cart_items as $hash => $cart ) {
      if( isset( $cart['dnd-wc-file-upload'] ) ) {
          $files = $cart['dnd-wc-file-upload'];
      }
    }
    
    print_r( $files );
    Thread Starter pwasielewski

    (@pwasielewski)

    Hi @glenwpcoder,
    Thanks for your answer. But i have problem that this data cannot be added to ordered product because i use custom function to add product to cart.

    I am not submiting default WooCommerce add_to_cart button. Is there any way to get access uploaded files before added to cart?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Ajax upload files with custom item data’ is closed to new replies.