Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

update to version 1.4.5

  • Loading branch information...
commit 803c142407efda8c7047a5e2c89984ce56f842ad 1 parent f46dbd7
@divergeinfinity divergeinfinity authored
Showing with 5,537 additions and 5,791 deletions.
  1. +30 −0 CONTRIBUTING.md
  2. +7 −7 admin/jigoshop-admin-dashboard.php
  3. +10 −0 admin/jigoshop-admin-product-quick-bulk-edit.php
  4. +10 −10 admin/jigoshop-admin-reports.php
  5. +48 −56 admin/jigoshop-admin-settings-api.php
  6. +2 −3 admin/jigoshop-install.php
  7. +19 −2 assets/css/frontend.css
  8. +23 −2 assets/css/frontend.less
  9. +6 −3 assets/js/script.js
  10. +233 −209 classes/jigoshop_cart.class.php
  11. +12 −9 classes/jigoshop_checkout.class.php
  12. +11 −0 classes/jigoshop_customer.class.php
  13. +6 −18 classes/jigoshop_options.class.php
  14. +1 −1  classes/jigoshop_order.class.php
  15. +65 −61 classes/jigoshop_product.class.php
  16. +3 −1 classes/jigoshop_tax.class.php
  17. +16 −32 gateways/paypal.php
  18. +1 −1  gateways/skrill.php
  19. +5 −4 jigoshop.php
  20. +18 −13 jigoshop_actions.php
  21. +261 −188 jigoshop_emails.php
  22. +8 −14 jigoshop_template_functions.php
  23. +18 −0 jigoshop_upgrade.php
  24. BIN  languages/jigoshop-hr_HR.mo
  25. +2,733 −3,211 languages/jigoshop-hr_HR.po
  26. BIN  languages/jigoshop-ja_JA.mo
  27. +537 −512 languages/{jigoshop-en_GB.po → jigoshop-ja_JA.po}
  28. +1,395 −1,417 languages/jigoshop.pot
  29. +26 −3 readme.txt
  30. +3 −2 shipping/shipping_method.class.php
  31. +17 −8 shortcodes/cart.php
  32. +12 −3 templates/checkout/review_order.php
  33. +1 −1  version.txt
View
30 CONTRIBUTING.md
@@ -0,0 +1,30 @@
+#Contribute To Jigoshop
+
+Community made patches, localisations, bug reports and contributions are always welcome and are crucial to ensure Jigoshop remains the #1 eCommerce platform for WordPress.
+
+When contributing please ensure you follow the guidelines below so that we can keep on top of things.
+
+__note__ GitHub is for bug reports and contributions only - if you have a support question or a request for a customisation don't post here. Use [Jigoshop Forum](http://forum.jigoshop.com/) instead.
+
+## Getting Started
+
+* Submit a ticket for your issue, assuming one does not already exist.
+ * https://github.com/jigoshop/jigoshop/issues
+ * Clearly describe the issue including steps to reproduce when it is a bug.
+ * Make sure you fill in the earliest version that you know has the issue.
+
+## Making Changes
+
+* Fork the repository on GitHub
+* Make the changes to your forked repository
+ * Ensure you stick to the [WordPress Coding Standards](http://codex.wordpress.org/WordPress_Coding_Standards)
+* When committing, reference your issue (if present) and include a note about the fix
+* Push the changes to your fork and submit a pull request to the 'dev' branch of the Jigoshop repository
+
+At this point you're waiting on us to merge your pull request. We'll review all pull requests, and make suggestions and changes if necessary.
+
+# Additional Resources
+
+* [General GitHub documentation](http://help.github.com/)
+* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
+* [Jigoshop Forum](http://forum.jigoshop.com/)
View
14 admin/jigoshop-admin-dashboard.php
@@ -50,13 +50,13 @@ function on_load_page() {
wp_enqueue_script('wp-lists');
wp_enqueue_script('postbox');
- add_meta_box('jigoshop_dash_right_now', 'Right Now', array(&$this, 'jigoshop_dash_right_now'), $this->page, 'side', 'core');
- add_meta_box('jigoshop_dash_recent_orders', 'Recent Orders', array(&$this, 'jigoshop_dash_recent_orders'), $this->page, 'side', 'core');
- add_meta_box('jigoshop_dash_stock_report', 'Stock Report', array(&$this, 'jigoshop_dash_stock_report'), $this->page, 'side', 'core');
- add_meta_box('jigoshop_dash_monthly_report','Monthly Report',array(&$this, 'jigoshop_dash_monthly_report'),$this->page, 'normal', 'core');
- add_meta_box('jigoshop_dash_recent_reviews','Recent Reviews',array(&$this, 'jigoshop_dash_recent_reviews'),$this->page, 'normal', 'core');
- add_meta_box('jigoshop_dash_latest_news', 'Latest News', array(&$this, 'jigoshop_dash_latest_news'), $this->page, 'normal', 'core');
- add_meta_box('jigoshop_dash_useful_links', 'Useful Links', array(&$this, 'jigoshop_dash_useful_links'), $this->page, 'normal', 'core');
+ add_meta_box('jigoshop_dash_right_now', __('Right Now','jigoshop'), array($this, 'jigoshop_dash_right_now'), $this->page, 'side', 'core');
+ add_meta_box('jigoshop_dash_recent_orders', __('Recent Orders','jigoshop'), array($this, 'jigoshop_dash_recent_orders'), $this->page, 'side', 'core');
+ add_meta_box('jigoshop_dash_stock_report', __('Stock Report','jigoshop'), array($this, 'jigoshop_dash_stock_report'), $this->page, 'side', 'core');
+ add_meta_box('jigoshop_dash_monthly_report', __('Monthly Report','jigoshop'), array($this, 'jigoshop_dash_monthly_report'),$this->page, 'normal', 'core');
+ add_meta_box('jigoshop_dash_recent_reviews', __('Recent Reviews','jigoshop'), array($this, 'jigoshop_dash_recent_reviews'),$this->page, 'normal', 'core');
+ add_meta_box('jigoshop_dash_latest_news', __('Latest News','jigoshop'), array($this, 'jigoshop_dash_latest_news'), $this->page, 'normal', 'core');
+ add_meta_box('jigoshop_dash_useful_links', __('Useful Links','jigoshop'), array($this, 'jigoshop_dash_useful_links'), $this->page, 'normal', 'core');
}
function on_show_page() {
View
10 admin/jigoshop-admin-product-quick-bulk-edit.php
@@ -69,7 +69,12 @@ function jigoshop_ajax_get_product_stock_price() {
if ( $_product->is_type( array( 'grouped' ) ) ) {
$values['price'] = __('Grouped parent has no price','jigoshop');
} else {
+ if (get_post_meta( $_GET['post_id'], 'regular_price', true ) == null){
+ $values['price']='';
+ }
+ else {
$values['price'] = sprintf( "%.2F", get_post_meta( $_GET['post_id'], 'regular_price', true ) );
+ }
}
die( json_encode( $values ) );
@@ -136,7 +141,12 @@ function jigoshop_save_quick_edit( $post_id, $post ) {
}
if ( array_key_exists( 'price', $_POST ) && ! empty( $_POST['price'] ) ) {
if ( ! $_product->is_type( array( 'grouped' ) ) ) {
+ if ($_POST[ 'price' ] == null){
+ update_post_meta( $post_id, 'regular_price', '' );
+ }
+ else{
update_post_meta( $post_id, 'regular_price', jigoshop_sanitize_num( $_POST[ 'price' ] ) );
+ }
}
}
break;
View
20 admin/jigoshop-admin-reports.php
@@ -25,9 +25,9 @@ class Jigoshop_reports {
function __construct() {
- add_filter( 'posts_where', array(&$this, 'orders_within_range') );
+ add_filter( 'posts_where', array($this, 'orders_within_range') );
$this->orders = apply_filters( 'jigoshop_reports_orders', $this->jigoshop_get_orders());
- remove_filter( 'posts_where', array(&$this, 'orders_within_range') );
+ remove_filter( 'posts_where', array($this, 'orders_within_range') );
$this->on_show_page();
@@ -127,14 +127,14 @@ function on_show_page() {
<div id="report-widgets" class="metabox-holder">
<div class='thumbnail mainGraph' style=''>
- <h1>Sales</h1>
+ <h1><?php _e('Sales','jigoshop'); ?></h1>
<?php $this->jigoshop_dash_monthly_report(); ?>
</div>
<br class="clear"/>
<div class="span3 thumbnail">
- <h2>Top Earners</h2>
+ <h2><?php _e('Top Earners','jigoshop'); ?></h2>
<div id="top_earners_pie" style="height:300px"></div>
<?php $this->jigoshop_top_earners(); ?>
<?php echo $this->jigoshop_pie_charts('top_earners_pie'); ?>
@@ -142,7 +142,7 @@ function on_show_page() {
</div>
<div class="span3 thumbnail">
- <h2>Most Sold</h2>
+ <h2><?php _e('Most Sold','jigoshop'); ?></h2>
<div id="most_sold_pie" style="height:300px"></div>
<?php $this->jigoshop_most_sold(); ?>
<?php echo $this->jigoshop_pie_charts('most_sold_pie'); ?>
@@ -150,17 +150,17 @@ function on_show_page() {
<div class="span3 thumbnail">
<h1><?php echo $this->jigoshop_total_customers(); ?></h1>
- <h3>Total New Customers</h3>
+ <h3><?php _e('Total New Customers','jigoshop'); ?></h3>
</div>
<div class="span3 thumbnail">
<h1><?php echo $this->jigoshop_total_orders(); ?></h1>
- <h3>Total Orders</h3>
+ <h3><?php _e('Total Orders','jigoshop'); ?></h3>
</div>
<div class="span3 thumbnail">
<h1><?php echo $this->jigoshop_total_sales(); ?></h1>
- <h3>Total Sales</h3>
+ <h3><?php _e('Total Sales','jigoshop'); ?></h3>
</div>
</div>
@@ -555,7 +555,7 @@ function weekendAreas(axes) {
for (var i = 0; i < d2.length; ++i) d2[i][0] += 60 * 60 * 1000;
- var plot = jQuery.plot(jQuery("#placeholder"), [ { label: "Number of sales", data: d }, { label: "Sales amount", data: d2, yaxis: 2 } ], {
+ var plot = jQuery.plot(jQuery("#placeholder"), [ { label: "<?php _e('Number of sales','jigoshop'); ?>", data: d }, { label: "<?php _e('Sales amount','jigoshop'); ?>", data: d2, yaxis: 2 } ], {
series: {
lines: { show: true },
points: { show: true }
@@ -602,7 +602,7 @@ function showTooltip(x, y, contents) {
jQuery("#tooltip").remove();
- if (item.series.label=="Number of sales") {
+ if (item.series.label=="<?php _e('Number of sales','jigoshop'); ?>") {
var y = item.datapoint[1];
showTooltip(item.pageX, item.pageY, item.series.label + " - " + y);
View
104 admin/jigoshop-admin-settings-api.php
@@ -83,12 +83,18 @@ public function register_settings() {
$screen = get_current_screen();
if ( $screen->base <> 'jigoshop_page_jigoshop_settings' && $screen->base <> 'options' ) return;
- register_setting( JIGOSHOP_OPTIONS, JIGOSHOP_OPTIONS, array ( $this, 'validate_settings' ) );
-
$slug = $this->get_current_tab_slug();
$options = $this->our_parser->tabs[$slug];
- foreach ( $options as $index => $option ) {
+ if ( ! is_array( $options ) ) {
+ jigoshop_log( "Jigoshop Settings API: -NO- valid options for 'register_settings()' - EXITING with:" );
+ jigoshop_log( $options );
+ return;
+ }
+
+ register_setting( JIGOSHOP_OPTIONS, JIGOSHOP_OPTIONS, array( $this, 'validate_settings' ) );
+
+ if ( is_array( $options )) foreach ( $options as $index => $option ) {
switch ( $option['type'] ) {
case 'title':
add_settings_section( $option['section'], $option['name'], array( $this, 'display_section' ), JIGOSHOP_OPTIONS );
@@ -217,9 +223,9 @@ public function output_markup() {
<?php settings_fields( JIGOSHOP_OPTIONS ); ?>
<?php do_settings_sections( JIGOSHOP_OPTIONS ); ?>
- <?php $tabname = $this->get_current_tab_name(); ?>
-
- <p class="submit"><input name="Submit" type="submit" class="button-primary" value="<?php echo sprintf( __( "Save %s Changes", 'jigoshop' ), $tabname ); ?>" /></p>
+ <p class="submit">
+ <input name="Submit" type="submit" class="button-primary" value="<?php echo sprintf( __( "Save %s Changes", 'jigoshop' ), $this->get_current_tab_name() ); ?>" />
+ </p>
</div>
</div>
@@ -295,7 +301,7 @@ public function get_current_tab_slug() {
if ( isset( $_GET['tab'] ) ) {
$current = $_GET['tab'];
- } else if ( isset( $_POST['_wp_http_referer'] ) ) {
+ } else if ( isset( $_POST['_wp_http_referer'] ) && strpos($_POST['_wp_http_referer'], '&tab=') !== false ) {
// /site/wp-admin/admin.php?page=jigoshop_settings&tab=products-inventory&settings-updated=true
// find the 'tab'
$result = strstr( $_POST['_wp_http_referer'], '&tab=' );
@@ -306,9 +312,9 @@ public function get_current_tab_slug() {
$current = substr( $result, 0 , $end_pos !== false ? $end_pos : strlen( $result ) );
// products-inventory
} else {
- $current = sanitize_title( $this->our_parser->these_options[0]['name'] );
+ $current = $this->our_parser->these_options[0]['name'];
}
- return $current;
+ return sanitize_title( $current );
}
@@ -318,31 +324,15 @@ public function get_current_tab_slug() {
* @since 1.3
*/
public function get_current_tab_name() {
- $current = "";
- if ( isset( $_GET['tab'] ) ) {
- foreach ( $this->our_parser->these_options as $option ) {
- if ( $option['type'] == 'tab' && sanitize_title( $option['name'] ) == $_GET['tab'] ) {
- $current = $option['name'];
- }
- }
- } else if ( isset( $_POST['_wp_http_referer'] ) ) {
- // /site/wp-admin/admin.php?page=jigoshop_settings&tab=products-inventory&settings-updated=true
- // find the 'tab'
- $result = strstr( $_POST['_wp_http_referer'], '&tab=' );
- // &tab=products-inventory&settings-updated=true
- $result = substr( $result, 5 );
- // products-inventory&settings-updated=true
- $end_pos = strpos( $result, '&' );
- $tab_slug = substr( $result, 0 , $end_pos !== false ? $end_pos : strlen( $result ) );
- // products-inventory
- foreach ( $this->our_parser->these_options as $option ) {
- if ( $option['type'] == 'tab' && sanitize_title( $option['name'] ) == $tab_slug ) {
- $current = $option['name'];
- }
+ $current = $this->our_parser->these_options[0]['name'];
+
+ $slug = $this->get_current_tab_slug();
+ foreach ( $this->our_parser->tab_headers as $tab ) {
+ $this_slug = sanitize_title( $tab );
+ if ( $slug == $this_slug ) {
+ $current = $tab;
}
- } else {
- $current = $this->our_parser->these_options[0]['name'];
}
return $current;
}
@@ -365,12 +355,21 @@ public function validate_settings( $input ) {
$valid_input = $current_options; // we start with the current options
// Find the current TAB we are working with and use it's option settings
- $this_section = self::get_current_tab_name();
+ $this_section = $this->get_current_tab_name();
$tab = $this->our_parser->tabs[sanitize_title( $this_section )];
// with each option, get it's type and validate it
- foreach ( $tab as $index => $setting ) {
+ if ( ! empty( $tab )) foreach ( $tab as $index => $setting ) {
if ( isset( $setting['id'] ) ) {
+
+ // special case tax classes should be updated, they will do nothing if this is not the right TAB
+ if ( $setting['id'] == 'jigoshop_tax_rates' ) {
+ $valid_input['jigoshop_tax_rates'] = $this->get_updated_tax_classes();
+ update_option( $setting['id'], $valid_input['jigoshop_tax_rates'] ); // TODO: remove in v1.5 - provides compatibility
+ continue;
+ }
+
+ // get this settings options
foreach ( $defaults as $default_index => $option ) {
if ( in_array( $setting['id'], $option ) ) {
break;
@@ -388,7 +387,7 @@ public function validate_settings( $input ) {
if ( is_callable( $option['update'], true ) ) {
$result = call_user_func( $option['update'] );
$valid_input[$setting['id']] = $result;
- update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.4 - provides compatibility
+ update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.5 - provides compatibility
}
}
break;
@@ -404,14 +403,14 @@ public function validate_settings( $input ) {
}
}
$valid_input[$setting['id']] = $selected;
- update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.4 - provides compatibility
+ update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.5 - provides compatibility
}
break;
case 'checkbox' :
// there will be no $value for a false checkbox, set it now
$valid_input[$setting['id']] = isset( $value ) ? 'yes' : 'no';
- update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.4 - provides compatibility
+ update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.5 - provides compatibility
break;
case 'multicheck' :
@@ -424,14 +423,14 @@ public function validate_settings( $input ) {
}
}
$valid_input[$setting['id']] = $selected;
- update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.4 - provides compatibility
+ update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.5 - provides compatibility
break;
case 'text' :
case 'longtext' :
case 'textarea' :
$valid_input[$setting['id']] = esc_attr( jigowatt_clean( $value ) );
- update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.4 - provides compatibility
+ update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.5 - provides compatibility
break;
case 'email' :
@@ -447,7 +446,7 @@ public function validate_settings( $input ) {
} else {
$valid_input[$setting['id']] = esc_attr( jigowatt_clean( $email ) );
}
- update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.4 - provides compatibility
+ update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.5 - provides compatibility
break;
case 'decimal' :
@@ -463,7 +462,7 @@ public function validate_settings( $input ) {
} else {
$valid_input[$setting['id']] = $cleaned;
}
- update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.4 - provides compatibility
+ update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.5 - provides compatibility
break;
case 'integer' :
@@ -479,7 +478,7 @@ public function validate_settings( $input ) {
} else {
$valid_input[$setting['id']] = $cleaned;
}
- update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.4 - provides compatibility
+ update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.5 - provides compatibility
break;
case 'natural' :
@@ -495,13 +494,13 @@ public function validate_settings( $input ) {
} else {
$valid_input[$setting['id']] = $cleaned;
}
- update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.4 - provides compatibility
+ update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.5 - provides compatibility
break;
default :
if ( isset( $value ) ) {
$valid_input[$setting['id']] = $value;
- update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.4 - provides compatibility
+ update_option( $setting['id'], $valid_input[$setting['id']] ); // TODO: remove in v1.5 - provides compatibility
}
break;
}
@@ -509,13 +508,6 @@ public function validate_settings( $input ) {
}
- // tax classes should be updated
- // they will do nothing if this is not the right TAB
- if ( $setting['id'] == 'jigoshop_tax_rates' ) {
- $valid_input['jigoshop_tax_rates'] = $this->get_updated_tax_classes();
- update_option( $setting['id'], $valid_input['jigoshop_tax_rates'] ); // TODO: remove in v1.4 - provides compatibility
- }
-
// remove all jigoshop_update_options actions on shipping classes when not on the shipping tab
if ( $this_section != __('Shipping','jigoshop') ) {
$this->remove_update_options( jigoshop_shipping::get_all_methods() );
@@ -533,7 +525,7 @@ public function validate_settings( $input ) {
add_settings_error(
'',
'settings_updated',
- sprintf(__('"%s" settings were updated successfully.','jigoshop'), self::get_current_tab_name()),
+ sprintf(__('"%s" settings were updated successfully.','jigoshop'), $this_section ),
'updated'
);
}
@@ -689,8 +681,6 @@ function get_updated_tax_classes() {
endfor;
- /* Remove duplicates. */
- $tax_rates = array_values( array_unique( $tax_rates, SORT_REGULAR ));
usort( $tax_rates, array( $this, 'csort_tax_rates' ) );
return $tax_rates;
@@ -752,7 +742,7 @@ private function parse_options() {
if ( $item['type'] == 'tab' ) {
$tab_name = sanitize_title( $item['name'] );
- $tab_headers[$tab_name] = $item['name'];
+ $tab_headers[$tab_name] = $item['name']; // used by get_current_tab_name()
continue;
}
@@ -775,11 +765,13 @@ private function parse_options() {
public function format_option_for_display( $item ) {
+ if ( empty( $item['id'] )) return ''; // ensure we have an id to work with
+
$data = Jigoshop_Base::get_options()->get_current_options();
$display = ""; // each item builds it's output into this and it's returned for echoing
$class = "";
-
+
if ( isset( $item['class'] ) ) {
$class = $item['class'];
}
View
5 admin/jigoshop-install.php
@@ -213,12 +213,11 @@ function jigoshop_create_single_page( $page_slug, $page_option, $page_data ) {
function jigoshop_tables_install() {
global $wpdb;
- if ( is_multisite() ) define( 'DIEONDBERROR', true );
-
+ if((!defined('DIEONDBERROR'))&&(is_multisite())){define('DIEONDBERROR',true);}
$wpdb->show_errors();
$collate = '';
- if($wpdb->supports_collation()) {
+ if($wpdb->has_cap( 'collation' )) {
if(!empty($wpdb->charset)) $collate = "DEFAULT CHARACTER SET $wpdb->charset";
if(!empty($wpdb->collate)) $collate .= " COLLATE $wpdb->collate";
}
View
21 assets/css/frontend.css
@@ -376,7 +376,7 @@ a.button,
button.button,
input.button,
#review_form #submit {
- color: #fff !important;
+ color: #fff;
background: #ff9c07;
padding: 6px;
line-height: 1em !important;
@@ -406,7 +406,7 @@ input.button:hover,
float: none;
}
.button-alt {
- color: #fff !important;
+ color: #fff;
background: #069bcd;
padding: 6px;
line-height: 1em !important;
@@ -818,6 +818,7 @@ td.quantity,
}
.cart-collaterals .cart_totals h2 {
text-align: left;
+ margin: 0;
margin-left: 10px;
}
.cart-collaterals .cart_totals p {
@@ -1241,3 +1242,19 @@ input:-ms-input-placeholder {
background: white;
color: LightGray;
}
+/* =Twenty Twelve
+-------------------------------------------------------------- */
+.jigoshop .site-content {
+ width: 66%;
+}
+.jigoshop .site-content .cross-sells {
+ width: auto;
+}
+.jigoshop .site-content div.jigoshop_error,
+.jigoshop .site-content div.jigoshop_message {
+ padding: 15px 10px 15px 32px;
+}
+.jigoshop .site-content div.jigoshop_error a.button,
+.jigoshop .site-content div.jigoshop_message a.button {
+ margin-top: -4px;
+}
View
25 assets/css/frontend.less
@@ -434,7 +434,7 @@ table.shop_attributes {
/* =Buttons
-------------------------------------------------------------- */
a.button, button.button, input.button, #review_form #submit {
- color: #fff !important;
+ color: #fff;
background: #ff9c07;
padding: 6px;
line-height: 1em !important;
@@ -461,7 +461,7 @@ a.button:hover, button.button:hover, input.button:hover, #review_form #submit:ho
}
.button-alt {
- color: #fff !important;
+ color: #fff;
background: #069bcd;
padding: 6px;
line-height: 1em !important;
@@ -844,6 +844,7 @@ td.quantity, .jigoshop #content div.quantity {
text-align: right;
h2 {
text-align: left;
+ margin: 0;
margin-left: 10px;
}
p {
@@ -1291,3 +1292,23 @@ input:-ms-input-placeholder {
background: white;
color: LightGray;
}
+
+/* =Twenty Twelve
+-------------------------------------------------------------- */
+
+.jigoshop .site-content {
+// width: 65.104166667%; /*twenty-twelve default, not quite wide enough to have 4 columns on Shop */
+ width: 66%;
+}
+
+.jigoshop .site-content .cross-sells {
+ width: auto;
+}
+
+.jigoshop .site-content div.jigoshop_error, .jigoshop .site-content div.jigoshop_message {
+ padding: 15px 10px 15px 32px;
+
+ a.button {
+ margin-top: -4px;
+ }
+}
View
9 assets/js/script.js
@@ -224,7 +224,7 @@ jQuery(function() {
current_attr_select.find('option:gt(0)').attr('disabled', 'disabled');
// Get name
- var current_attr_name = current_attr_select.attr('name');
+ var current_attr_name = current_attr_select.attr('name');
// Loop through variations
for(num in variations) {
@@ -242,6 +242,9 @@ jQuery(function() {
}
}
}
+
+ // completely re-enable the previous select so 'Choose an option' isn't required to change selections
+ current_attr_select.parent().prev().find('select').find('option:gt(0)').removeAttr('disabled');
});
@@ -479,9 +482,9 @@ if ( jigoshop_params.is_checkout ) {
clearTimeout(updateTimer);
update_checkout();
}).change();
- jQuery('input#billing-country, input#billing-state, #billing-postcode, input#shipping-country, input#shipping-state, #shipping-postcode').live('keydown', function(){
+ jQuery('input#billing-country, input#billing-state, #billing-postcode, input#shipping-country, input#shipping-state, #shipping-postcode').live('change', function(){
clearTimeout(updateTimer);
- updateTimer = setTimeout("update_checkout()", '5000');
+ update_checkout();
});
jQuery('select#billing-country, select#billing-state, select#shipping-country, select#shipping-state, #shiptobilling input').live('change', function(){
clearTimeout(updateTimer);
View
442 classes/jigoshop_cart.class.php
@@ -206,9 +206,13 @@ function add_to_cart($product_id, $quantity = 1, $variation_id = '', $variation
self::$cart_contents[$cart_id] = apply_filters( 'jigoshop_add_cart_item', array(
'data' => $product,
'product_id' => $product_id,
- 'quantity' => (int) $quantity,
'variation' => $variation,
- 'variation_id'=> $variation_id
+ 'variation_id'=> $variation_id,
+ 'quantity' => (int) $quantity,
+ 'unit_price' => 0,
+ 'tax' => 0,
+ 'discount' => 0,
+ 'price_includes_tax' => self::get_options()->get_option('jigoshop_prices_include_tax')
), $cart_item_data);
}
@@ -392,34 +396,77 @@ private static function reset_totals() {
* Calculate total 'cart fixed' and 'cart percentage' discounts
*
* @param $total_to_use the cart total price to base discounts on, tax in or out usually
+ *
+ * @return $cart_discount a total monetary amount from the applied cart discount coupons
*/
private static function calculate_cart_discounts_total( $total_to_use ) {
-
+
+ $cart_discount = 0;
if ( ! empty( self::$applied_coupons )) foreach ( self::$applied_coupons as $code ) {
if ( $coupon = JS_Coupons::get_coupon( $code )) {
switch ( $coupon['type'] ) :
case 'fixed_cart' :
- self::$discount_total += $coupon['amount'];
+ $cart_discount += $coupon['amount'];
break;
case 'percent' :
- self::$discount_total += ( $total_to_use / 100 ) * $coupon['amount'];
+ $cart_discount += ( $total_to_use / 100 ) * $coupon['amount'];
break;
- case 'fixed_product' :
- if ( sizeof( $coupon['include_products'] ) == 0 )
- self::$discount_total += ( $coupon['amount'] * sizeof( self::$cart_contents ) );
- break;
endswitch;
}
}
-
+ return $cart_discount;
}
+ /**
+ * Calculate total 'product fixed' and 'product percentage' discounts
+ *
+ * @param $_product the product we are working with
+ * @param $values the cart values for this product
+ *
+ * @return $current_product_discount
+ */
+ private static function calculate_product_discounts_total( $_product, $values ) {
+
+ $current_product_discount = 0;
+
+ if ( ! empty( self::$applied_coupons )) foreach ( self::$applied_coupons as $code ) {
+
+ $coupon_discount = 0;
+ $coupon = JS_Coupons::get_coupon( $code );
+
+ if ( ! JS_Coupons::is_valid_coupon_for_product( $code, $values ) ) continue;
+
+ $price = self::get_options()->get_option('jigoshop_tax_after_coupon') == 'yes'
+ ? $_product->get_price_excluding_tax()
+ : $_product->get_price_with_tax();
+
+ switch ( $coupon['type'] ) {
+
+ case 'fixed_product' :
+ $coupon_discount = ( $coupon['amount'] * $values['quantity'] );
+ if ( $coupon_discount > $price * $values['quantity'] )
+ $coupon_discount = $price * $values['quantity'];
+ break;
+
+ case 'percent_product' :
+
+ $coupon_discount = ( $price * $values['quantity'] / 100 ) * $coupon['amount'];
+ break;
+ }
+
+ $current_product_discount += $coupon_discount;
+
+ }
+
+ return $current_product_discount;
+
+ }
/**
*
@@ -434,146 +481,90 @@ private static function calculate_cart_total() {
return;
}
- /**
- * Whole new section on applying cart coupons. If we need to apply coupons before
- * taxes are calculated, we need to figure out how to apply full cart coupons evenly
- * since there might be different tax classes on different products. Therefore, the
- * best way to apply evenly on the cart is to figure out a percentage of the total
- * discount that will be applied, and then apply that percentage to each product
- * individually before calculating taxes.
- */
$percentage_discount = 1;
$total_cart_discounts = 0; // determines how much cart discount is left over
$total_cart_price_ex_tax = 0;
$total_cart_price_with_tax = 0;
-
- // for all cart discounts, we need to apply the discount on all items evenly. Find out
- // how many items are in the cart, and then find out if there is a discount on the cart
- if ( self::get_options()->get_option('jigoshop_calc_taxes') == 'yes' ) {
+ $current_product_discount = 0;
+ $discounted_item_price = 0;
+ // Used to determine how many iterations are left on the cart_contents. Applied with cart coupons
+ // NOTE: cart coupons are moved out of here in 1.4.5, not sure we need this anymore
+ $cart_contents_loop_count = count( self::$cart_contents );
- if ( ! empty( self::$cart_contents )) foreach ( self::$cart_contents as $cart_item_key => $values ) {
- $_product = $values['data'];
- $total_cart_price_ex_tax += $_product->get_price_excluding_tax( $values['quantity'] );
- $total_cart_price_with_tax += $_product->get_price_with_tax( $values['quantity'] );
+ // total up all products without and with taxes based on shipping destination
+ if ( ! empty( self::$cart_contents )) foreach ( self::$cart_contents as $cart_item_key => $values ) {
+// the following isn't yet used as of 1.4.5, but might be what we implement
+ $_product = $values['data'];
+ $values['price_includes_tax'] = self::get_options()->get_option('jigoshop_prices_include_tax');
+ $values['unit_price'] = $_product->get_price_excluding_tax();
+ $values['discount'] = round( self::calculate_product_discounts_total( $_product, $values ), 2 );
+ if ( $values['discount'] > 0 && self::get_options()->get_option('jigoshop_tax_after_coupon') == 'yes' ) {
+ $values['unit_price'] -= $values['discount'];
}
-
- if ( self::get_options()->get_option('jigoshop_tax_after_coupon') == 'yes' ) {
-
- self::calculate_cart_discounts_total( $total_cart_price_ex_tax );
- $total_cart_discounts = self::$discount_total;
-
- if ( $total_cart_price_ex_tax > 0 ) {
- $percentage_discount = $percentage_discount - ( self::$discount_total / $total_cart_price_ex_tax );
- }
-
- } else { // Taxes are applied before coupons, 'jigoshop_tax_after_coupon' == 'no'
-
- self::calculate_cart_discounts_total( $total_cart_price_with_tax );
- $total_cart_discounts = self::$discount_total;
-
- if ( $total_cart_price_with_tax > 0 ) {
- $percentage_discount = $percentage_discount - ( self::$discount_total / $total_cart_price_with_tax );
- }
-
+ $this_tax = new jigoshop_tax( 100 );
+
+ if ( $_product->is_taxable() ) {
+ $this_tax->set_is_shipable( jigoshop_shipping::is_enabled() && $_product->requires_shipping() );
}
+ $this_tax->calculate_tax_amounts(
+ $values['unit_price'],
+ $_product->get_tax_classes(),
+ $values['price_includes_tax']
+ );
+ // following commented out, always the wrong answer
+// $values['tax'] = $this_tax->get_taxes_as_array( $this_tax->get_taxes_as_string() );
+ // this isn't right either, but ...
+ $values['tax'] = ($_product->get_price_with_tax() * $values['quantity']) - ($_product->get_price_excluding_tax() * $values['quantity']);
- }
-
- /* ===== End of calculations for cart (fixed_cart, percent, fixed_product) discounts ===== */
+// END of unused portion, the following is used
- // Used to determine how many iterations are left on the cart_contents. Applied with cart coupons
- $cart_contents_loop_count = count( self::$cart_contents );
-
+ $total_cart_price_ex_tax += $_product->get_price_excluding_tax() * $values['quantity'] ;
+ $total_cart_price_with_tax += $_product->get_price_with_tax() * $values['quantity'];
+
+ // the aim is to have all pertinent info attached to a cart item, not used as of 1.4.5
+// self::$cart_contents[$cart_item_key] = $values;
+ }
+
+ /*
+ * Loop through each product in the cart (for now, to be reworked post 1.4.5)
+ */
if ( ! empty( self::$cart_contents )) foreach ( self::$cart_contents as $cart_item_key => $values ) {
+ $cart_contents_loop_count--;
+
$_product = $values['data'];
-
+
self::$cart_contents_count += $values['quantity'];
- // current_product_discount is used for applying discount to a product and is only used with apply discount
- // before taxes. otherwise the discount doesn't get applied until calculating into the total
- $current_product_discount = 0;
-
- // Product Discounts for specific product ID's
- if ( ! empty( self::$applied_coupons )) foreach ( self::$applied_coupons as $code ) {
-
- $coupon = JS_Coupons::get_coupon( $code );
-
- if ( ! JS_Coupons::is_valid_coupon_for_product( $code, $values ) ) continue;
-
- switch ( $coupon['type'] ) {
- case 'fixed_product' :
- $current_product_discount = ( $coupon['amount'] * $values['quantity'] );
- break;
-
- case 'percent_product' :
- $current_product_discount = (((
- self::get_options()->get_option('jigoshop_tax_after_coupon') == 'yes'
- ? $values['data']->get_price_excluding_tax( $values['quantity'] )
- /*: $values['data']->get_price() * $values['quantity']*/
- : $values['data']->get_price_with_tax( $values['quantity'] ) // should be something like this?
- ) / 100 ) * $coupon['amount'] );
- break;
- }
-
- self::$discount_total += $current_product_discount;
-
- }
-
- // Time to calculate discounts into a discounted item price
+ $current_product_discount = self::calculate_product_discounts_total( $_product, $values );
+ self::$discount_total += $current_product_discount;
+
$discounted_item_price = -1;
$cart_discount_amount = 0;
- if ( self::get_options()->get_option('jigoshop_calc_taxes') == 'yes' && ! empty( self::$applied_coupons ) ) {
- if ( self::get_options()->get_option('jigoshop_tax_after_coupon') == 'yes' ) {
-
- $discounted_item_price = round( $_product->get_price_excluding_tax($values['quantity']) - $current_product_discount, 2 );
-
- if ( $discounted_item_price > 0 && $total_cart_discounts > 0 ) {
-
- $cart_discount_amount =
- $cart_contents_loop_count == 1
- ? $total_cart_discounts
- : $discounted_item_price - round( $discounted_item_price * $percentage_discount, 2 );
- $total_cart_discounts -= $cart_discount_amount;
-
- if ( $cart_contents_loop_count == 1 && $cart_discount_amount > $discounted_item_price )
- self::$cart_discount_leftover = $cart_discount_amount - $discounted_item_price; // to use with shipping cost
-
- $discounted_item_price = ( $cart_discount_amount > $discounted_item_price ? 0 : $discounted_item_price - $cart_discount_amount );
-
- }
-
- $cart_contents_loop_count--;
-
- } else { // Taxes are applied before coupons, 'jigoshop_tax_after_coupon' == 'no'
-
- $discounted_item_price = round( $_product->get_price_with_tax( $values['quantity'] ) - $current_product_discount, 2 );
-
- if ( $discounted_item_price > 0 && $total_cart_discounts > 0 ) {
+ $discounted_item_price = round( $_product->get_price_excluding_tax() * $values['quantity'] - $current_product_discount, 2 );
+
+ if ( $discounted_item_price > 0 && $total_cart_discounts > 0 ) {
- $cart_discount_amount =
- $cart_contents_loop_count == 1
- ? $total_cart_discounts
- : $discounted_item_price - round( $discounted_item_price * $percentage_discount, 2 );
- $total_cart_discounts -= $cart_discount_amount;
+ $cart_discount_amount =
+ $cart_contents_loop_count == 1
+ ? $total_cart_discounts
+ : $discounted_item_price - round( $discounted_item_price * $percentage_discount, 2 );
+ $total_cart_discounts -= $cart_discount_amount;
- if ( $cart_contents_loop_count == 1 && $cart_discount_amount > $discounted_item_price )
- self::$cart_discount_leftover = $cart_discount_amount - $discounted_item_price; // to use with shipping cost
+ if ( $cart_contents_loop_count == 1 && $cart_discount_amount > $discounted_item_price )
+ self::$cart_discount_leftover = $cart_discount_amount - $discounted_item_price; // to use with shipping cost
- $discounted_item_price = ( $cart_discount_amount > $discounted_item_price ? 0 : $discounted_item_price - $cart_discount_amount );
+ $discounted_item_price = ( $cart_discount_amount > $discounted_item_price ? 0 : $discounted_item_price - $cart_discount_amount );
- }
- $cart_contents_loop_count--;
-
- }
-
}
-
-
+
+ $cart_contents_loop_count--;
+
+
$total_item_price = $_product->get_price() * $values['quantity'] * 100;
if ( self::get_options()->get_option('jigoshop_calc_taxes') == 'yes' ) {
@@ -581,86 +572,66 @@ private static function calculate_cart_total() {
$tax_classes_applied = array();
if ( $_product->is_taxable() ) {
-
+
$shipable = jigoshop_shipping::is_enabled() && $_product->requires_shipping();
self::$tax->set_is_shipable( $shipable );
-
- // prices include tax only when customer outside of base but within same country
+
if ( self::get_options()->get_option('jigoshop_prices_include_tax') == 'yes'
&& jigoshop_customer::is_customer_outside_base( $shipable )
) {
- $total_item_price = $_product->get_price_excluding_tax( $values['quantity'] ) * 100;
- $product_discounted_price = $discounted_item_price > 0 ? $discounted_item_price * 100 : $total_item_price;
-
- // the reason there is a return value
+ $total_item_price = $_product->get_price_with_tax() * $values['quantity'] * 100;
// tax_classes_applied is for special email processing
// that needs to know what tax classes (%) were applied to each product.
// Specifically for Norway. Others may utilize it too
$tax_classes_applied = self::$tax->calculate_tax_amounts(
- $product_discounted_price,
+ $total_item_price,
$_product->get_tax_classes(),
false
);
-
- // add customer taxes back into the total item price, customer is outside base and we asked to have prices include taxes
- // keep tax with multiplier
- $total_item_price += ((self::$tax->get_non_compounded_tax_amount() + self::$tax->get_compound_tax_amount()) * 100);
} else { // all other scenarios
-
- // always use false for price includes tax when calculating tax after coupon = yes, as the price is excluding tax
+
$price_includes_tax =
self::get_options()->get_option('jigoshop_tax_after_coupon') == 'yes'
&& ($cart_discount_amount > 0 || $current_product_discount > 0)
? false
: self::get_options()->get_option('jigoshop_prices_include_tax') == 'yes';
-
- $product_discounted_price = (self::get_options()->get_option('jigoshop_tax_after_coupon') == 'yes'
+
+ $product_discounted_price = (self::get_options()->get_option('jigoshop_tax_after_coupon') == 'yes'
&& ($cart_discount_amount > 0 || $current_product_discount > 0)
? $discounted_item_price * 100
: $total_item_price);
+
$tax_classes_applied = self::$tax->calculate_tax_amounts(
$product_discounted_price,
$_product->get_tax_classes(),
$price_includes_tax
);
-
- // if coupons are applied and also applied before taxes but prices include tax, we need to re-adjust total
- // item price according to new tax rate.
+
if ( self::get_options()->get_option('jigoshop_prices_include_tax') == 'yes') {
- // TODO: why is this happening? First off, if prices_include_tax == 'yes' total_item_price is already tax in.. see above where it's set.
- // so if we do get_price_with_tax...what's the difference? I don't see the need. I think we really want
- // $total_item_price = discounted_item_price + taxes that have been just calculated, otherwise i don't see the need
- // to check if discounted_item_price is > 0 in the first place if all we want to do is get the product price with tax in.
if (self::get_options()->get_option('jigoshop_tax_after_coupon') == 'yes' && $discounted_item_price >= 0) {
- //$total_item_price = $_product->get_price_with_tax( $values['quantity'] ) * 100;
-
- // add new tax amounts back into the discounted item price since we are using the option catalogue includes tax
- // and only when customer is taxable... taxes will be 0 if customer is not taxable, so we can just blindly add them here
+
$total_item_price = ($discounted_item_price + self::$tax->get_non_compounded_tax_amount() + self::$tax->get_compound_tax_amount()) * 100;
+
}
// adjust total_item_price for customers that are not in the taxable shop country... this is definitely needed.
else if (!jigoshop_customer::is_taxable($shipable)) {
- $total_item_price = $_product->get_price_excluding_tax($values['quantity']) * 100;
+ $total_item_price = $_product->get_price_excluding_tax() * $values['quantity'] * 100;
}
- } else {
-
- // need to check for something here? -JAP-
-
}
-
+
}
-
- // reason we cannot use get_applied_tax_classes is because we may not have applied
- // all tax classes for this product. get_applied_tax_classes will return all of the tax
- // classes that have been applied on all products
+
+
+ // reason we cannot use get_applied_tax_classes is because we may not have applied all tax classes for this product.
+ // get_applied_tax_classes will return all of the tax classes that have been applied on all products
foreach ( $tax_classes_applied as $tax_class ) {
- $price_ex_tax = $_product->get_price_excluding_tax($values['quantity']);
+ $price_ex_tax = $_product->get_price_excluding_tax() * $values['quantity'];
if ( isset(self::$price_per_tax_class_ex_tax[$tax_class]) )
self::$price_per_tax_class_ex_tax[$tax_class] += $price_ex_tax;
@@ -668,11 +639,9 @@ private static function calculate_cart_total() {
self::$price_per_tax_class_ex_tax[$tax_class] = $price_ex_tax;
}
-
}
-
}
-
+
$total_item_price = $total_item_price / 100;
/* Apply weight only to non-downloadable products. */
@@ -684,7 +653,8 @@ private static function calculate_cart_total() {
}
self::$cart_contents_total += $total_item_price;
- self::$cart_contents_total_ex_tax = self::$cart_contents_total_ex_tax + ($_product->get_price_excluding_tax( $values['quantity'] ));
+ self::$cart_contents_total_ex_tax += $_product->get_price_excluding_tax() * $values['quantity'];
+
}
@@ -709,7 +679,6 @@ function calculate_totals() {
if (self::get_options()->get_option('jigoshop_calc_taxes') == 'yes') :
self::$shipping_tax_total = jigoshop_shipping::get_tax();
- //TODO: figure this out with new shipping taxes
self::$tax->update_tax_amount_with_shipping_tax(self::$shipping_tax_total * 100);
$shipping_tax_classes = self::$tax->get_shipping_tax_classes();
@@ -728,24 +697,81 @@ function calculate_totals() {
self::$subtotal_ex_tax = self::$cart_contents_total_ex_tax;
self::$subtotal = self::$cart_contents_total;
- // This can go once all shipping methods use the new tax structure
if (self::get_options()->get_option('jigoshop_calc_taxes') == 'yes' && !self::$tax->get_total_shipping_tax_amount()) :
foreach (self::get_applied_tax_classes() as $tax_class) :
if (!self::is_not_compounded_tax($tax_class)) : //tax compounded
$discount = (self::get_options()->get_option('jigoshop_tax_after_coupon') == 'yes' ? self::$discount_total : 0);
- // always want prices excluding taxes when updating the tax here, so therefore use the static instance variables rather than the helper methods
self::$tax->update_tax_amount($tax_class, (self::$subtotal_ex_tax - $discount + self::$tax->get_non_compounded_tax_amount() + self::$shipping_total) * 100);
endif;
endforeach;
endif;
+
+ self::$total = self::get_cart_subtotal(false) + self::get_cart_shipping_total(false);
+ if ( self::get_options()->get_option('jigoshop_calc_taxes') == 'yes'
+ && self::get_options()->get_option('jigoshop_prices_include_tax') == 'no'
+ && self::get_options()->get_option('jigoshop_tax_after_coupon') == 'no' ) {
+
+ self::$total += self::$tax->get_non_compounded_tax_amount() + self::$tax->get_compound_tax_amount();
+ }
+
+ // calculate any cart wide discounts from coupons
+ $total_product_discounts = self::$discount_total;
+ $total_cart_discounts = 0;
+ $temp = 0;
+ if ( self::get_options()->get_option('jigoshop_tax_after_coupon') == 'yes' ) {
+
+ // we need products and shipping with tax out
+ $total_cart_discounts = round( self::calculate_cart_discounts_total(
+ self::$cart_contents_total_ex_tax + self::get_cart_shipping_total(false,true)), 2 );
+ if ( $total_cart_discounts > 0 ) {
+ foreach ( self::get_applied_tax_classes() as $tax_class ) {
+ // recalc tax based on discounts
+ $rate = self::$tax->get_rate($tax_class);
+ $tax = self::$tax->calc_tax(
+ self::$cart_contents_total_ex_tax + self::$shipping_total - $total_cart_discounts - $total_product_discounts, $rate, false
+ );
+ self::$tax->update_tax_amount( $tax_class, $tax * 100, false, true );
+ $temp += self::$tax->get_tax_amount($tax_class);
+ }
+ } else {
+ foreach ( self::get_applied_tax_classes() as $tax_class ) {
+ // otherwise use existing tax
+ $temp += self::$tax->get_tax_amount($tax_class);
+ }
+ }
+
+ if ( self::get_options()->get_option('jigoshop_prices_include_tax') == 'no' ) {
+ self::$total += $temp;
+ } else {
+ self::$total = self::$cart_contents_total_ex_tax + self::$shipping_total + $temp;
+ }
+ } else { // Taxes are applied before coupons, 'jigoshop_tax_after_coupon' == 'no'
- self::$total = self::get_cart_subtotal(false) + self::get_cart_shipping_total(false) - self::$discount_total;
-
- if (self::get_options()->get_option('jigoshop_calc_taxes') == 'yes' && self::get_options()->get_option('jigoshop_display_totals_tax') == 'no') :
- self::$total += self::$tax->get_non_compounded_tax_amount() + self::$tax->get_compound_tax_amount();
- endif;
-
+ if ( self::get_options()->get_option('jigoshop_prices_include_tax') == 'no' ) {
+ $total_cart_discounts = self::calculate_cart_discounts_total( self::$total );
+ } else {
+ $total_cart_discounts = self::calculate_cart_discounts_total( self::$cart_contents_total_ex_tax + self::$shipping_total );
+ if ( $total_cart_discounts > 0 ) {
+ // with an initial discount, recalc taxes and get a proper discount
+ foreach ( self::get_applied_tax_classes() as $tax_class ) {
+ $rate = self::$tax->get_rate($tax_class);
+ $tax = self::$tax->calc_tax(
+ self::$cart_contents_total_ex_tax + self::$shipping_total, $rate, false
+ );
+ self::$tax->update_tax_amount( $tax_class, $tax * 100, false, true );
+ $temp += self::$tax->get_tax_amount($tax_class);
+ }
+ $total_cart_discounts = self::calculate_cart_discounts_total( self::$cart_contents_total_ex_tax + self::$shipping_total + $temp );
+ }
+ }
+ }
+
+ // self::$discount_total already contains product discounts
+ self::$discount_total += $total_cart_discounts;
+
+ // adjust the grand total after all discounts
+ self::$total -= self::$discount_total;
if ( self::$total < 0 ) self::$total = 0;
// with everything calculated, check that coupons depending on cart totals are still valid
@@ -807,30 +833,37 @@ public static function get_cart_subtotal( $for_display = true, $apply_discount_a
*/
if ( self::get_options()->get_option('jigoshop_calc_taxes') == 'yes' ) :
- /* Don't show the discount bit in the subtotal because discount will be calculated after taxes, thus in the grand total (not the subtotal). */
- if ( self::get_options()->get_option('jigoshop_tax_after_coupon') == 'yes' )
- $discount = 0;
-
- /* Cart total excludes taxes. */
- if ( self::get_options()->get_option('jigoshop_display_totals_tax') == 'no' || $order_exclude_tax ) :
+// if ( self::get_options()->get_option('jigoshop_display_totals_tax') == 'no' || $order_exclude_tax ) :
+ // for final Orders in the Admin we always need tax out
+ if ( $order_exclude_tax ) :
$subtotal = self::get_options()->get_option('jigoshop_prices_include_tax') == 'yes' ? self::$subtotal_ex_tax : $subtotal;
$tax_label = 1; //ex. tax
else :
- /* Cart total includes taxes. */
- $subtotal = self::get_options()->get_option('jigoshop_prices_include_tax') == 'yes' ? $subtotal : self::$subtotal_ex_tax + self::get_total_cart_tax_without_shipping_tax();
- $tax_label = 2; //inc. tax
+ if ( self::get_options()->get_option('jigoshop_prices_include_tax') == 'yes' ) {
+ $tax_label = 2; //inc. tax
+ } else {
+ $subtotal = self::$subtotal_ex_tax;
+ $tax_label = 1; //inc. tax
+ }
endif;
endif;
+ // Don't show the discount bit in the subtotal because discount will be calculated after taxes
+ // thus in the grand total (not the subtotal). */
+ if ( self::get_options()->get_option('jigoshop_tax_after_coupon') == 'yes' ) {
+ $discount = 0;
+ }
+
/* Display totals with discount & shipping applied? */
if ( $apply_discount_and_shipping ) :
- $subtotal = $subtotal + self::$shipping_total;
+ $subtotal = $subtotal + jigoshop_cart::get_cart_shipping_total( false );
/* Check if the discount is greater than our total first. */
- $subtotal = ( $discount > $subtotal ) ? $subtotal : $subtotal + $discount;
+ // NOTE: this is broken when called from process checkout and assigning to $order->order_discount_subtotal
+ $subtotal = ( $discount > $subtotal ) ? $subtotal : $subtotal - $discount;
endif;
@@ -869,8 +902,8 @@ public function show_retail_price($order = '') {
if ( self::get_options()->get_option('jigoshop_calc_taxes') != 'yes' )
return false;
- if ( self::get_options()->get_option('jigoshop_display_totals_tax') != 'no' )
- return false;
+// if ( self::get_options()->get_option('jigoshop_display_totals_tax') != 'no' )
+// return false;
return ( jigoshop_cart::has_compound_tax() || jigoshop_cart::tax_after_coupon() );
@@ -946,7 +979,7 @@ public static function get_cart_shipping_total($for_display = true, $order_exclu
if ( self::get_options()->get_option('jigoshop_calc_taxes') == 'no' )
return ($for_display ? jigoshop_price(self::$shipping_total) : number_format(self::$shipping_total, 2, '.', ''));
- if ( self::get_options()->get_option('jigoshop_display_totals_tax') == 'no' || $order_exclude_tax ) {
+ if ( self::get_options()->get_option('jigoshop_prices_include_tax') == 'no' || $order_exclude_tax ) {
$return = ($for_display ? jigoshop_price(self::$shipping_total) : number_format(self::$shipping_total, 2, '.', ''));
@@ -1057,14 +1090,6 @@ function valid_coupon($coupon_code) {
}
}
- /* See if coupon is already applied. */
- // NOTE: disengaging for Jigoshop 1.4.2, silent carry on if coupon already applied, no error message needed
- // we will check on 'add_discount' if coupon is already applied and won't add it if it is
-// if ( self::has_discount($coupon_code) && !empty($_POST['coupon_code']) ) {
-// jigoshop::add_error(__('Discount code already applied!', 'jigoshop'));
-// return false;
-// }
-
// Check it can be used with cart
// get_coupon() checks for valid coupon code. don't go any further without one
if (!JS_Coupons::get_coupon($coupon_code)) {
@@ -1078,13 +1103,6 @@ function valid_coupon($coupon_code) {
return false;
}
- // if it's a percentage discount for products, make sure it's for a specific product, not all products
- // NOTE: disengaging for Jigoshop 1.4.2, there should be no need to restrict this coupon type to specific products
-// if ($the_coupon['type'] == 'percent_product' && sizeof($the_coupon['include_products']) == 0) {
-// jigoshop::add_error(__('Invalid coupon!', 'jigoshop'));
-// return false;
-// }
-
return true;
}
@@ -1123,13 +1141,19 @@ function has_discount($code) {
/** Returns the total discount amount. */
function get_total_discount() {
- if (!self::$discount_total)
+ if ( empty( self::$discount_total ) )
return false;
- $subtotal = jigoshop_cart::get_cart_subtotal(false, true);
+ $total = self::get_cart_subtotal(false) + self::get_cart_shipping_total(false);
+
+ if ( self::get_options()->get_option('jigoshop_calc_taxes') == 'yes'
+ && self::get_options()->get_option('jigoshop_prices_include_tax') == 'no') {
+
+ $total += self::$tax->get_non_compounded_tax_amount() + self::$tax->get_compound_tax_amount();
+ }
$discount = self::$discount_total;
- return ( $discount > $subtotal )
- ? jigoshop_price($subtotal)
+ return ( $discount > $total )
+ ? jigoshop_price($total)
: jigoshop_price($discount);
}
View
21 classes/jigoshop_checkout.class.php
@@ -226,9 +226,11 @@ function checkout_form_shipping() {
// Shipping Details
if (!jigoshop_cart::ship_to_billing_address_only() && self::get_options()->get_option('jigoshop_calc_shipping') == 'yes') :
- $shiptobilling = !$_POST ? apply_filters('shiptobilling_default', 1) : $this->get_value('shiptobilling'); ?>
-
- <p class="form-row" id="shiptobilling"><input class="input-checkbox" type="checkbox" name="shiptobilling" id="shiptobilling-checkbox" <?php if ($shiptobilling) : ?> checked="checked" <?php endif; ?> /> <label for="shiptobilling-checkbox" class="checkbox"><?php _e('Ship to same address?', 'jigoshop'); ?></label> </p>
+ $shiptobilling = !$_POST ? apply_filters('shiptobilling_default', 1) : $this->get_value('shiptobilling');
+ $shiptodisplay = self::get_options()->get_option('jigoshop_ship_to_billing_address_only') == 'yes' ? 'checked="checked"' : '';
+ ?>
+
+ <p class="form-row" id="shiptobilling"><input class="input-checkbox" type="checkbox" name="shiptobilling" id="shiptobilling-checkbox" <?php if ($shiptobilling) : echo $shiptodisplay; endif; ?> /> <label for="shiptobilling-checkbox" class="checkbox"><?php _e('Ship to billing address?', 'jigoshop'); ?></label> </p>
<h3><?php _e('Shipping Address', 'jigoshop'); ?></h3>
@@ -406,7 +408,7 @@ function process_checkout() {
// Process Discount Codes
if ( !empty( $_POST['coupon_code'] ) ) {
- $coupon_code = stripslashes(trim($_POST['coupon_code']));
+ $coupon_code = sanitize_title( $_POST['coupon_code'] );
jigoshop_cart::add_discount($coupon_code);
}
@@ -705,7 +707,7 @@ function process_checkout() {
$data['payment_method'] = $this->posted['payment_method'];
$data['payment_method_title'] = !empty($available_gateways[$this->posted['payment_method']]) ?$available_gateways[$this->posted['payment_method']]->title : '';
$data['order_subtotal'] = jigoshop_cart::get_cart_subtotal(false, false, true);/* no display, no shipping, no tax */
- $data['order_discount_subtotal']= jigoshop_cart::get_cart_subtotal(false, true, true);/* no display, with shipping/discounts, no tax */
+ $data['order_discount_subtotal']= jigoshop_cart::get_cart_subtotal(false, false, true)-jigoshop_cart::$discount_total;
$data['order_shipping'] = jigoshop_cart::get_cart_shipping_total(false, true);
$data['order_discount'] = number_format(jigoshop_cart::$discount_total, 2, '.', '');
$data['order_tax'] = jigoshop_cart::get_taxes_as_string();
@@ -759,7 +761,7 @@ function process_checkout() {
'customization' => $custom,
'name' => $_product->get_title(),
'qty' => (int) $values['quantity'],
- 'cost' => $_product->get_price_excluding_tax((int) $values['quantity']),
+ 'cost' => $_product->get_price_excluding_tax() * (int) $values['quantity'],
'cost_inc_tax' => $price_inc_tax, // if less than 0 don't use this
'taxrate' => $rate
), $values);
@@ -935,14 +937,15 @@ static function get_shipping_dropdown() {
$tax_label = 0; // 0 no label, 1 ex. tax, 2 inc. tax
$price = 0;
- if (self::get_options()->get_option('jigoshop_display_totals_tax') == 'yes' ) {
+ if (self::get_options()->get_option('jigoshop_prices_include_tax') == 'yes' ) {
// check that shipping is indeed taxed.
if (jigoshop_cart::$shipping_tax_total > 0) {
- $tax_label = 2; // inc. tax
+ $tax_label = 1; // inc. tax
}
- $price = $method->get_selected_price($i) + $method->get_selected_tax($i);
+// $price = $method->get_selected_price($i) + $method->get_selected_tax($i);
+ $price = $method->get_selected_price($i);
}
else {
View
11 classes/jigoshop_customer.class.php
@@ -186,6 +186,17 @@ public static function get_shipping_country() {
if (self::get_customer_session('shipping_country')) return self::get_customer_session('shipping_country');
}
+ /** Gets the country and state from the current session for cart shipping display */
+ public static function get_shipping_country_or_state() {
+ if (self::get_customer_session('shipping_country')) {
+ if (self::get_customer_session('shipping_state')) {
+ return jigoshop_countries::$states[self::get_customer_session('shipping_country')][self::get_customer_session('shipping_state')];
+ } else {
+ return jigoshop_countries::$countries[self::get_customer_session('shipping_country')];
+ }
+ }
+ }
+
/** Gets the postcode from the current session */
public static function get_shipping_postcode() {
if (self::get_customer_session('shipping_postcode')) return strtolower(str_replace(' ', '', self::get_customer_session('shipping_postcode')));
View
24 classes/jigoshop_options.class.php
@@ -258,7 +258,7 @@ public function update_options() {
*/
public function add_option( $name, $value ) {
// take care of keeping the old name updated when setting new options
- update_option($name, $value);
+ add_option($name, $value);
$this->get_current_options();
if ( ! isset( self::$current_options[$name] )) {
@@ -568,6 +568,7 @@ private function set_default_options() {
'ILS' => __('Israeli Shekel (&#8362;)', 'jigoshop'),
'INR' => __('Indian Rupee (&#8360;)', 'jigoshop'),
'JPY' => __('Japanese Yen (&yen;)', 'jigoshop'),
+ 'KES' => __('Kenyan Shilling (KSh)', 'jigoshop'),
'MXN' => __('Mexican Peso (&#36;)', 'jigoshop'),
'MYR' => __('Malaysian Ringgits (RM)', 'jigoshop'),
'NGN' => __('Nigerian Naira (&#8358;)', 'jigoshop'),
@@ -1508,7 +1509,7 @@ private function set_default_options() {
self::$default_options[] = array(
'name' => __('Apply Taxes After Coupon','jigoshop'),
- 'desc' => '',
+ 'desc' => __('This will have no effect if Calculate Taxes is turned off.','jigoshop'),
'tip' => __('If yes, taxes get applied after coupons. When no, taxes get applied before coupons.','jigoshop'),
'id' => 'jigoshop_tax_after_coupon',
'std' => 'yes',
@@ -1521,8 +1522,8 @@ private function set_default_options() {
self::$default_options[] = array(
'name' => __('Catalog Prices include tax?','jigoshop'),
- 'desc' => '',
- 'tip' => __('If prices include tax then tax calculations will work backwards.','jigoshop'),
+ 'desc' => __('This will only apply to the Shop, Category and Product pages.','jigoshop'),
+ 'tip' => __('This will have no effect on the Cart, Checkout, Emails, or final Orders; prices are always shown with tax out.','jigoshop'),
'id' => 'jigoshop_prices_include_tax',
'std' => 'yes',
'type' => 'checkbox',
@@ -1533,19 +1534,6 @@ private function set_default_options() {
);
self::$default_options[] = array(
- 'name' => __('Subtotals include tax?','jigoshop'),
- 'desc' => '',
- 'tip' => __('Should any subtotals be shown including or excluding tax on the Cart and Checkout? This will include Shipping subtotals.','jigoshop'),
- 'id' => 'jigoshop_display_totals_tax',
- 'std' => 'no',
- 'type' => 'checkbox',
- 'choices' => array(
- 'no' => __('No', 'jigoshop'),
- 'yes' => __('Yes', 'jigoshop')
- )
- );
-
- self::$default_options[] = array(
'name' => __('Additional Tax classes','jigoshop'),
'desc' => __('List 1 per line. This is in addition to the default <em>Standard Rate</em>.','jigoshop'),
'tip' => __('List product and shipping tax classes here, e.g. Zero Tax, Reduced Rate.','jigoshop'),
@@ -1600,7 +1588,7 @@ private function set_default_options() {
self::$default_options[] = array(
'name' => __('Only ship to billing address?','jigoshop'),
'desc' => '',
- 'tip' => '',
+ 'tip' => __('When activated, Shipping address fields will not appear on the Checkout.','jigoshop'),
'id' => 'jigoshop_ship_to_billing_address_only',
'std' => 'no',
'type' => 'checkbox',
View
2  classes/jigoshop_order.class.php
@@ -252,7 +252,7 @@ function get_subtotal_to_display() {
$subtotal = jigoshop_price($this->order_subtotal);
- if ($this->order_tax>0) :
+ if ($this->order_tax>0 && self::get_options()->get_option( 'jigoshop_calc_taxes' ) == 'yes') :
$subtotal .= __(' <small>(ex. tax)</small>', 'jigoshop');
endif;
View
126 classes/jigoshop_product.class.php
@@ -466,8 +466,8 @@ public function get_stock() {
public function get_availability() {
- // Do not display availability if we aren't managing stock
- if ( self::get_options()->get_option('jigoshop_manage_stock') != 'yes' )
+ // Do not display initial availability if we aren't managing stock or if variable or grouped
+ if ( self::get_options()->get_option('jigoshop_manage_stock') != 'yes' || $this->is_type( array('grouped', 'variable')) )
return false;
// Start as in stock
@@ -489,7 +489,7 @@ public function get_availability() {
$notice['availability'] = $notice['availability'] .' ('.__('backorders allowed','jigoshop').')';
}
}
- else if ( $this->backorders_allowed() && $this->backorders_require_notification() ) {
+ else if ( $this->managing_stock() && $this->backorders_allowed() ) {
$notice['availability'] = __( 'Available on Backorder', 'jigoshop' );
}
@@ -619,7 +619,7 @@ function get_price_excluding_tax( $quantity = 1 ) {
endif;
endforeach;
-
+
// Product prices are always 2 decimal digits.
// Will get rounding errors on backwards tax calcs if we don't round
return round( ($price * $quantity - $tax_totals) / 100, 2 );
@@ -646,47 +646,38 @@ function get_price_excluding_tax( $quantity = 1 ) {
function get_price_with_tax( $quantity = 1 ) {
// to avoid rounding errors multiply by 100
- $price = $this->get_price() * 100;
+ $price = $this->get_price_excluding_tax() * 100;
+ $tax_totals = 0;
+ $rates = (array) $this->get_tax_destination_rate();
+
+ if ( count( $rates > 0 )) {
- if ( self::get_options()->get_option('jigoshop_prices_include_tax') == 'no' ) {
+ // rates array sorted so that taxes applied to retail value come first. To reverse taxes, need to reverse this array
+ $new_rates = array_reverse( $rates, true );
- $rates = (array) $this->get_tax_destination_rate();
-
- if ( count( $rates > 0 )) {
-
- // rates array sorted so that taxes applied to retail value come first. To reverse taxes, need to reverse this array
- $new_rates = array_reverse( $rates, true );
-
- $tax_applied_after_retail = 0;
- $tax_totals = 0;
-
- $_tax = new jigoshop_tax( 100 );
-
- foreach ( $new_rates as $key => $value ) {
-
- if ( $value['is_not_compound_tax'] ) {
- $tax_totals += $_tax->calc_tax(( $price * $quantity ) - $tax_applied_after_retail, $value['rate'], false );
- } else {
- $tax_amount[$key] = $_tax->calc_tax( $price * $quantity, $value['rate'], false );
- $tax_applied_after_retail += $tax_amount[$key];
- $tax_totals += $tax_amount[$key];
- }
-
+ $tax_applied_after_retail = 0;
+ $tax_totals = 0;
+
+ $_tax = new jigoshop_tax( 100 );
+
+ foreach ( $new_rates as $key => $value ) {
+
+ if ( $value['is_not_compound_tax'] ) {
+ $tax_totals += $_tax->calc_tax(( $price * $quantity ) - $tax_applied_after_retail, $value['rate'], false );
+ } else {
+ $tax_amount[$key] = $_tax->calc_tax( $price * $quantity, $value['rate'], false );
+ $tax_applied_after_retail += $tax_amount[$key];
+ $tax_totals += $tax_amount[$key];
}
-
- // Product prices are always 2 decimal digits.
- // Will get rounding errors on backwards tax calcs if we don't round
- return round( ($price * $quantity + $tax_totals) / 100, 2 );
-
+ $tax_totals = round( $tax_totals, 1 ); // without this we were getting rounding errors
+
}
-
- } else {
- // Product prices are always 2 decimal digits.
- // Will get rounding errors on backwards tax calcs if we don't round
- return round( $price * $quantity / 100, 2 );
-
- }
+ }
+
+ // Product prices are always 2 decimal digits.
+ // Will get rounding errors on backwards tax calcs if we don't round
+ return round( ($price * $quantity + $tax_totals) / 100, 2 );
}
@@ -811,11 +802,26 @@ public function get_price() {
}
/**
+ * Adjust the products price during runtime
+ *
+ * @param mixed
+ * @return void
+ */
+ public function adjust_price( $new_price ) {
+
+ // Only adjust sale price if we are on sale
+ if ( $this->is_on_sale() )
+ $this->sale_price = $this->get_price() + $new_price;
+ else
+ $this->regular_price += $new_price;
+ }
+
+ /**
* Returns the products sale value, either with or without a percentage
*
* @return html
*/
- public function calculate_sale_price() {
+ public function get_calculated_sale_price_html() {
if ( $this->is_on_sale() ) :
if ( strstr($this->sale_price,'%') )
@@ -824,25 +830,11 @@ public function calculate_sale_price() {
<br><ins>' . sprintf(__('%s off!', 'jigoshop'), $this->sale_price) . '</ins>';
else
return '
- <del>' . jigoshop_price( $this->regular_price ) . '</del>
- <ins>' . jigoshop_price( $this->sale_price ) . '</ins>';
+ <del>' . jigoshop_price( $this->regular_price ) . '</del>
+ <ins>' . jigoshop_price( $this->sale_price ) . '</ins>';
endif;
- }
-
- /**
- * Adjust the products price during runtime
- *
- * @param mixed
- * @return void
- */
- public function adjust_price( $new_price ) {
-
- // Only adjust sale price if we are on sale
- if($this->sale_price)
- $this->sale_price += $new_price;
-
- $this->regular_price += $new_price;
+ return '';
}
/**
@@ -861,11 +853,13 @@ public function get_price_html() {
return __( 'Unavailable', 'jigoshop' );
$array = array();
+ $onsale = false;
foreach ( $children as $child_ID ) {
$child = $this->get_child($child_ID);
// Only get prices that are in stock
if ( $child->is_in_stock() ) {
+ if ( $child->is_on_sale() ) $onsale = true; // signal at least one child is on sale
// store product id for later, get regular or sale price if available
$array[$child_ID] = $child->get_price();
}
@@ -881,7 +875,16 @@ public function get_price_html() {
$id = key( $array );
$child = $this->get_child( $id );
if ( $child->is_on_sale() )
- $html .= $child->calculate_sale_price();
+ $html .= $child->get_calculated_sale_price_html();
+ else
+ $html .= jigoshop_price( $child->regular_price );
+ elseif ( $onsale ) : // prices may be the same, but we could be on sale and need the 'From'
+ $html = '<span class="from">' . _x('From:', 'price', 'jigoshop') . '</span> ';
+ reset( $array );
+ $id = key( $array );
+ $child = $this->get_child( $id );
+ if ( $child->is_on_sale() )
+ $html .= $child->get_calculated_sale_price_html();
else
$html .= jigoshop_price( $child->regular_price );
else : // prices are the same
@@ -894,7 +897,7 @@ public function get_price_html() {
// For standard products
if ( $this->is_on_sale() )
- $html = $this->calculate_sale_price();
+ $html = $this->get_calculated_sale_price_html();
else
$html = jigoshop_price( $this->regular_price );
@@ -1106,7 +1109,8 @@ public function get_attributes() {
// Get the attributes
if ( ! $this->attributes )
- $this->attributes = maybe_unserialize( $this->meta['product_attributes'][0] );
+ if ( isset( $this->meta['product_attributes'] ) )
+ $this->attributes = maybe_unserialize( $this->meta['product_attributes'][0] );
return (array) $this->attributes;
}
View
4 classes/jigoshop_tax.class.php
@@ -647,7 +647,7 @@ public function update_tax_amount_with_shipping_tax($tax_amount) {
}
- public function update_tax_amount($tax_class, $amount, $recalculate_tax = true) {
+ public function update_tax_amount($tax_class, $amount, $recalculate_tax = true, $overwrite = false) {
if ($tax_class) :
@@ -663,6 +663,8 @@ public function update_tax_amount($tax_class, $amount, $recalculate_tax = true)
$rate = $this->get_rate($tax_class);
$tax = $this->calc_tax($amount, $rate, ($this->is_compound_tax() ? false : self::get_options()->get_option('jigoshop_prices_include_tax') == 'yes'));
$this->tax_amounts[$tax_class]['amount'] = $tax;
+ elseif ( $overwrite ) :
+ $this->tax_amounts[$tax_class]['amount'] = $amount;
else :
if ( isset($this->tax_amounts[$tax_class]['amount'])) :
$this->tax_amounts[$tax_class]['amount'] += $amount;
View
48 gateways/paypal.php
@@ -45,8 +45,6 @@ public function __construct() {
$this->testmode = Jigoshop_Base::get_options()->get_option('jigoshop_paypal_testmode');
$this->testmail = Jigoshop_Base::get_options()->get_option('jigoshop_sandbox_email');
- $this->send_shipping = Jigoshop_Base::get_options()->get_option('jigoshop_paypal_send_shipping');
-
add_action( 'init', array(&$this, 'check_ipn_response') );
add_action('valid-paypal-standard-ipn-request', array(&$this, 'successful_request') );
add_action( 'jigoshop_settings_scripts', array( &$this, 'admin_scripts' ) );
@@ -110,19 +108,6 @@ protected function get_default_options() {
);
$defaults[] = array(
- 'name' => __('Send shipping details to PayPal','jigoshop'),
- 'desc' => '',
- 'tip' => __('If your checkout page does not ask for shipping details, or if you do not want to send shipping information to PayPal, set this option to no. If you enable this option PayPal may restrict where things can be sent, and will prevent some orders going through for your protection.','jigoshop'),
- 'id' => 'jigoshop_paypal_send_shipping',
- 'std' => 'no',
- 'type' => 'checkbox',
- 'choices' => array(
- 'no' => __('No', 'jigoshop'),
- 'yes' => __('Yes', 'jigoshop')
- )
- );
-
- $defaults[] = array(
'name' => __('Force payment when free','jigoshop'),
'desc' => '',
'tip' => __('If product totals are free and shipping is also free (excluding taxes), this will force 0.01 to allow paypal to process payment. Shop owner is responsible for refunding customer.','jigoshop'),
@@ -268,29 +253,34 @@ public function generate_paypal_form( $order_id ) {
$paypal_args['tax'] = $order->get_total_tax();
$paypal_args['tax_cart'] = $order->get_total_tax();
- if ($this->send_shipping=='yes') :
+ // For Jigoshop 1.4.5 we will always send shipping information to paypal, even if it's just the billing info
+ // 'no_shipping' must ALWAYS be '1', as this will NOT allow paypal to prompt for an address
+ // 'address_override' MUST be '1' to allow addresses other than the paypal stored address for the customer
+ // These are the ONLY settings that Jigoshop can allow so that addresses can't be edited at paypal
+ // - which bypasses cart/checkout tax calcs for shipping destination
+ // If addresses ARE allowed to be edited at paypal, they will NOT appear in final orders
+ // Ultimately, the Jigoshop Checkout determines -all- addresses
+// if ($this->send_shipping=='yes') :
$paypal_args['no_shipping'] = 1;
$paypal_args['address_override'] = 1;
+ $paypal_args['first_name'] = $order->shipping_first_name;
+ $paypal_args['last_name'] = $order->shipping_last_name;
$paypal_args['address1'] = $order->shipping_address_1;
$paypal_args['address2'] = $order->shipping_address_2;
$paypal_args['city'] = $order->shipping_city;
$paypal_args['state'] = $order->shipping_state;
$paypal_args['zip'] = $order->shipping_postcode;
$paypal_args['country'] = $order->shipping_country;
- else :
- $paypal_args['no_shipping'] = 1;
- $paypal_args['address_override'] = 0;
- endif;
+// else :
+// $paypal_args['no_shipping'] = 1;
+// $paypal_args['address_override'] = 0;
+// endif;
// Cart Contents
$item_loop = 0;
if (sizeof($order->items)>0) : foreach ($order->items as $item) :
- if(!empty($item['variation_id'])) {
- $_product = new jigoshop_product_variation($item['variation_id']);
- } else {
- $_product = new jigoshop_product($item['id']);
- }
+ $_product = $order->get_product_from_item( $item );
if ($_product->exists() && $item['qty']) :
@@ -300,15 +290,9 @@ public function generate_paypal_form( $order_id ) {
//if variation, insert variation details into product title
if ($_product instanceof jigoshop_product_variation) {
- $variation_details = array();
- foreach ($_product->get_variation_attributes() as $name => $value) {
- $variation_details[] = ucfirst(str_replace('tax_', '', $name)) . ': ' . ucfirst($value);
- }
+ $title .= ' (' . jigoshop_get_formatted_variation( $item['variation'], true) . ')';
- if (count($variation_details) > 0) {
- $title .= ' (' . implode(', ', $variation_details) . ')';
- }
}
$paypal_args['item_name_'.$item_loop] = $title;
View
2  gateways/skrill.php
@@ -203,7 +203,7 @@ public function generate_skrill_form() {
$skrill_args['item_name_'.$item_loop]= $_product->get_title();
$skrill_args['quantity_'.$item_loop] = $item['qty'];
- $skrill_args['amount_'.$item_loop] = $_product->get_price_excluding_tax();
+ $skrill_args['amount_'.$item_loop] = $_product->get_price_with_tax();
endif;
endforeach; endif;