Forum Replies Created

Viewing 1 replies (of 1 total)
  • fireworkswebsites

    (@fireworkswebsites)

    @hardikp Ypu will have to use a workaround for now:

    In your functions.php file insert the following hooks:

    
    add_action('woocommerce_checkout_process', 'afterpay_post');
    function afterpay_post() {
        if(!session_id()) { session_start(); }
        if ($_POST['payment_method'] === 'afterpay') {
            $_SESSION['AFTERPAY'] = $_POST;
        }
    }
    
    add_action('woocommerce_checkout_update_order_meta', 'afterpay_delivery_date', 10, 1);
    function afterpay_delivery_date($order_id) {
        if(!session_id()) { session_start(); }
        if(isset($_SESSION['AFTERPAY'])) {
            $data = $_SESSION['AFTERPAY'];
            foreach($data as $k=>$v) {
                $_POST[$k] = $v;
            }
            unset($_SESSION['AFTERPAY']);
        }
    }
    

    Basically this just saves your checkout’s form data from the $_POST object into a session variable. When Afterpay redirects back to your site, the 2nd hook takes that session and extracts the data and reassigns it to the $_POST object. The Delivery Date plugin handles the rest.

Viewing 1 replies (of 1 total)