0

I'm wondering whether it's possible to make 2 different checkout pages for 2 different products?

If a buyer chooses the product #1, he/she will be redirected to the checkout page #1. If he/she chooses the product #2, he/she will be redirected to the checkout page #2.

These 2 checkout pages have some same fields and some different fields. Some same fields are optional on the checkout page #1 but are mandatory on the checkout page #2.

Any help is appreciated. :)

2
  • What if a user buys both products?
    – Ewout
    Mar 23, 2013 at 18:07
  • Hi @Ewout, Thanks for your question. A user may buy only one product at a time.
    – Box
    Mar 23, 2013 at 23:51

1 Answer 1

1

If you want to make sure a user can only buy one product at a time, you need to disable shopping after a user has bought a product: otherwise a user could press 'back', and add the other product to the cart.

That said, you could try changing the checkout fields conditionally by putting this in functions.php:

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

function custom_override_checkout_fields( $fields ) {
    global $woocommerce;

    //assuming only one product in cart
    foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
        $_product = $values['data'];
    }

    switch ($_product->id) {
        case '666': //product id for product 1
            //do stuff with the checkout fields
            break;
        case '999': //product id for product 2
            //do stuff with the checkout fields
            break;
    }

    return $fields;
}

take a look at this tutorial for more info about changing checkout fields.

2
  • Thanks for your answer. :) Merging the 2 different checkout pages into one is an approach.
    – Box
    Mar 25, 2013 at 22:15
  • is the answer not what you are looking for?
    – Ewout
    Mar 25, 2013 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.