[Checkout] Developer seeks co-operation from jQuery expert

alecmyers

Joined: 2006-08-01
Posts: 3361
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?

Login or register to post comments
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 2669
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

Login or register to post comments
alecmyers

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

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

Login or register to post comments
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 2669
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

Login or register to post comments
alecmyers

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

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

Login or register to post comments