WooCommerce create an order programmatically and redirect to payment

前端 未结 2 1366
旧巷少年郎
旧巷少年郎 2021-02-05 16:42

For WooCommerce i\'m lookin\' for a solution to create an order programmaticly (my site just has 1 homepage with some fields) to order.

After products are added with a

2条回答
  •  走了就别回头了
    2021-02-05 17:10

    To skip the checkout page you can filter the add to cart url.

    function so_31787244_redirect_to_checkout( $url ) {
    
        // Remove default cart message
        WC()->clear_messages();
    
        // Redirect to checkout
        $url = WC()->cart->get_checkout_url();
    
        return $url;
    }
    add_filter( 'add_to_cart_redirect', 'so_31787244_redirect_to_checkout' );
    

    You could also pursue a plugin such as One Page Checkout

提交回复
热议问题