• Im trying to make a checkout template with a product already added (using add_action with my function at the beginning of the template) but always redirect to another page saying that cart is empty. Im doing this trying to edit form-checkout.php on my template.

    How can i do this?

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

    (@midoucloud)

    I found a way creating a new template, but i dont get the total updates even if i use WC()->cart->calculate_totals(); after the add to cart

    add_action() can be used to add some markup to a template, but just showing it in the cart is not enough. What you need to do is to add the product to the $woocommerce global variable with:

    
    $woocommerce->cart->add_to_cart( $free_product_id );
    

    Hopefully you can adapt this snippet:
    https://pastebin.com/tY3DEypx

    Thread Starter MidouCloud

    (@midoucloud)

    This dont work, because im trying to do this with curl to load on a different website

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Checkeout template with product already added’ is closed to new replies.