Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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. :)

share|improve this question
    
What if a user buys both products? –  Ewout Mar 23 '13 at 18:07
    
Hi @Ewout, Thanks for your question. A user may buy only one product at a time. –  boxoft Mar 23 '13 at 23:51
add comment

1 Answer

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.

share|improve this answer
    
Thanks for your answer. :) Merging the 2 different checkout pages into one is an approach. –  boxoft Mar 25 '13 at 22:15
    
is the answer not what you are looking for? –  Ewout Mar 25 '13 at 22:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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