• Resolved Joe G.

    (@webgmclassics)


    This is wonderful idea and good implementation overall.

    Is it possible to convert a cart with existing products to a quote-cart when a quote-product is added? Right now, it simply removes the previous products.

    My use case:
    – Our store has some products which require Truck shipping and therefore a customized shipping quote.
    – When such a product is added, we would like the entire cart to be converted to a quote.

    Is this possible?

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Joe G.

    (@webgmclassics)

    It seems that simply disabling WC()->cart->empty_cart(); within the qwc_cart_validations method achieves this affect. Is there any risks in doing this?

    Thread Starter Joe G.

    (@webgmclassics)

    I think I have successfully modified the plugin to accomplish this. Is there anything I am missing? Any red flags?

    1. Comment out the qwc_cart_validations method, replace with

    $product_quotable = product_quote_enabled( $product_id );		
    if($product_quotable){
    $message = 'This product requires special shipping. Continue to add products to your cart and when you checkout, we will review your order and send you an email with a shipping quote for you to pay and complete your order.';
    wc_add_notice( __( $message, 'quote-wc' ), $notice_type = 'notice' );
    }

    2. Add the following in the __construct method

    // modify the proceed to checkout button text. Requires modified child template at woo.../cart/proceed-to-checkout-button
    add_action('woocommerce_cart_proceed_text', array( &$this, 'j5_qwc_change_checkout_button_text'),20);
    // disable shipping
    add_filter( 'woocommerce_cart_ready_to_calc_shipping', [&$this, 'j5_qwc_disable_shipping_calc_on_cart'], 99 );

    3. Add the following methods

    /**
             * Modify the Proceed to checkout button on the cart page
             * @mod
             */
    		function j5_qwc_change_checkout_button_text() {
    			if (cart_contains_quotable()){
    				esc_html_e( 'Proceed to quote', 'woocommerce' );
    			}else{
    				esc_html_e( 'Proceed to checkout', 'woocommerce' );
    			}
    		}
    		
    		
    		function j5_qwc_disable_shipping_calc_on_cart( $show_shipping ) {
    			if(cart_contains_quotable() ) {
    				return false;
    			}
    			return $show_shipping;
    		}

    4. Modify the qwc_css method by adding

    if ( cart_contains_quotable()) {
    wp_enqueue_style( 'qwc-frontend', plugins_url( '/assets/css/qwc-disable-shipping.css', __FILE__ ), '', $plugin_version, false );}

    5. Create the relevant stylesheet hiding the shipping row

    Thread Starter Joe G.

    (@webgmclassics)

    Last question for the day – is there a particular reason the plugin does not create a new order status called “pending quote” or something like that? As I was writing a modifying plugin, I added the feature before noticing that the plugin checks for the processing status on a few occasions.

    If you’re interested, I’ll send you the code and you might be able to include it in a future release.

    Plugin Author pinal.shah

    (@pinalshah)

    Hi Joe,

    I’m glad to know that you were able to modify the plugin to suit your needs. Yes, it would be great if you could send the code (pinalj1612 at gmail dot com) and I will try to add it in a future update.

    As for adding a new order status, the quote status is being managed as order meta as you might’ve noticed. Another possibility could be to display the quote status in WooCommerce->Orders instead of modifying the order status. However, I’ll analyze this further and implement it.

    Thanks for sharing this and please feel free to get in touch if you would like to see any more features added to the plugin to make it better.

    Thanks,
    Pinal

    Plugin Author pinal.shah

    (@pinalshah)

    Also, the code you’ve added to stop the cart from being emptied and not display the shipping row also looks good and should not raise any issues.

    Pinal

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Converting Cart to Quote’ is closed to new replies.