Skip to content

Commit

Permalink
minor fixes for 2.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jkudish committed Apr 28, 2012
1 parent ea3e643 commit 5193518
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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~
4 changes: 2 additions & 2 deletions inc/checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );


?>
Expand Down
49 changes: 35 additions & 14 deletions jigoshop-software.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
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
Text Domain: jigoshop-software
*/

/**
* @version 2.1.3
* @version 2.1.4
* @author Joachim Kudish <info@jkudish.com>
* @link http://jkudish.com
* @uses JigoShop @link http://jigoshop.com
Expand Down Expand Up @@ -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' ) );
Expand All @@ -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' );
Expand Down Expand Up @@ -889,6 +890,16 @@ function loop_add_to_cart( $post, $_product ) {
?><a href="<?php echo $_product->add_to_cart_url(); ?>" class="button"><?php _e( 'Buy Now' , 'jigoshop-software' ); ?></a><?php
}

/**
* 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"
*
Expand All @@ -913,6 +924,19 @@ function locate_api_template( $template ) {
return JIGOSHOP_SOFTWARE_PATH . '/inc/api.php';
}

/**
* 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
*
Expand All @@ -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;
}
Expand Down Expand Up @@ -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' );
}

Expand Down

0 comments on commit 5193518

Please sign in to comment.