Hooks for stripe

This commit is contained in:
Mike Jolley 2012-06-19 19:09:51 +01:00
parent 74fbd56d5b
commit c9ddba1e35
5 changed files with 58 additions and 43 deletions

View File

@ -708,50 +708,63 @@ jQuery(document).ready(function($) {
/* AJAX Form Submission */ /* AJAX Form Submission */
$('form.checkout').submit( function() { $('form.checkout').submit( function() {
var $form = $(this); var $form = $(this);
if ($form.is('.processing')) return false; if ( $form.is('.processing') )
return false;
$form.addClass('processing').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6}});
// Trigger a handler to let gateways manipulate the checkout if needed
$.ajax({ if ( $form.triggerHandler('checkout_place_order') !== false && $form.triggerHandler('checkout_place_order_' + $('#order_review input[name=payment_method]:checked').val() ) !== false ) {
type: 'POST',
url: woocommerce_params.checkout_url, $form.addClass('processing');
data: $form.serialize(),
success: function( code ) { var form_data = $form.data();
$('.woocommerce_error, .woocommerce_message').remove();
try { if ( form_data["blockUI.isBlocked"] != 1 )
result = $.parseJSON( code ); $form.block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6}});
if (result.result=='success') { $.ajax({
type: 'POST',
url: woocommerce_params.checkout_url,
data: $form.serialize(),
success: function( code ) {
try {
result = $.parseJSON( code );
window.location = decodeURI(result.redirect); if (result.result=='success') {
window.location = decodeURI(result.redirect);
} else if (result.result=='failure') {
$('.woocommerce_error, .woocommerce_message').remove();
$form.prepend( result.messages );
$form.removeClass('processing').unblock();
} else if (result.result=='failure') { if (result.refresh=='true') $('body').trigger('update_checkout');
$form.prepend( result.messages ); $('html, body').animate({
scrollTop: ($('form.checkout').offset().top - 100)
}, 1000);
} else {
throw "Invalid response";
}
}
catch(err) {
$('.woocommerce_error, .woocommerce_message').remove();
$form.prepend( code );
$form.removeClass('processing').unblock(); $form.removeClass('processing').unblock();
if (result.refresh=='true') $('body').trigger('update_checkout');
$('html, body').animate({ $('html, body').animate({
scrollTop: ($('form.checkout').offset().top - 100) scrollTop: ($('form.checkout').offset().top - 100)
}, 1000); }, 1000);
} else {
throw "Invalid response";
} }
} },
catch(err) { dataType: "html"
$form.prepend( code ); });
$form.removeClass('processing').unblock();
}
$('html, body').animate({
scrollTop: ($('form.checkout').offset().top - 100)
}, 1000);
}
},
dataType: "html"
});
return false; return false;
}); });

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@ Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, affiliate
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@woothemes.com&item_name=Donation+for+WooCommerce Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@woothemes.com&item_name=Donation+for+WooCommerce
Requires at least: 3.3 Requires at least: 3.3
Tested up to: 3.4 Tested up to: 3.4
Stable tag: 1.5.7.1 Stable tag: 1.5.8
License: GPLv3 License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html License URI: http://www.gnu.org/licenses/gpl-3.0.html
@ -161,7 +161,9 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog == == Changelog ==
= = = 1.5.8 - 21/06/2012 =
* Tweak - Added checkout processing triggers for gateways (in particular stripe) to use
* Tweak - Pay page woocommerce_pay hidden input so we can use javascript to submit the form
* Tweak - Hooks for order statuses in reports * Tweak - Hooks for order statuses in reports
* Fix - Remove depreciated ereg_replace in validation class * Fix - Remove depreciated ereg_replace in validation class
* Fix - strpos warning in shipping class * Fix - strpos warning in shipping class

View File

@ -76,8 +76,8 @@ global $woocommerce;
<div class="form-row"> <div class="form-row">
<?php $woocommerce->nonce_field('pay')?> <?php $woocommerce->nonce_field('pay')?>
<input type="submit" class="button alt" name="woocommerce_pay" id="place_order" value="<?php _e('Pay for order', 'woocommerce'); ?>" /> <input type="submit" class="button alt" id="place_order" value="<?php _e('Pay for order', 'woocommerce'); ?>" />
<input type="hidden" name="woocommerce_pay" value="1" />
</div> </div>
</div> </div>

View File

@ -3,7 +3,7 @@
* Plugin Name: WooCommerce * Plugin Name: WooCommerce
* Plugin URI: http://www.woothemes.com/woocommerce/ * Plugin URI: http://www.woothemes.com/woocommerce/
* Description: An e-commerce toolkit that helps you sell anything. Beautifully. * Description: An e-commerce toolkit that helps you sell anything. Beautifully.
* Version: 1.5.7.1 * Version: 1.5.8
* Author: WooThemes * Author: WooThemes
* Author URI: http://woothemes.com * Author URI: http://woothemes.com
* Requires at least: 3.3 * Requires at least: 3.3
@ -32,7 +32,7 @@ class Woocommerce {
/** Version ***************************************************************/ /** Version ***************************************************************/
var $version = '1.5.7.1'; var $version = '1.5.8';
/** URLS ******************************************************************/ /** URLS ******************************************************************/