Skip to content
Browse files

minor fixes for 2.1.4

  • Loading branch information...
1 parent ea3e643 commit 519351808442a75c60ddb135a11309f3524b0f82 @jkudish committed
Showing with 43 additions and 17 deletions.
  1. +6 −1 README.md
  2. +2 −2 inc/checkout.php
  3. +35 −14 jigoshop-software.php
View
7 README.md
@@ -9,6 +9,11 @@ The plugin requires JigoShop 1.1.1 or higher.
Changelog
===========
+### 2.1.4
+* Empty cart when order is cancelled at paypal
+* Minor adjustment to output buffer used to modify price sent to paypal
+* Fix php notice in number_format function
+
### 2.1.3
* Save license keys with prefixes as lowercase
@@ -118,4 +123,4 @@ Current Version
The line below is used for the updater API, please leave it untouched unless bumping the version up :)
-~Current Version:2.1.3~
+~Current Version:2.1.4~
View
4 inc/checkout.php
@@ -32,8 +32,8 @@
// prices format in US dollars
setlocale( LC_MONETARY, 'en_US' );
- @$echo_price = money_format( '%(#10n', $price );
- @$echo_up_price = money_format( '%(#10n', $up_price );
+ @$echo_price = money_format( '%(#10n', (float) $price );
+ @$echo_up_price = money_format( '%(#10n', (float) $up_price );
?>
View
49 jigoshop-software.php
@@ -3,7 +3,7 @@
Plugin Name: JigoShop - Software Add-On
Plugin URI: https://github.com/jkudish/JigoShop-Software-Add-on/
Description: Extends JigoShop to a full-blown software shop, including license activation, license retrieval, activation e-mails and more
-Version: 2.1.3
+Version: 2.1.4
Author: Joachim Kudish
Author URI: http://jkudish.com
License: GPL v2
@@ -11,7 +11,7 @@
*/
/**
- * @version 2.1.3
+ * @version 2.1.4
* @author Joachim Kudish <info@jkudish.com>
* @link http://jkudish.com
* @uses JigoShop @link http://jigoshop.com
@@ -102,7 +102,6 @@ function __construct() {
add_action( 'downloadable_add_to_cart', array( $this, 'add_to_cart' ) );
add_action( 'grouped_add_to_cart', array( $this, 'add_to_cart' ) );
add_action( 'jigoshop_after_shop_loop_item', array( $this, 'loop_add_to_cart' ), 10, 2 );
- add_filter( 'init', array( $this, 'init_output_buffer' ) );
add_action( 'wp_print_styles', array( $this, 'print_styles' ) );
add_action( 'wp_head', array( $this, 'redirect_away_from_cart' ) );
@@ -112,7 +111,9 @@ function __construct() {
add_action( 'wp_ajax_jgs_lost_license', array( $this, 'ajax_jgs_lost_license' ) );
// payment stuff
+ add_action( 'init', array( $this, 'init_output_buffer') );
add_action( 'thankyou_paypal', array( $this, 'post_paypal_payment' ) );
+ add_action( 'order_status_cancelled', array( $this, 'cancel_order' ) );
// email stuff
remove_action( 'order_status_pending_to_processing', 'jigoshop_new_order_notification' );
@@ -890,6 +891,16 @@ function loop_add_to_cart( $post, $_product ) {
}
/**
+ * empty the cart when an order is cancelled
+ *
+ * @param int the order id
+ * @return void
+ */
+ function cancel_order( $order_id ) {
+ jigoshop_cart::empty_cart();
+ }
+
+ /**
* redirect the user to checkout after they've clicked "buy now"
*
* @see jigoshop_add_to_cart_action()
@@ -914,6 +925,19 @@ function locate_api_template( $template ) {
}
/**
+ * runs an output buffer on the price sent to paypal when upgrading
+ *
+ * @see jigoshop_software_filter_price_paypal
+ * @since 2.1.4
+ * @return void
+ */
+ function init_output_buffer() {
+ if ( isset( $_GET['order'] ) && isset( $_GET['key'] ) ) {
+ ob_start( array( $this, 'filter_price_paypal' ) );
+ }
+ }
+
+ /**
* very hacky way to filter out the price sent to paypal when it's an upgrade, but the only way to do it w/out changing core jigoshop
*
* @see $this->init_output_buffer()
@@ -922,15 +946,13 @@ function locate_api_template( $template ) {
* @param string $buffer what's being sent to paypal
* @return string $buffer what's being sent to paypal
*/
- function jigoshop_software_filter_price_paypal( $buffer ) {
- if ( isset($_GET['order']) ) {
- $order_id = $_GET['order'];
- $data = get_post_meta( $order_id, 'order_data', true );
- $original_price = $data['original_price'];
- $correct_price = $data['order_total'];
- if ( $original_price ) {
- $buffer = str_replace( '"amount_1" value="' . $original_price . '"', '"amount_1" value="' . $correct_price . '"', $buffer );
- }
+ function filter_price_paypal( $buffer ) {
+ $order_id = $_GET['order'];
+ $data = get_post_meta( $order_id, 'order_data', true );
+ $original_price = number_format( $data['original_price'], 2 );
+ $correct_price = number_format( $data['order_total'], 2 );
+ if ( $original_price ) {
+ $buffer = str_replace( '"amount_1" value="' . $original_price . '"', '"amount_1" value="' . $correct_price . '"', $buffer );
}
return $buffer;
}
@@ -1676,11 +1698,10 @@ function import( $import = null ) {
* @since 1.0
* @return void
*/
- add_action( 'init', 'jigoshop_software_init' );
+ add_action( 'plugins_loaded', 'jigoshop_software_init', 1 );
function jigoshop_software_init() {
global $jigoshopsoftware;
$jigoshopsoftware = new Jigoshop_Software();
- ob_start( array( $jigoshopsoftware, 'jigoshop_software_filter_price_paypal' ) );
include_once( 'inc/shortcodes.php' );
}

0 comments on commit 5193518

Please sign in to comment.
Something went wrong with that request. Please try again.