Page 1 of 1

[Resolved]Express Checkout

Posted: Sat Dec 01, 2012 1:05 pm
by pokemon007
I'm trying to implement express checkout such that when customer clicks on modified "Buy Now" it adds the product to the cart and then brings customer to the checkout page that has cart view as header and checkout form as the body while customer can still click on "Add to Cart" behaving like current demo's "Buy Now". What I did is
1. Add /cart/addAndCheckout method to CartController that adds the product to cart and redirect to /checkout/expressCheckout
2. Add /checkout/expressCheckout to CheckoutController that returns /checkout/expressCheckout view module
3. Add expressCheckoutLayout that includes /cart/cart as header
4. Add entry to layout map in application-servlet.xml such that /checkout/expressCheckout view using expressCheckoutLayout.

Everything works perfectly except for the jQuery/Ajax functionality in cartOperations.js view. I added some debug alert and found everything works fine except that the last line to update the cart's html doesn't work. For instance, remove an item from cart:

Code: Select all

   // Intercept remove from cart operations and perform them via AJAX instead
   // This will trigger on any link with class "remove_from_cart"
   $('body').on('click', 'a.remove_from_cart', function() {
      alert('remove_from_cart');
      var link = this;
      
      BLC.ajax({url: $(link).attr('href'),
            type: "GET"
         }, function(data, extraData) {
            updateHeaderCartItemsCount(extraData.cartItemCount);
            showAddToCartButton(extraData.productId, 'cart');
            
         alert(data);
            $('.fancybox-inner').html(data);
         }
      );
      return false;
   });   


Further experiment, I found this jQuery/Ajax only works in popup. If I navigate to /cart in the browser directly, it won't work either. I'm new to jQuery, can someone give me a hint? Is this the problem of selector qualifier or sort?

Thank you in advance!

-Charlie

Re: Express Checkout

Posted: Tue Dec 04, 2012 5:36 pm
by phillipuniverse
The part that updates the popup is this:

Code: Select all

$('.fancybox-inner').html(data);
 


The $('.fancybox-inner') is a JQuery selector (plenty of docs can be found via Google on how to use these) that selects the popup element. The .html(data) part says "replace the innerHtml of the item returned by the JQuery selector with the 'data' that I am passing in". You will need to change the selector and possibly the HTML that is returned from the server to be relevant for your requirements.

Re: Express Checkout

Posted: Thu Dec 27, 2012 5:14 am
by pokemon007
This issue has been resolved.

Thank you!