[Checkout] Developer seeks co-operation from jQuery expert

alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sat, 2009-11-07 12:27

As the current maintainer for the checkout series of modules, I'd very much like to modernise the cart pages of this module by AJAXing them. I'd like to make the order totals and so on update dynamically in real time when you change the quantities, have the postage do likwise and so on.

I've a little experience with integrating jQuery with Gallery2 and I like the way it feels.

Also there should be no problem for me to write the Gallery-end of things to supply the server-side information for the dynamic webpages.

Is there anyone out there who'd like to help with the client-side stuff?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2009-11-07 13:25

I'm no expert but...
jQuery makes it so easy ;)

<script>
//Updates checkout
function updateCheckout(){
    $.ajax({
        type: "POST",
        url: "/gallery2/checkout_processing_view.php",
        data: {
            // Tell checkout_processing_view.php which function to execute and pass any variables via $_POST
            'function': 'update',
            'new_item_being_added': itemName,
            'new_items_price': itemPrice,
            'shipping' : itemShipping,
            'tax_rate' : itemTaxRate
        },
        dataType: "json",
        // We'll receive an json encoded array back
        success: function(data){
            if (data.items) {
                // Iterate(assuming they can add more then one item at a time)
                // through our items list and add them to the "items in basket" column
                for (var i = 0; i < data.items.length; i++) {
                    $('#basket-display').append($("<p>" + data.items[i].itemName + "&nbsp;" + data.items[i].itemPrice +  "</p>"));
                }
            }
            if (data.totalShipping) {
                $('#total-shipping').html($("<span class=\"totalsText\">" + data.totalShipping + "</span>"));
            }
            if (data.totalTax) {
                $('#total-tax').html($("<span class=\"totalsText\">" + data.totalTax + "</span>"));
            }
            if (data.totalPrice) {
                $('#total-price').html($("<span class=\"totalsText\">" + data.totalPrice + "</span>"));
            }
        },
    });
}
</script>

And on the php side just make sure you json_encode() the data array before you send it back.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sat, 2009-11-07 13:55

Are you volunteering to do the client-side stuff? I want volunteers, not technical hints!

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2009-11-07 14:00

I've never even installed one of gallery's checkout modules as I have no interest.
So sorry no.
I was just trying to illustrate how easy it would be for someone like yourself.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sat, 2009-11-07 14:22

I know it's "easy", but mucking about with dhtml and javascript holds no interest for me.

 
surfgimp

Joined: 2007-11-13
Posts: 8
Posted: Mon, 2010-02-01 18:40

I'm no jquery expert but I'm a jack of most trades. PHP, jquery, css etc. I've recently started to dabble with your plugins so I could lend a hand if you need it.

Cheers
Steve

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2010-02-01 18:44

Unfortunately, the period where I had plenty of spare time (November/December) has passed, and I am now in it past my eyeballs for the foreseeable. Thanks for the offer though.