yorkshirepudding's picture

As part of a module, I want to programmatically add a certain product to a cart or order and go straight to checkout.

Can anyone guide me into which functions I need to use?

Do I need to go via a cart or can I go straight to order?

Comments

Have you tried uc_cart_add_item()? You need to provide the nid of the product. Then you can use backdrop_goto('cart/checkout'); to send the user to the checkout screen. uc_cart_add_item automatically creates a new order for the logged in user, or for the anonymous user browsing the page (Ubercart creates a session for anonymous to store the order number).