This commit is contained in:
Patrick Garman 2012-01-29 02:27:57 +00:00
commit cfa3a264c7
74 changed files with 12663 additions and 2041 deletions

View File

@ -63,20 +63,22 @@ function woocommerce_edit_product_columns($columns){
$columns["cb"] = "<input type=\"checkbox\" />";
$columns["thumb"] = __("Image", 'woocommerce');
$columns["title"] = __("Name", 'woocommerce');
if( get_option('woocommerce_enable_sku', true) == 'yes' ) $columns["sku"] = __("ID", 'woocommerce');
$columns["name"] = __("Name", 'woocommerce');
if (get_option('woocommerce_enable_sku', true) == 'yes')
$columns["sku"] = __("SKU", 'woocommerce');
$columns["product_type"] = __("Type", 'woocommerce');
$columns["product_cat"] = __("Categories", 'woocommerce');
$columns["product_tags"] = __("Tags", 'woocommerce');
$columns["featured"] = __("Featured", 'woocommerce');
if (get_option('woocommerce_manage_stock')=='yes') :
if (get_option('woocommerce_manage_stock')=='yes')
$columns["is_in_stock"] = __("In Stock?", 'woocommerce');
endif;
$columns["price"] = __("Price", 'woocommerce');
$columns["product_date"] = __("Date", 'woocommerce');
$columns["date"] = __("Date", 'woocommerce');
return $columns;
}
@ -85,11 +87,11 @@ function woocommerce_edit_product_columns($columns){
/**
* Custom Columns for Products page
**/
add_action('manage_product_posts_custom_column', 'woocommerce_custom_product_columns', 2);
add_action('manage_product_posts_custom_column', 'woocommerce_custom_product_columns', 2 );
function woocommerce_custom_product_columns($column) {
function woocommerce_custom_product_columns( $column ) {
global $post, $woocommerce;
$product = new Woocommerce_Product($post->ID);
$product = new WC_Product($post->ID);
switch ($column) {
case "thumb" :
@ -97,6 +99,79 @@ function woocommerce_custom_product_columns($column) {
echo get_the_post_thumbnail($post->ID, 'shop_thumbnail');
endif;
break;
case "name" :
$edit_link = get_edit_post_link( $post->ID );
$title = _draft_or_post_title();
$post_type_object = get_post_type_object( $post->post_type );
$can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID );
echo '<strong><a class="row-title" href="'.$edit_link.'">' . $title.'</a>';
_post_states( $post );
echo '</strong>';
if ( $post->post_parent > 0 )
echo '&nbsp;&nbsp;&larr; <a href="'. get_edit_post_link($post->post_parent) .'">'. get_the_title($post->post_parent) .'</a>';
// Get actions
$actions = array();
$actions['id'] = 'ID: #' . $post->ID;
if ( $can_edit_post && 'trash' != $post->post_status ) {
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
}
if ( current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) {
if ( 'trash' == $post->post_status )
$actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
elseif ( EMPTY_TRASH_DAYS )
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
}
if ( $post_type_object->public ) {
if ( in_array( $post->post_status, array( 'pending', 'draft' ) ) ) {
if ( $can_edit_post )
$actions['view'] = '<a href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
} elseif ( 'trash' != $post->post_status ) {
$actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
}
}
$actions = apply_filters( 'post_row_actions', $actions, $post );
echo '<div class="row-actions">';
$i = 0;
$action_count = sizeof($actions);
foreach ( $actions as $action => $link ) {
++$i;
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
echo "<span class='$action'>$link$sep</span>";
}
echo '</div>';
get_inline_data( $post );
break;
case "sku" :
echo $product->get_sku();
break;
case "product_type" :
if( $product->product_type == 'grouped' ):
echo __('Grouped', 'woocommerce');
elseif ( $product->product_type == 'external' ):
echo __('External/Affiliate', 'woocommerce');
elseif ( $product->product_type == 'simple' ):
echo __('Simple', 'woocommerce');
elseif ( $product->product_type == 'variable' ):
echo __('Variable', 'woocommerce');
else:
// Assuming that we have other types in future
echo ucwords($product->product_type);
endif;
break;
case "price":
echo $product->get_price_html();
break;
@ -106,89 +181,23 @@ function woocommerce_custom_product_columns($column) {
case "product_tags" :
if (!$terms = get_the_term_list($post->ID, 'product_tag', '', ', ','')) echo '<span class="na">&ndash;</span>'; else echo $terms;
break;
case "sku" :
if ( $sku = get_post_meta( $post->ID, '_sku', true )) :
echo '#'.$post->ID.' - SKU: ' . $sku;
else :
echo '#'.$post->ID;
endif;
break;
case "featured" :
$url = wp_nonce_url( admin_url('admin-ajax.php?action=woocommerce-feature-product&product_id=' . $post->ID), 'woocommerce-feature-product' );
echo '<a href="'.$url.'" title="'.__('Change', 'woocommerce') .'">';
if ($product->is_featured()) echo '<a href="'.$url.'"><img src="'.$woocommerce->plugin_url().'/assets/images/success.gif" alt="yes" />';
else echo '<img src="'.$woocommerce->plugin_url().'/assets/images/success-off.gif" alt="no" />';
if ($product->is_featured()) echo '<a href="'.$url.'"><img src="'.$woocommerce->plugin_url().'/assets/images/success.png" alt="yes" />';
else echo '<img src="'.$woocommerce->plugin_url().'/assets/images/success-off.png" alt="no" />';
echo '</a>';
break;
case "is_in_stock" :
if ( !$product->is_type( 'grouped' ) && $product->is_in_stock() ) :
echo '<img src="'.$woocommerce->plugin_url().'/assets/images/success.gif" alt="yes" /> ';
echo '<img src="'.$woocommerce->plugin_url().'/assets/images/success.png" alt="yes" /> ';
else :
echo '<img src="'.$woocommerce->plugin_url().'/assets/images/success-off.gif" alt="no" /> ';
echo '<img src="'.$woocommerce->plugin_url().'/assets/images/success-off.png" alt="no" /> ';
endif;
if ( $product->managing_stock() ) :
echo $product->get_total_stock().__(' in stock', 'woocommerce');
echo '&times; ' . $product->get_total_stock();
endif;
break;
case "product_type" :
// Its was dynamic but did not support the translations
if( $product->product_type == 'grouped' ):
echo __('Grouped product', 'woocommerce');
elseif ( $product->product_type == 'external' ):
echo __('External/Affiliate product', 'woocommerce');
elseif ( $product->product_type == 'simple' ):
echo __('Simple product', 'woocommerce');
elseif ( $product->product_type == 'variable' ):
echo __('Variable', 'woocommerce');
else:
// Assuming that we have other types in future
echo ucwords($product->product_type);
endif;
break;
case "product_date" :
if ( '0000-00-00 00:00:00' == $post->post_date ) :
$t_time = $h_time = __( 'Unpublished', 'woocommerce' );
$time_diff = 0;
else :
$t_time = get_the_time( __( 'Y/m/d g:i:s A', 'woocommerce' ) );
$m_time = $post->post_date;
$time = get_post_time( 'G', true, $post );
$time_diff = time() - $time;
if ( $time_diff > 0 && $time_diff < 24*60*60 )
$h_time = sprintf( __( '%s ago', 'woocommerce' ), human_time_diff( $time ) );
else
$h_time = mysql2date( __( 'Y/m/d', 'woocommerce' ), $m_time );
endif;
echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post ) . '</abbr><br />';
if ( 'publish' == $post->post_status ) :
_e( 'Published', 'woocommerce' );
elseif ( 'future' == $post->post_status ) :
if ( $time_diff > 0 ) :
echo '<strong class="attention">' . __( 'Missed schedule', 'woocommerce' ) . '</strong>';
else :
_e( 'Scheduled', 'woocommerce' );
endif;
else :
_e( 'Last Modified', 'woocommerce' );
endif;
/**
* show hidden visible product on colum Date
* Assuming that we have only show and hidden status
*/
if ( $product->visibility == 'hidden' ) :
echo '<br />'. __('Hidden', 'woocommerce');
else:
echo '<br />'. __('Visible', 'woocommerce');
endif;
break;
}
}
@ -205,7 +214,7 @@ function woocommerce_custom_product_sort($columns) {
'price' => 'price',
'featured' => 'featured',
'sku' => 'sku',
'product_date' => 'date'
'name' => 'title'
);
return wp_parse_args($custom, $columns);
}

View File

@ -37,7 +37,7 @@ add_action('manage_shop_order_posts_custom_column', 'woocommerce_custom_order_co
function woocommerce_custom_order_columns($column) {
global $post;
$order = new Woocommerce_Order( $post->ID );
$order = new WC_Order( $post->ID );
switch ($column) {
case "order_status" :

View File

@ -20,7 +20,7 @@ function woocommerce_order_data_meta_box($post) {
$thepostid = $post->ID;
$order = new Woocommerce_Order( $thepostid );
$order = new WC_Order( $thepostid );
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
@ -260,9 +260,9 @@ function woocommerce_order_items_meta_box($post) {
<?php $loop = 0; if (sizeof($order_items)>0 && isset($order_items[0]['id'])) foreach ($order_items as $item) :
if (isset($item['variation_id']) && $item['variation_id'] > 0) :
$_product = new Woocommerce_Product_Variation( $item['variation_id'] );
$_product = new WC_Product_Variation( $item['variation_id'] );
else :
$_product = new Woocommerce_Product( $item['id'] );
$_product = new WC_Product( $item['id'] );
endif;
// Totals - Backwards Compatibility
@ -318,7 +318,7 @@ function woocommerce_order_items_meta_box($post) {
$meta_value = $meta;
endif;
echo '<tr><td><input type="text" name="meta_name['.$loop.'][]" value="'.$meta_name.'" /></td><td><input type="text" name="meta_value['.$loop.'][]" value="'.esc_attr( $meta_value ).'" /></td><td width="1%"><button class="remove_meta button">&times;</button></td></tr>';
echo '<tr><td><input type="text" name="meta_name['.$loop.'][]" value="'.esc_attr( $meta_name ).'" /></td><td><input type="text" name="meta_value['.$loop.'][]" value="'.esc_attr( $meta_value ).'" /></td><td width="1%"><button class="remove_meta button">&times;</button></td></tr>';
endforeach;
endif;
?>
@ -460,6 +460,7 @@ function woocommerce_order_actions_meta_box($post) {
* Displays the order totals meta box
*/
function woocommerce_order_totals_meta_box($post) {
global $woocommerce;
$data = get_post_custom( $post->ID );
?>
@ -505,7 +506,45 @@ function woocommerce_order_totals_meta_box($post) {
<div class="clear"></div>
</div>
<div class="totals_group">
<h4><?php _e('Taxes', 'woocommerce'); ?></h4>
<h4><?php _e('Tax Rows', 'woocommerce'); ?> <a class="tips" tip="<?php _e('These rows contain taxes for this order. This allows you to display multiple or compound taxes rather than a single total.', 'woocommerce'); ?>" href="#">[?]</a></h4>
<div id="tax_rows">
<?php
$loop = 0;
$taxes = maybe_unserialize($data['_order_taxes'][0]);
if (is_array($taxes) && sizeof($taxes)>0) :
foreach ($taxes as $tax) :
?>
<div class="tax_row">
<p class="first">
<label><?php _e('Tax Label:', 'woocommerce'); ?></label>
<input type="text" name="_order_taxes_label[<?php echo $loop; ?>]" placeholder="<?php echo $woocommerce->countries->tax_or_vat(); ?>" value="<?php echo $tax['label']; ?>" />
</p>
<p class="last">
<label><?php _e('Compound:', 'woocommerce'); ?>
<input type="checkbox" name="_order_taxes_compound[<?php echo $loop; ?>]" <?php checked($tax['compound'], 1); ?> /></label>
</p>
<p class="first">
<label><?php _e('Cart Tax:', 'woocommerce'); ?></label>
<input type="text" name="_order_taxes_cart[<?php echo $loop; ?>]" placeholder="0.00" value="<?php echo $tax['cart_tax']; ?>" />
</p>
<p class="last">
<label><?php _e('Shipping Tax:', 'woocommerce'); ?></label>
<input type="text" name="_order_taxes_shipping[<?php echo $loop; ?>]" placeholder="0.00" value="<?php echo $tax['shipping_tax']; ?>" />
</p>
<a href="#" class="delete_tax_row">&times;</a>
<div class="clear"></div>
</div>
<?php
$loop++;
endforeach;
endif;
?>
</div>
<h4><a href="#" class="add_tax_row"><?php _e('+ Add tax row', 'woocommerce'); ?></a></h4>
<div class="clear"></div>
</div>
<div class="totals_group">
<h4><?php _e('Tax Totals', 'woocommerce'); ?></h4>
<ul class="totals">
<li class="left">
@ -525,33 +564,6 @@ function woocommerce_order_totals_meta_box($post) {
</ul>
<div class="clear"></div>
</div>
<div class="totals_group">
<h4><?php _e('Tax Rows', 'woocommerce'); ?> <a class="tips" tip="<?php _e('These rows contain taxes for this order. This allows you to add multiple or compound taxes. Leave the rate blank to remove a tax row.', 'woocommerce'); ?>" href="#">[?]</a></h4>
<ul class="totals tax_rows">
<?php
$taxes = maybe_unserialize($data['_order_taxes'][0]);
if (is_array($taxes) && sizeof($taxes)>0) :
foreach ($taxes as $tax) :
?>
<li class="left">
<input type="text" name="_order_taxes_label[]" placeholder="Tax Label" value="<?php
echo $tax['label'];
?>" class="calculated" />
</li>
<li class="right">
<input type="text" name="_order_taxes_total[]" placeholder="0.00" value="<?php
echo $tax['total'];
?>" class="calculated" />
<input type="hidden" name="_order_taxes_compound[]" value="<?php echo $tax['compound']; ?>" />
</li>
<?php
endforeach;
endif;
?>
</ul>
<p><button class="button add_tax_row"><?php _e('Add row', 'woocommerce'); ?></button></p>
<div class="clear"></div>
</div>
<div class="totals_group">
<h4><?php _e('Total', 'woocommerce'); ?></h4>
<ul class="totals">
@ -584,7 +596,7 @@ function woocommerce_order_totals_meta_box($post) {
add_action('woocommerce_process_shop_order_meta', 'woocommerce_process_shop_order_meta', 1, 2);
function woocommerce_process_shop_order_meta( $post_id, $post ) {
global $wpdb;
global $wpdb, $woocommerce;
$woocommerce_errors = array();
@ -627,20 +639,25 @@ function woocommerce_process_shop_order_meta( $post_id, $post ) {
if (isset($_POST['_order_taxes_label'])) :
$order_taxes_label = $_POST['_order_taxes_label'];
$order_taxes_total = $_POST['_order_taxes_total'];
$order_taxes_compound = $_POST['_order_taxes_compound'];
$order_taxes_label = $_POST['_order_taxes_label'];
$order_taxes_compound = $_POST['_order_taxes_compound'];
$order_taxes_cart = $_POST['_order_taxes_cart'];
$order_taxes_shipping = $_POST['_order_taxes_shipping'];
for ($i=0; $i<sizeof($order_taxes_label); $i++) :
// Add to array
if (!$order_taxes_label[$i]) continue;
if (!$order_taxes_total[$i]) continue;
// Add to array if the tax amount is set
if (!$order_taxes_cart[$i] && !$order_taxes_shipping[$i]) continue;
if (!$order_taxes_label[$i]) $order_taxes_label[$i] = $woocommerce->countries->tax_or_vat();
if (isset($order_taxes_compound[$i])) $is_compound = 1; else $is_compound = 0;
$order_taxes[] = array(
'label' => esc_attr($order_taxes_label[$i]),
'compound' => (int) esc_attr($order_taxes_compound[$i]),
'total' => esc_attr($order_taxes_total[$i])
'label' => esc_attr($order_taxes_label[$i]),
'compound' => $is_compound,
'cart_tax' => esc_attr($order_taxes_cart[$i]),
'shipping_tax' => esc_attr($order_taxes_shipping[$i])
);
endfor;
@ -721,7 +738,7 @@ function woocommerce_process_shop_order_meta( $post_id, $post ) {
endif;
// Order data saved, now get it so we can manipulate status
$order = new Woocommerce_Order( $post_id );
$order = new WC_Order( $post_id );
// Order status
$order->update_status( $_POST['order_status'] );

View File

@ -65,9 +65,9 @@ function variable_product_type_options() {
$variation_data = get_post_custom( $variation->ID );
$image = '';
if (isset($variation_data['__thumbnail_id'][0])) :
$image_id = $variation_data['__thumbnail_id'][0];
$image = wp_get_attachment_url( $variation_data['__thumbnail_id'][0] );
if (isset($variation_data['_thumbnail_id'][0])) :
$image_id = $variation_data['_thumbnail_id'][0];
$image = wp_get_attachment_url( $variation_data['_thumbnail_id'][0] );
else :
$image_id = 0;
endif;

View File

@ -30,7 +30,7 @@ function woocommerce_product_data_box() {
<li class="tax_tab show_if_simple show_if_variable tax_options"><a href="#tax_product_data"><?php _e('Tax', 'woocommerce'); ?></a></li>
<?php if (get_option('woocommerce_manage_stock')=='yes') : ?><li class="inventory_tab show_if_simple show_if_variable show_if_grouped inventory_options"><a href="#inventory_product_data"><?php _e('Inventory', 'woocommerce'); ?></a></li><?php endif; ?>
<li class="inventory_tab show_if_simple show_if_variable show_if_grouped inventory_options"><a href="#inventory_product_data"><?php _e('Inventory', 'woocommerce'); ?></a></li>
<li class="upsells_and_crosssells_tab crosssell_options"><a href="#upsells_and_crosssells_product_data"><?php _e('Up-sells/Cross-sells', 'woocommerce'); ?></a></li>
@ -182,7 +182,7 @@ function woocommerce_product_data_box() {
do_action('woocommerce_product_options_tax');
?>
</div>
<?php if (get_option('woocommerce_manage_stock')=='yes') : ?>
<div id="inventory_product_data" class="panel woocommerce_options_panel">
<?php
@ -193,30 +193,34 @@ function woocommerce_product_data_box() {
'outofstock' => __('Out of stock', 'woocommerce')
) ) );
// manage stock
woocommerce_wp_checkbox( array( 'id' => '_manage_stock', 'wrapper_class' => 'show_if_simple show_if_variable', 'label' => __('Manage stock?', 'woocommerce') ) );
if (get_option('woocommerce_manage_stock')=='yes') {
do_action('woocommerce_product_options_stock');
// manage stock
woocommerce_wp_checkbox( array( 'id' => '_manage_stock', 'wrapper_class' => 'show_if_simple show_if_variable', 'label' => __('Manage stock?', 'woocommerce') ) );
do_action('woocommerce_product_options_stock');
echo '<div class="stock_fields show_if_simple show_if_variable">';
// Stock
woocommerce_wp_text_input( array( 'id' => '_stock', 'label' => __('Stock Qty', 'woocommerce') ) );
// Backorders?
woocommerce_wp_select( array( 'id' => '_backorders', 'label' => __('Allow Backorders?', 'woocommerce'), 'options' => array(
'no' => __('Do not allow', 'woocommerce'),
'notify' => __('Allow, but notify customer', 'woocommerce'),
'yes' => __('Allow', 'woocommerce')
) ) );
echo '<div class="stock_fields show_if_simple show_if_variable">';
do_action('woocommerce_product_options_stock_fields');
echo '</div>';
// Stock
woocommerce_wp_text_input( array( 'id' => '_stock', 'label' => __('Stock Qty', 'woocommerce') ) );
// Backorders?
woocommerce_wp_select( array( 'id' => '_backorders', 'label' => __('Allow Backorders?', 'woocommerce'), 'options' => array(
'no' => __('Do not allow', 'woocommerce'),
'notify' => __('Allow, but notify customer', 'woocommerce'),
'yes' => __('Allow', 'woocommerce')
) ) );
do_action('woocommerce_product_options_stock_fields');
echo '</div>';
}
?>
</div>
<?php endif; ?>
<div id="woocommerce_attributes" class="panel">
<div class="woocommerce_attributes_wrapper">
@ -386,7 +390,7 @@ function woocommerce_product_data_box() {
if (sizeof($posts_in)>0) :
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'post_status' => 'any',
'numberposts' => -1,
'orderby' => 'title',
'order' => 'asc',

View File

@ -125,7 +125,7 @@ function woocommmerce_dashboard_recent_orders() {
echo '<ul class="recent-orders">';
foreach ($orders as $order) :
$this_order = new Woocommerce_Order( $order->ID );
$this_order = new WC_Order( $order->ID );
echo '
<li>
@ -270,7 +270,7 @@ function woocommmerce_dashboard_sales_js() {
if ($orders) :
foreach ($orders as $order) :
$order_data = new Woocommerce_Order($order->ID);
$order_data = new WC_Order($order->ID);
if ($order_data->status=='cancelled' || $order_data->status=='refunded') continue;

View File

@ -157,7 +157,10 @@ function woocommerce_admin_scripts() {
'meta_name' => __('Meta Name', 'woocommerce'),
'meta_value' => __('Meta Value', 'woocommerce'),
'no_customer_selected' => __('No customer selected', 'woocommerce'),
'tax_label' => __('Tax Label', 'woocommerce'),
'tax_label' => __('Tax Label:', 'woocommerce'),
'compound_label' => __('Compound:', 'woocommerce'),
'cart_tax_label' => __('Cart Tax:', 'woocommerce'),
'shipping_tax_label' => __('Shipping Tax:', 'woocommerce'),
'plugin_url' => $woocommerce->plugin_url(),
'ajax_url' => admin_url('admin-ajax.php'),
'add_order_item_nonce' => wp_create_nonce("add-order-item"),

View File

@ -184,7 +184,7 @@ function woocommerce_create_pages() {
* Sets up the database tables which the plugin needs to function.
*/
function woocommerce_tables_install() {
global $wpdb;
global $wpdb, $woocommerce;
$wpdb->hide_errors();
@ -233,38 +233,44 @@ function woocommerce_tables_install() {
PRIMARY KEY id (meta_id)) $collate;";
dbDelta($sql);
// Update woocommerce_downloadable_product_permissions table to include order ID's as well as keys
$results = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."woocommerce_downloadable_product_permissions WHERE order_id = 0;" );
if ($results) foreach ($results as $result) :
/**
* Version updates
**/
if ( get_option('woocommerce_db_version') > 1.0 && get_option('woocommerce_db_version') < 1.4 ) {
// Update woocommerce_downloadable_product_permissions table to include order ID's as well as keys
$results = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."woocommerce_downloadable_product_permissions WHERE order_id = 0;" );
if (!$result->order_key) continue;
if ($results) foreach ($results as $result) :
if (!$result->order_key) continue;
$order_id = $wpdb->get_var( $wpdb->prepare("SELECT post_id FROM ".$wpdb->postmeta." WHERE meta_key = '_order_key' AND meta_value = '%s' LIMIT 1;", $result->order_key) );
if ($order_id) :
$wpdb->update( $wpdb->prefix . "woocommerce_downloadable_product_permissions", array(
'order_id' => $order_id,
), array(
'product_id' => $result->product_id,
'order_key' => $result->order_key
), array( '%s' ), array( '%s', '%s' ) );
endif;
endforeach;
$order_id = $wpdb->get_var( $wpdb->prepare("SELECT post_id FROM ".$wpdb->postmeta." WHERE meta_key = '_order_key' AND meta_value = '%s' LIMIT 1;", $result->order_key) );
// Upgrade old meta keys for product data
$meta = array('sku', 'downloadable', 'virtual', 'price', 'visibility', 'stock', 'stock_status', 'backorders', 'manage_stock', 'sale_price', 'regular_price', 'weight', 'length', 'width', 'height', 'tax_status', 'tax_class', 'upsell_ids', 'crosssell_ids', 'sale_price_dates_from', 'sale_price_dates_to', 'min_variation_price', 'max_variation_price', 'featured', 'product_attributes', 'file_path', 'download_limit', 'product_url', 'min_variation_price', 'max_variation_price');
if ($order_id) :
$wpdb->update( $wpdb->prefix . "woocommerce_downloadable_product_permissions", array(
'order_id' => $order_id,
), array(
'product_id' => $result->product_id,
'order_key' => $result->order_key
), array( '%s' ), array( '%s', '%s' ) );
endif;
endforeach;
// Upgrade old meta keys for product data
$meta = array('sku', 'downloadable', 'virtual', 'price', 'visibility', 'stock', 'stock_status', 'backorders', 'manage_stock', 'sale_price', 'regular_price', 'weight', 'length', 'width', 'height', 'tax_status', 'tax_class', 'upsell_ids', 'crosssell_ids', 'sale_price_dates_from', 'sale_price_dates_to', 'min_variation_price', 'max_variation_price', 'featured', 'product_attributes', 'file_path', 'download_limit', 'product_url', 'min_variation_price', 'max_variation_price');
$wpdb->query("
UPDATE $wpdb->postmeta
LEFT JOIN $wpdb->posts ON ( $wpdb->postmeta.post_id = $wpdb->posts.ID )
SET meta_key = CONCAT('_', meta_key)
WHERE meta_key IN ('". implode("', '", $meta) ."')
AND $wpdb->posts.post_type = 'product'
");
$wpdb->query("
UPDATE $wpdb->postmeta
LEFT JOIN $wpdb->posts ON ( $wpdb->postmeta.post_id = $wpdb->posts.ID )
SET meta_key = CONCAT('_', meta_key)
WHERE meta_key IN ('". implode("', '", $meta) ."')
AND $wpdb->posts.post_type IN ('product', 'product_variation')
");
}
$wpdb->show_errors();

View File

@ -292,7 +292,7 @@ function woocommerce_sales_overview() {
echo '<ul class="recent-orders">';
foreach ($orders as $order) :
$this_order = new Woocommerce_Order( $order->ID );
$this_order = new WC_Order( $order->ID );
if ($this_order->user_id > 0) :
$customer = get_user_by('id', $this_order->user_id);
@ -1072,7 +1072,7 @@ function woocommerce_product_sales() {
$product_totals = array();
// Get ID's related to product
$chosen_product = new Woocommerce_Product( $chosen_product_id );
$chosen_product = new WC_Product( $chosen_product_id );
$child_ids = $chosen_product->get_children();
if ($orders) :

View File

@ -1155,9 +1155,9 @@ function woocommerce_settings() {
<td>';
if ($method->enabled == 'yes')
echo '<img src="'.$woocommerce->plugin_url().'/assets/images/success.gif" alt="yes" />';
echo '<img src="'.$woocommerce->plugin_url().'/assets/images/success.png" alt="yes" />';
else
echo '<img src="'.$woocommerce->plugin_url().'/assets/images/success-off.gif" alt="no" />';
echo '<img src="'.$woocommerce->plugin_url().'/assets/images/success-off.png" alt="no" />';
echo '</td>
</tr>';
@ -1223,9 +1223,9 @@ function woocommerce_settings() {
<td>';
if ($gateway->enabled == 'yes')
echo '<img src="'.$woocommerce->plugin_url().'/assets/images/success.gif" alt="yes" />';
echo '<img src="'.$woocommerce->plugin_url().'/assets/images/success.png" alt="yes" />';
else
echo '<img src="'.$woocommerce->plugin_url().'/assets/images/success-off.gif" alt="no" />';
echo '<img src="'.$woocommerce->plugin_url().'/assets/images/success-off.png" alt="no" />';
echo '</td>
</tr>';

View File

@ -85,8 +85,8 @@ function woocommerce_user_column_values($value, $column_name, $user_id) {
$paying_customer = get_user_meta( $user_id, 'paying_customer', true );
if ($paying_customer) $value = '<img src="'.$woocommerce->plugin_url().'/assets/images/success.gif" alt="yes" />';
else $value = '<img src="'.$woocommerce->plugin_url().'/assets/images/success-off.gif" alt="no" />';
if ($paying_customer) $value = '<img src="'.$woocommerce->plugin_url().'/assets/images/success.png" alt="yes" />';
else $value = '<img src="'.$woocommerce->plugin_url().'/assets/images/success-off.png" alt="no" />';
break;
endswitch;

View File

@ -36,15 +36,24 @@ mark.amount{background:transparent none;color:inherit;}
#woocommerce-order-items h3 small{color:#999;}
#woocommerce-order-items .row-actions{float:right;padding:0;color:#999;}#woocommerce-order-items .row-actions a{color:#999;}
#woocommerce-order-items .row-actions a.remove_row:hover{color:red;}
#woocommerce-order-totals h4{margin:0 !important;}
#woocommerce-order-totals .totals_group{border-top:1px solid white;border-bottom:1px solid #DDD;padding:10px 10px 0;}
#woocommerce-order-totals h4{margin:0 !important;}#woocommerce-order-totals h4 a.add_tax_row{display:block;padding-bottom:10px;}
#woocommerce-order-totals .totals_group{border-top:1px solid white;border-bottom:1px solid #DDD;padding:10px 0 0;}
#woocommerce-order-totals .totals_group:first-child{border-top:0;}
#woocommerce-order-totals ul.totals{margin:6px 0 0;float:left;}#woocommerce-order-totals ul.totals li{float:left;clear:both;width:100%;font-size:1.2em;font-weight:bold;line-height:1.2em;margin:0;padding:0 0 10px;}#woocommerce-order-totals ul.totals li label{font-weight:normal;display:block;font-size:0.8em;color:#333;}
#woocommerce-order-totals ul.totals li input{width:100%;vertical-align:middle;font-size:1em;margin:0 !important;font-weight:normal;color:#555;}
#woocommerce-order-totals ul.totals li input.first{width:49%;float:left;}
#woocommerce-order-totals ul.totals li input.last{width:49%;float:right;}
#woocommerce-order-totals ul.totals li.left{float:left;width:49%;clear:none;}#woocommerce-order-totals ul.totals li.left input{width:100%;}
#woocommerce-order-totals ul.totals li.left{float:left;width:49%;clear:left;}#woocommerce-order-totals ul.totals li.left input{width:100%;}
#woocommerce-order-totals ul.totals li.right{float:right;width:49%;clear:none;}#woocommerce-order-totals ul.totals li.right input{width:100%;}
#woocommerce-order-totals ul.totals .calculated{border-color:#ae8ca2;border-style:dotted;}
#woocommerce-order-totals #tax_rows{margin:6px 0 0;}
#woocommerce-order-totals .tax_row{margin:0 0 9px;border:1px solid #DFDFDF;background:#fff;padding:6px 6px 0;position:relative;opacity:0.75;}#woocommerce-order-totals .tax_row:hover,#woocommerce-order-totals .tax_row:focus{opacity:1;}
#woocommerce-order-totals .tax_row p{margin:0 0 6px;}
#woocommerce-order-totals .tax_row label{color:#555;}#woocommerce-order-totals .tax_row label .checkbox{line-height:26px;}
#woocommerce-order-totals .tax_row p.first{float:left;width:49%;clear:left;}#woocommerce-order-totals .tax_row p.first input,#woocommerce-order-totals .tax_row p.first select{width:100%;}
#woocommerce-order-totals .tax_row p.last{float:right;width:49%;clear:none;}#woocommerce-order-totals .tax_row p.last input,#woocommerce-order-totals .tax_row p.last select{width:100%;}
#woocommerce-order-totals .tax_row a.delete_tax_row{padding:0;text-decoration:none;font-size:11px;line-height:16px;width:16px;height:16px;text-align:center;color:#999;float:right;background:#ddd;border:1px solid #eee;-webkit-box-shadow:0 0 0 1px #ccc;-webkit-border-radius:8px;-moz-border-radius:8px;-o-border-radius:8px;border-radius:8px;position:absolute;top:0;right:0;margin:-8px -8px 0 0;display:none;}
#woocommerce-order-totals .tax_row:hover a.delete_tax_row,#woocommerce-order-totals .tax_row:focus a.delete_tax_row{display:block;}
.woocommerce_order_items_wrapper{margin:0;}.woocommerce_order_items_wrapper table.woocommerce_order_items{width:100%;background:#fff;}.woocommerce_order_items_wrapper table.woocommerce_order_items thead th{background:#ECECEC;padding:8px;font-size:11px;text-align:left;}
.woocommerce_order_items_wrapper table.woocommerce_order_items td{padding:8px;text-align:left;line-height:26px;vertical-align:top;border-bottom:1px dotted #ececec;}.woocommerce_order_items_wrapper table.woocommerce_order_items td input,.woocommerce_order_items_wrapper table.woocommerce_order_items td textarea{width:100%;}
.woocommerce_order_items_wrapper table.woocommerce_order_items td select{width:50%;}
@ -83,10 +92,12 @@ ul.order_notes li.customer-note .note_content{background:#d7cad2;}
ul.order_notes li.customer-note .note_content:after{border-color:#d7cad2 transparent;}
.add_note{border-top:1px solid #ddd;padding:10px;}.add_note h4{margin-top:5px !important;}
.add_note input#add_order_note{width:50%;}
table.wp-list-table .column-thumb{width:66px;text-align:center;white-space:nowrap;}
table.wp-list-table .column-sku,table.wp-list-table .column-product_type,table.wp-list-table .column-product_cat,table.wp-list-table .column-product_tags,table.wp-list-table .column-is_in_stock,table.wp-list-table .column-price,table.wp-list-table .column-product_date,table.wp-list-table .column-featured{width:9%;}
table.wp-list-table .column-thumb{width:52px;text-align:center;white-space:nowrap;}
table.wp-list-table .column-product_cat,table.wp-list-table .column-product_tag{width:11% !important;}
table.wp-list-table .column-product_cat,table.wp-list-table .column-product_tags,table.wp-list-table .column-is_in_stock,table.wp-list-table .column-price,table.wp-list-table .column-product_date,table.wp-list-table .column-featured{width:9%;}
table.wp-list-table .column-sku,table.wp-list-table .column-product_type{width:7%;}
table.wp-list-table img{margin:1px 2px;}
table.wp-list-table .column-thumb img{padding:2px;margin:0;border:1px solid #dfdfdf;vertical-align:middle;width:42px;height:42px;}
table.wp-list-table .column-thumb img{padding:2px;margin:0;border:1px solid #dfdfdf;vertical-align:middle;width:32px;height:32px;}
table.wp-list-table span.na{color:#999;}
table.wp-list-table .column-featured,table.wp-list-table .column-is_in_stock{text-align:left !important;}
ul.woocommerce_stats{overflow:hidden;zoom:1;}ul.woocommerce_stats li{width:22%;padding:0 1.4%;float:left;font-size:0.8em;border-left:1px solid #fff;border-right:1px solid #ececec;text-align:center;}

View File

@ -214,11 +214,18 @@ mark.amount {
#woocommerce-order-totals {
h4 {
margin:0 !important;
a.add_tax_row {
display: block;
padding-bottom: 10px;
}
}
.totals_group {
border-top: 1px solid white;
border-bottom: 1px solid #DDD;
padding: 10px 10px 0;
padding: 10px 0 0;
}
.totals_group:first-child {
border-top: 0;
}
ul.totals {
margin: 6px 0 0;
@ -258,7 +265,7 @@ mark.amount {
li.left {
float: left;
width: 49%;
clear: none;
clear: left;
input {
width: 100%;
}
@ -276,6 +283,73 @@ mark.amount {
border-style: dotted;
}
}
#tax_rows {
margin: 6px 0 0;
}
.tax_row {
margin:0 0 9px;
border:1px solid #DFDFDF;
background: #fff;
padding:6px 6px 0;
position: relative;
opacity:0.75;
&:hover, &:focus {
opacity:1;
}
p {
margin:0 0 6px;
}
label {
color:#555;
.checkbox {
line-height: 26px;
}
}
p.first {
float: left;
width: 49%;
clear: left;
input, select {
width: 100%;
}
}
p.last {
float: right;
width: 49%;
clear: none;
input, select {
width: 100%;
}
}
a.delete_tax_row {
padding:0;
text-decoration: none;
font-size: 11px;
line-height: 16px;
width: 16px;
height: 16px;
text-align: center;
color:#999;
float: right;
background: #ddd;
border: 1px solid #eee;
-webkit-box-shadow: 0 0 0 1px #ccc;
-webkit-border-radius:8px;
-moz-border-radius:8px;
-o-border-radius:8px;
border-radius:8px;
position: absolute;
top: 0;
right: 0;
margin: -8px -8px 0 0;
display: none;
}
&:hover, &:focus {
a.delete_tax_row {
display: block;
}
}
}
}
.woocommerce_order_items_wrapper {
margin: 0;
@ -524,13 +598,19 @@ ul.order_notes {
/* Product list */
table.wp-list-table {
.column-thumb {
width: 66px;
width: 52px;
text-align: center;
white-space: nowrap
}
.column-sku, .column-product_type, .column-product_cat, .column-product_tags, .column-is_in_stock, .column-price, .column-product_date, .column-featured {
.column-product_cat, .column-product_tag {
width: 11% !important;
}
.column-product_cat, .column-product_tags, .column-is_in_stock, .column-price, .column-product_date, .column-featured {
width: 9%;
}
.column-sku, .column-product_type {
width: 7%;
}
img {
margin: 1px 2px;
}
@ -539,8 +619,8 @@ table.wp-list-table {
margin: 0;
border: 1px solid #dfdfdf;
vertical-align: middle;
width: 42px;
height: 42px;
width: 32px;
height: 32px;
}
span.na {
color: #999;

View File

@ -1,7 +1,8 @@
.clear{clear:both;}
.nobr{white-space:nowrap;}
.woocommerce_message,.info,.woocommerce_error,.woocommerce_info{padding:.55em 1em .55em 3em;margin-bottom:2em;position:relative;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;background:#f6f6f6;background:-webkit-gradient(linear, left top, left bottom, from(#f6f6f6), to(#eeeeee));background:-webkit-linear-gradient(#f6f6f6, #eeeeee);background:-moz-linear-gradient(center top, #f6f6f6 0%, #eeeeee 100%);background:-moz-gradient(center top, #f6f6f6 0%, #eeeeee 100%);box-shadow:0 1px 2px 0 rgba(0, 0, 0, 0.25);-webkit-box-shadow:0 1px 2px 0 rgba(0, 0, 0, 0.25);-moz-box-shadow:0 1px 2px 0 rgba(0, 0, 0, 0.25);text-shadow:0 1px 0 #ffffff;}.woocommerce_message:before,.info:before,.woocommerce_error:before,.woocommerce_info:before{content:"";height:16px;width:16px;display:block;position:absolute;top:.8em;left:1em;background-color:white;-webkit-border-radius:1em;-moz-border-radius:1em;border-radius:1em;}
.woocommerce_message,.info,.woocommerce_error,.woocommerce_info{padding:.55em 1em .55em 3em;margin:0 0 2em;position:relative;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;background:#f6f6f6;background:-webkit-gradient(linear, left top, left bottom, from(#f6f6f6), to(#eeeeee));background:-webkit-linear-gradient(#f6f6f6, #eeeeee);background:-moz-linear-gradient(center top, #f6f6f6 0%, #eeeeee 100%);background:-moz-gradient(center top, #f6f6f6 0%, #eeeeee 100%);box-shadow:0 1px 2px 0 rgba(0, 0, 0, 0.25);-webkit-box-shadow:0 1px 2px 0 rgba(0, 0, 0, 0.25);-moz-box-shadow:0 1px 2px 0 rgba(0, 0, 0, 0.25);text-shadow:0 1px 0 #ffffff;list-style:none outside;}.woocommerce_message:before,.info:before,.woocommerce_error:before,.woocommerce_info:before{content:"";height:16px;width:16px;display:block;position:absolute;top:.8em;left:1em;background-color:white;-webkit-border-radius:1em;-moz-border-radius:1em;border-radius:1em;}
.woocommerce_message .button,.info .button,.woocommerce_error .button,.woocommerce_info .button{float:right;}
.woocommerce_message li,.info li,.woocommerce_error li,.woocommerce_info li{list-style:none outside;}
.woocommerce_message:after,.info:after,.woocommerce_error:after,.woocommerce_info:after{content:"";display:block;clear:both;}
.woocommerce_message:before{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAGCAYAAAAPDoR2AAAAN0lEQVQIHXWMQQ4AMAjCxv7/ZxZIanbYPIhSUbbXo2Jqf0BsA4mjgU1ioAVpSSrDVbPzFgPt7QH7qwoJ3MDCYgAAAABJRU5ErkJggg==) center no-repeat #8fae1b;}
.info:before,.woocommerce_info:before{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAAFCAYAAABvsz2cAAAAG0lEQVQIHWP8DwQMQMACxIwwBliECcQDATgDAMHrBQqJ6tMZAAAAAElFTkSuQmCC) center no-repeat #18919c;}
@ -59,7 +60,7 @@ ul.products li.first{clear:both;}
ul.products li.last{margin-right:0;}
.woocommerce_ordering{margin-bottom:24px;}
a.button,button.button,input.button,#review_form #submit{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle;line-height:normal;cursor:pointer;position:relative;font-family:sans-serif;text-decoration:none;overflow:visible;border:1px solid #969696;background:#f5f5f5;background:-webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#e1e1e1));background:-webkit-linear-gradient(#f5f5f5, #e1e1e1);background:-moz-linear-gradient(center top, #f5f5f5 0%, #e1e1e1 100%);background:-moz-gradient(center top, #f5f5f5 0%, #e1e1e1 100%);padding:5px 10px;color:#676767;text-decoration:none;font-weight:bold;text-shadow:0 1px 0 #fff;margin:0;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;-webkit-box-shadow:inset 0 -1px 0 rgba(0, 0, 0, 0.075),inset 0 1px 0 rgba(255, 255, 255, 0.3),0 1px 2px rgba(0, 0, 0, 0.1);-moz-box-shadow:inset 0 -1px 0 rgba(0, 0, 0, 0.075),inset 0 1px 0 rgba(255, 255, 255, 0.3),0 1px 2px rgba(0, 0, 0, 0.1);box-shadow:inset 0 -1px 0 rgba(0, 0, 0, 0.075),inset 0 1px 0 rgba(255, 255, 255, 0.3),0 1px 2px rgba(0, 0, 0, 0.1);}a.button.loading,button.button.loading,input.button.loading,#review_form #submit.loading{color:#999;border-color:#ccc;}a.button.loading:before,button.button.loading:before,input.button.loading:before,#review_form #submit.loading:before{content:"";position:absolute;top:0;right:0;left:0;bottom:0;background:url(../images/ajax-loader.gif) center no-repeat rgba(255, 255, 255, 0.65);}
a.button.added:before,button.button.added:before,input.button.added:before,#review_form #submit.added:before{content:"";position:absolute;height:16px;width:16px;top:0.35em;right:-26px;text-indent:0;background:url(../images/success.gif) no-repeat;}
a.button.added:before,button.button.added:before,input.button.added:before,#review_form #submit.added:before{content:"";position:absolute;height:16px;width:16px;top:0.35em;right:-26px;text-indent:0;background:url(../images/success.png) no-repeat;}
a.button:hover,button.button:hover,input.button:hover,#review_form #submit:hover{background:#fafafa;background:-webkit-gradient(linear, left top, left bottom, from(#fafafa), to(#e6e6e6));background:-webkit-linear-gradient(#fafafa, #e6e6e6);background:-moz-linear-gradient(center top, #fafafa 0%, #e6e6e6 100%);background:-moz-gradient(center top, #fafafa 0%, #e6e6e6 100%);text-decoration:none;}
a.button:active,button.button:active,input.button:active,#review_form #submit:active{top:1px;}
a.button.alt,button.button.alt,input.button.alt,#review_form #submit.alt{background:#ad74a2;background:-webkit-gradient(linear, left top, left bottom, from(#ad74a2), to(#935386));background:-webkit-linear-gradient(#ad74a2, #935386);background:-moz-linear-gradient(center top, #ad74a2 0%, #935386 100%);background:-moz-gradient(center top, #ad74a2 0%, #935386 100%);border-color:#522e4b;color:#fff;text-shadow:0 -1px 0 rgba(0, 0, 0, 0.6);}a.button.alt:hover,button.button.alt:hover,input.button.alt:hover,#review_form #submit.alt:hover{background:#b784ad;background:-webkit-gradient(linear, left top, left bottom, from(#b784ad), to(#935386));background:-webkit-linear-gradient(#b784ad, #935386);background:-moz-linear-gradient(center top, #b784ad 0%, #935386 100%);background:-moz-gradient(center top, #b784ad 0%, #935386 100%);}

View File

@ -90,12 +90,13 @@ transition:@selector @animation @duration;
.nobr { white-space: nowrap; }
.woocommerce_message, .info, .woocommerce_error, .woocommerce_info {
padding:.55em 1em .55em 3em;
margin-bottom:2em;
margin: 0 0 2em;
position: relative;
.border_radius(2px);
.vertical_gradient(#f6f6f6,#eee);
.box_shadow(0,1px,2px,0,rgba(0,0,0,0.25));
.text_shadow(0,1px,0,#fff);
list-style: none outside;
&:before {
content: "";
@ -113,6 +114,10 @@ transition:@selector @animation @duration;
float: right;
}
li {
list-style: none outside;
}
&:after {
content: "";
display: block;
@ -577,7 +582,7 @@ a.button, button.button, input.button, #review_form #submit {
top:0.35em;
right:-26px;
text-indent: 0;
background: url(../images/success.gif) no-repeat;
background: url(../images/success.png) no-repeat;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 353 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 560 B

BIN
assets/images/success.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 711 B

View File

@ -20,6 +20,10 @@ jQuery( function($){
});
// ORDERS
jQuery('#woocommerce-order-actions input, #woocommerce-order-actions a').click(function(){
window.onbeforeunload = '';
});
$('a.edit_address').click(function(){
$(this).hide();
@ -167,7 +171,7 @@ jQuery( function($){
$('#_order_total').val( order_total );
// Since we currently cannot calc shipping from the backend, ditch the rows. They must be manually calculated.
$('ul.tax_rows').empty();
$('#tax_rows').empty();
$('#woocommerce-order-totals').unblock();
@ -351,8 +355,38 @@ jQuery( function($){
return false;
});
$('button.add_tax_row').live('click', function(){
$('ul.tax_rows').append('<li class="left"><input type="text" name="_order_taxes_label[]" placeholder="' + woocommerce_writepanel_params.tax_label + '" class="calculated" value="' + woocommerce_writepanel_params.tax_or_vat + '" /></li><li class="right"><input type="text" name="_order_taxes_total[]" placeholder="0.00" class="calculated" /><input type="hidden" name="_order_taxes_compound[]" value="0" /></li>');
$('a.add_tax_row').live('click', function(){
var size = $('#tax_rows .tax_row').size();
$('#tax_rows').append('<div class="tax_row">\
<p class="first">\
<label>' + woocommerce_writepanel_params.tax_label + '</label>\
<input type="text" name="_order_taxes_label[' + size + ']" placeholder="' + woocommerce_writepanel_params.tax_or_vat + '" />\
</p>\
<p class="last">\
<label>' + woocommerce_writepanel_params.compound_label + '\
<input type="checkbox" name="_order_taxes_compound[' + size + ']" /></label>\
</p>\
<p class="first">\
<label>' + woocommerce_writepanel_params.cart_tax_label + '</label>\
<input type="text" name="_order_taxes_cart[' + size + ']" placeholder="0.00" />\
</p>\
<p class="last">\
<label>' + woocommerce_writepanel_params.shipping_tax_label + '</label>\
<input type="text" name="_order_taxes_shipping[' + size + ']" placeholder="0.00" />\
</p>\
<a href="#" class="delete_tax_row">&times;</a>\
<div class="clear"></div>\
</div>');
return false;
});
$('a.delete_tax_row').live('click', function(){
$tax_row = $(this).closest('.tax_row');
$tax_row.find('input').val('');
$tax_row.hide();
return false;
});

File diff suppressed because one or more lines are too long

View File

@ -32,8 +32,8 @@ jQuery(document).ready(function($) {
// Get response
data = $.parseJSON( response );
if (data.error) {
alert(data.error);
if (data.error && data.product_url) {
window.location = data.product_url;
return;
}

File diff suppressed because one or more lines are too long

View File

@ -5,12 +5,12 @@
* The WooCommerce cart class stores cart data and active coupons as well as handling customer sessions and some cart related urls.
* The cart class also has a price calculation function which calls upon other classes to calcualte totals.
*
* @class Woocommerce_Cart
* @class WC_Cart
* @package WooCommerce
* @category Class
* @author WooThemes
*/
class Woocommerce_Cart {
class WC_Cart {
/* Public Variables */
var $cart_contents;
@ -26,6 +26,7 @@ class Woocommerce_Cart {
var $subtotal_ex_tax;
var $tax_total;
var $taxes;
var $shipping_taxes;
var $discount_cart;
var $discount_total;
var $shipping_total;
@ -39,7 +40,7 @@ class Woocommerce_Cart {
* Constructor
*/
function __construct() {
$this->tax = new Woocommerce_Tax();
$this->tax = new WC_Tax();
$this->prices_include_tax = (get_option('woocommerce_prices_include_tax')=='yes') ? true : false;
$this->display_totals_ex_tax = (get_option('woocommerce_display_totals_excluding_tax')=='yes') ? true : false;
$this->display_cart_ex_tax = (get_option('woocommerce_display_cart_prices_excluding_tax')=='yes') ? true : false;
@ -76,9 +77,9 @@ class Woocommerce_Cart {
foreach ($cart as $key => $values) :
if ($values['variation_id'] > 0) :
$_product = new Woocommerce_Product_Variation($values['variation_id']);
$_product = new WC_Product_Variation($values['variation_id']);
else :
$_product = new Woocommerce_Product($values['product_id']);
$_product = new WC_Product($values['product_id']);
endif;
if ($_product->exists && $values['quantity']>0) :
@ -113,6 +114,7 @@ class Woocommerce_Cart {
$this->subtotal_ex_tax = isset($_SESSION['subtotal_ex_tax']) ? $_SESSION['subtotal_ex_tax'] : 0;
$this->tax_total = isset($_SESSION['tax_total']) ? $_SESSION['tax_total'] : 0;
$this->taxes = isset($_SESSION['taxes']) ? $_SESSION['taxes'] : array();
$this->shipping_taxes = isset($_SESSION['shipping_taxes']) ? $_SESSION['shipping_taxes'] : array();
$this->discount_cart = isset($_SESSION['discount_cart']) ? $_SESSION['discount_cart'] : 0;
$this->discount_total = isset($_SESSION['discount_total']) ? $_SESSION['discount_total'] : 0;
$this->shipping_total = isset($_SESSION['shipping_total']) ? $_SESSION['shipping_total'] : 0;
@ -146,6 +148,7 @@ class Woocommerce_Cart {
$_SESSION['subtotal'] = $this->subtotal;
$_SESSION['subtotal_ex_tax'] = $this->subtotal_ex_tax;
$_SESSION['tax_total'] = $this->tax_total;
$_SESSION['shipping_taxes'] = $this->shipping_taxes;
$_SESSION['taxes'] = $this->taxes;
$_SESSION['discount_cart'] = $this->discount_cart;
$_SESSION['discount_total'] = $this->discount_total;
@ -160,7 +163,7 @@ class Woocommerce_Cart {
function empty_cart() {
$this->cart_contents = array();
$this->reset();
unset( $_SESSION['cart_contents_total'], $_SESSION['cart_contents_weight'], $_SESSION['cart_contents_count'], $_SESSION['cart_contents_tax'], $_SESSION['total'], $_SESSION['subtotal'], $_SESSION['subtotal_ex_tax'], $_SESSION['tax_total'], $_SESSION['taxes'], $_SESSION['discount_cart'], $_SESSION['discount_total'], $_SESSION['shipping_total'], $_SESSION['shipping_tax_total'], $_SESSION['shipping_label'], $_SESSION['coupons'], $_SESSION['cart'] );
unset( $_SESSION['cart_contents_total'], $_SESSION['cart_contents_weight'], $_SESSION['cart_contents_count'], $_SESSION['cart_contents_tax'], $_SESSION['total'], $_SESSION['subtotal'], $_SESSION['subtotal_ex_tax'], $_SESSION['tax_total'], $_SESSION['taxes'], $_SESSION['shipping_taxes'], $_SESSION['discount_cart'], $_SESSION['discount_total'], $_SESSION['shipping_total'], $_SESSION['shipping_tax_total'], $_SESSION['shipping_label'], $_SESSION['coupons'], $_SESSION['cart'] );
}
/*-----------------------------------------------------------------------------------*/
@ -212,7 +215,7 @@ class Woocommerce_Cart {
if (!$flat) $return = '<dl class="variation">';
// Variation data
if($cart_item['data'] instanceof woocommerce_product_variation && is_array($cart_item['variation'])) :
if($cart_item['data'] instanceof WC_Product_Variation && is_array($cart_item['variation'])) :
$variation_list = array();
@ -326,6 +329,20 @@ class Woocommerce_Cart {
*/
function get_cart() {
return (array) $this->cart_contents;
}
/**
* Returns the cart and shipping taxes, merged
*/
function get_taxes() {
$merged_taxes = array();
// Merge
foreach (array_keys($this->taxes + $this->shipping_taxes) as $key) {
$merged_taxes[$key] = (isset($this->shipping_taxes[$key]) ? $this->shipping_taxes[$key] : 0) + (isset($this->taxes[$key]) ? $this->taxes[$key] : 0);
}
return $merged_taxes;
}
/*-----------------------------------------------------------------------------------*/
@ -393,9 +410,9 @@ class Woocommerce_Cart {
$cart_item_key = $this->find_product_in_cart($cart_id);
if ($variation_id>0) :
$product_data = new Woocommerce_Product_Variation( $variation_id );
$product_data = new WC_Product_Variation( $variation_id );
else :
$product_data = new Woocommerce_Product( $product_id );
$product_data = new WC_Product( $product_id );
endif;
// Type/Exists check
@ -485,6 +502,7 @@ class Woocommerce_Cart {
$this->cart_contents_tax = 0;
$this->tax_total = 0;
$this->shipping_tax_total = 0;
$this->shipping_taxes = array();
$this->subtotal = 0;
$this->subtotal_ex_tax = 0;
$this->discount_total = 0;
@ -499,7 +517,7 @@ class Woocommerce_Cart {
function get_discounted_price( $values, $price, $add_totals = false ) {
if (!empty($this->applied_coupons)) foreach ($this->applied_coupons as $code) :
$coupon = new Woocommerce_Coupon( $code );
$coupon = new WC_Coupon( $code );
if ( $coupon->apply_before_tax() && $coupon->is_valid() ) :
@ -635,7 +653,7 @@ class Woocommerce_Cart {
function apply_product_discounts_after_tax( $values, $price ) {
if (!empty($this->applied_coupons)) foreach ($this->applied_coupons as $code) :
$coupon = new Woocommerce_Coupon( $code );
$coupon = new WC_Coupon( $code );
do_action( 'woocommerce_product_discount_after_tax_' . $coupon->type, $coupon );
@ -698,7 +716,7 @@ class Woocommerce_Cart {
function apply_cart_discounts_after_tax() {
if ($this->applied_coupons) foreach ($this->applied_coupons as $code) :
$coupon = new Woocommerce_Coupon( $code );
$coupon = new WC_Coupon( $code );
do_action( 'woocommerce_cart_discount_after_tax_' . $coupon->type, $coupon );
@ -838,11 +856,11 @@ class Woocommerce_Cart {
$taxes = $this->tax->calc_tax( $row_base_price - array_sum($base_taxes), $tax_rates, false );
// Tax amount
$tax_amount = $this->tax->get_tax_total($taxes);
$tax_amount = array_sum($taxes);
// Line subtotal + tax
$line_subtotal_tax = round($tax_amount, 2);
$line_subtotal = $row_base_price - array_sum($base_taxes);
$line_subtotal_tax = ( get_option('woocommerce_tax_round_at_subtotal')=='no' ) ? round($tax_amount, 2) : $tax_amount;
$line_subtotal = $row_base_price - $this->tax->get_tax_total($base_taxes);
// Adjusted price
$adjusted_price = ($row_base_price - array_sum($base_taxes) + array_sum($taxes)) / $values['quantity'];
@ -851,7 +869,7 @@ class Woocommerce_Cart {
$discounted_price = $this->get_discounted_price( $values, $adjusted_price, true );
$discounted_taxes = $this->tax->calc_tax( $discounted_price * $values['quantity'], $tax_rates, true );
$discounted_tax_amount = $this->tax->get_tax_total($discounted_taxes); // Sum taxes - round also to prevent rounding errors
$discounted_tax_amount = array_sum($discounted_taxes); // Sum taxes
/**
* Regular tax calculation (customer inside base and the tax class is unmodified
@ -859,17 +877,17 @@ class Woocommerce_Cart {
else :
// Base tax for line before discount - we will store this in the order data
$tax_amount = $this->tax->get_tax_total($this->tax->calc_tax( $base_price * $values['quantity'], $tax_rates, true ));
$tax_amount = array_sum($this->tax->calc_tax( $base_price * $values['quantity'], $tax_rates, true ));
// Line subtotal + tax
$line_subtotal_tax = round($tax_amount, 2);
$line_subtotal = ($base_price * $values['quantity']) - $line_subtotal_tax;
$line_subtotal_tax = ( get_option('woocommerce_tax_round_at_subtotal')=='no' ) ? round($tax_amount, 2) : $tax_amount;
$line_subtotal = ($base_price * $values['quantity']) - round($line_subtotal_tax, 2);
// Calc prices and tax (discounted)
$discounted_price = $this->get_discounted_price( $values, $base_price, true );
$discounted_taxes = $this->tax->calc_tax( $discounted_price * $values['quantity'], $tax_rates, true );
$discounted_tax_amount = $this->tax->get_tax_total($discounted_taxes); // Sum taxes - round also to prevent rounding errors
$discounted_tax_amount = array_sum($discounted_taxes); // Sum taxes
endif;
// Tax rows - merge the totals we just got
@ -888,9 +906,9 @@ class Woocommerce_Cart {
endif;
// Line prices - round tax so price is correctly calculated
$line_tax = round($discounted_tax_amount, 2);
$line_total = ($discounted_price * $values['quantity']) - $line_tax;
// Line prices
$line_tax = ( get_option('woocommerce_tax_round_at_subtotal')=='no' ) ? round($discounted_tax_amount, 2) : $discounted_tax_amount;
$line_total = ($discounted_price * $values['quantity']) - round($line_tax, 2);
// Add any product discounts (after tax)
$this->apply_product_discounts_after_tax( $values, $line_total + $discounted_tax_amount );
@ -930,11 +948,11 @@ class Woocommerce_Cart {
$tax_rates = $this->tax->get_rates( $_product->get_tax_class() );
// Base tax for line before discount - we will store this in the order data
$tax_amount = $this->tax->get_tax_total($this->tax->calc_tax( $base_price * $values['quantity'], $tax_rates, false ));
$tax_amount = array_sum($this->tax->calc_tax( $base_price * $values['quantity'], $tax_rates, false ));
// Now calc product rates
$discounted_taxes = $this->tax->calc_tax( $discounted_price * $values['quantity'], $tax_rates, false );
$discounted_tax_amount = $this->tax->get_tax_total( $discounted_taxes );
$discounted_tax_amount = array_sum( $discounted_taxes );
// Tax rows - merge the totals we just got
foreach (array_keys($this->taxes + $discounted_taxes) as $key) {
@ -969,16 +987,12 @@ class Woocommerce_Cart {
endif;
// Set tax total to sum of all tax rows
if ( get_option( 'woocommerce_tax_round_at_subtotal' ) == 'yes' ) :
$this->tax_total = $this->tax->get_tax_total( $this->taxes );
else :
$this->tax_total = array_sum( $this->taxes );
endif;
$this->tax_total = $this->tax->get_tax_total( $this->taxes );
// VAT exemption done at this point - so all totals are correct before exemption
if ($woocommerce->customer->is_vat_exempt() || (is_cart() && get_option('woocommerce_display_cart_taxes')=='no')) :
$this->shipping_tax_total = $this->tax_total = 0;
$this->taxes = array();
$this->taxes = $this->shipping_taxes = array();
endif;
// Cart Discounts (after tax)
@ -990,17 +1004,18 @@ class Woocommerce_Cart {
// Cart Shipping
$this->calculate_shipping();
// VAT exemption done again to wipe shipping tax
// VAT exemption for shipping
if ($woocommerce->customer->is_vat_exempt()) :
$this->shipping_tax_total = $this->tax_total = 0;
$this->taxes = array();
$this->shipping_tax_total = 0;
$this->shipping_taxes = array();
endif;
// Taxes Rounding - taxes now include shipping taxes
$this->taxes = $this->tax->get_taxes_rounded( $this->taxes );
// Round cart/shipping tax rows
$this->taxes = array_map(array(&$this->tax, 'round'), $this->taxes);
$this->shipping_taxes = array_map(array(&$this->tax, 'round'), $this->shipping_taxes);
// Allow plugins to hook and alter totals before final total is calculated
do_action('woocommerce_calculate_totals', $this);
do_action('woocommerce_calculate_totals', $this);
/**
* Grand Total
@ -1037,15 +1052,8 @@ class Woocommerce_Cart {
$this->shipping_total = $woocommerce->shipping->shipping_total; // Shipping Total
$this->shipping_label = $woocommerce->shipping->shipping_label; // Shipping Label
$this->shipping_tax_total = array_sum( $woocommerce->shipping->shipping_taxes ); // Shipping tax amount
// Merge Shipping tax rows with cart tax rows
if (is_array($woocommerce->shipping->shipping_taxes) && sizeof($woocommerce->shipping->shipping_taxes)>0) :
// Tax rows - merge the totals we just got
foreach (array_keys($this->taxes + $woocommerce->shipping->shipping_taxes) as $key) {
$this->taxes[$key] = (isset($woocommerce->shipping->shipping_taxes[$key]) ? $woocommerce->shipping->shipping_taxes[$key] : 0) + (isset($this->taxes[$key]) ? $this->taxes[$key] : 0);
}
endif;
$this->shipping_taxes = $woocommerce->shipping->shipping_taxes; // Shipping Taxes
$this->shipping_tax_total = $this->tax->get_tax_total( $this->shipping_taxes ); // Shipping tax amount
}
/**
@ -1139,7 +1147,7 @@ class Woocommerce_Cart {
function add_discount( $coupon_code ) {
global $woocommerce;
$the_coupon = new Woocommerce_Coupon($coupon_code);
$the_coupon = new WC_Coupon($coupon_code);
if ($the_coupon->id) :
@ -1161,7 +1169,7 @@ class Woocommerce_Cart {
endif;
foreach ($this->applied_coupons as $code) :
$coupon = new Woocommerce_Coupon($code);
$coupon = new WC_Coupon($code);
if ($coupon->individual_use=='yes') :
$this->applied_coupons = array();
endif;
@ -1193,13 +1201,13 @@ class Woocommerce_Cart {
if ($type == 1) :
if ($this->applied_coupons) foreach ($this->applied_coupons as $index => $code) :
$coupon = new Woocommerce_Coupon( $code );
$coupon = new WC_Coupon( $code );
if ( $coupon->apply_before_tax() ) unset($this->applied_coupons[$index]);
endforeach;
$_SESSION['coupons'] = $this->applied_coupons;
elseif ($type == 2) :
if ($this->applied_coupons) foreach ($this->applied_coupons as $index => $code) :
$coupon = new Woocommerce_Coupon( $code );
$coupon = new WC_Coupon( $code );
if ( !$coupon->apply_before_tax() ) unset($this->applied_coupons[$index]);
endforeach;
$_SESSION['coupons'] = $this->applied_coupons;
@ -1369,6 +1377,10 @@ class Woocommerce_Cart {
if (!$compound && $this->tax->is_compound( $key )) continue;
$total += $tax;
endforeach;
foreach ($this->shipping_taxes as $key => $tax) :
if (!$compound && $this->tax->is_compound( $key )) continue;
$total += $tax;
endforeach;
return $total;
}
@ -1401,4 +1413,12 @@ class Woocommerce_Cart {
endif;
return false;
}
}
/** Depreciated */
class woocommerce_cart extends WC_Cart {
public function __construct() {
_deprecated_function( 'woocommerce_cart', '1.4', 'WC_Cart()' );
parent::__construct();
}
}

View File

@ -4,12 +4,12 @@
*
* The WooCommerce checkout class handles the checkout process, collecting user data and processing the payment.
*
* @class Woocommerce_Checkout
* @class WC_Checkout
* @package WooCommerce
* @category Class
* @author WooThemes
*/
class Woocommerce_Checkout {
class WC_Checkout {
var $posted;
var $checkout_fields;
@ -220,7 +220,7 @@ class Woocommerce_Checkout {
$this->posted[$key] = apply_filters('woocommerce_process_checkout_field_' . $key, $this->posted[$key]);
// Validation: Required fields
if ( isset($field['required']) && $field['required'] && empty($this->posted[$key]) ) $woocommerce->add_error( $field['label'] . ' ' . __('is a required field.', 'woocommerce') );
if ( isset($field['required']) && $field['required'] && empty($this->posted[$key]) ) $woocommerce->add_error( '<strong>' . $field['label'] . '</strong> ' . __('is a required field.', 'woocommerce') );
if (!empty($this->posted[$key])) :
// Special handling for validation and formatting
@ -229,16 +229,16 @@ class Woocommerce_Checkout {
case "shipping_postcode" :
$this->posted[$key] = strtolower(str_replace(' ', '', $this->posted[$key]));
if (!$validation->is_postcode( $this->posted[$key], $_POST['billing_country'] )) : $woocommerce->add_error( $field['label'] . __(' (billing) is not a valid postcode/ZIP.', 'woocommerce') );
if (!$validation->is_postcode( $this->posted[$key], $_POST['billing_country'] )) : $woocommerce->add_error( '<strong>' . $field['label'] . '</strong> ' . __('(billing) is not a valid postcode/ZIP.', 'woocommerce') );
else :
$this->posted[$key] = $validation->format_postcode( $this->posted[$key], $_POST['billing_country'] );
endif;
break;
case "billing_phone" :
if (!$validation->is_phone( $this->posted[$key] )) : $woocommerce->add_error( $field['label'] . ' ' . __('is not a valid number.', 'woocommerce') ); endif;
if (!$validation->is_phone( $this->posted[$key] )) : $woocommerce->add_error( '<strong>' . $field['label'] . '</strong> ' . __('is not a valid number.', 'woocommerce') ); endif;
break;
case "billing_email" :
if (!$validation->is_email( $this->posted[$key] )) : $woocommerce->add_error( $field['label'] . ' ' . __('is not a valid email address.', 'woocommerce') ); endif;
if (!$validation->is_email( $this->posted[$key] )) : $woocommerce->add_error( '<strong>' . $field['label'] . '</strong> ' . __('is not a valid email address.', 'woocommerce') ); endif;
break;
endswitch;
endif;
@ -371,7 +371,7 @@ class Woocommerce_Checkout {
endif;
// Create Order (send cart variable so we can record items and reduce inventory). Only create if this is a new order, not if the payment was rejected last time.
$_tax = new Woocommerce_Tax();
$_tax = new WC_Tax();
$order_data = array(
'post_type' => 'shop_order',
@ -406,10 +406,10 @@ class Woocommerce_Checkout {
'name' => $_product->get_title(),
'qty' => (int) $values['quantity'],
'item_meta' => $item_meta->meta,
'line_subtotal' => number_format($values['line_subtotal'], 2, '.', ''), // Line subtotal (before discounts)
'line_subtotal_tax' => number_format($values['line_subtotal_tax'], 2, '.', ''), // Line tax (before discounts)
'line_total' => number_format($values['line_total'], 2, '.', ''), // Line total (after discounts)
'line_tax' => number_format($values['line_tax'], 2, '.', ''), // Line Tax (after discounts)
'line_subtotal' => rtrim(rtrim(number_format($values['line_subtotal'], 4, '.', ''), '0'), '.'), // Line subtotal (before discounts)
'line_subtotal_tax' => rtrim(rtrim(number_format($values['line_subtotal_tax'], 4, '.', ''), '0'), '.'), // Line tax (before discounts)
'line_total' => rtrim(rtrim(number_format($values['line_total'], 4, '.', ''), '0'), '.'), // Line total (after discounts)
'line_tax' => rtrim(rtrim(number_format($values['line_tax'], 4, '.', ''), '0'), '.'), // Line Tax (after discounts)
'tax_class' => $_product->get_tax_class() // Tax class (adjusted by filters)
), $values);
endforeach;
@ -492,11 +492,6 @@ class Woocommerce_Checkout {
// Post
update_post_meta( $order_id, '_' . $key, $this->posted[$field_key] );
// User
if ($user_id>0) :
update_user_meta( $user_id, $key, $this->posted[$field_key] );
endif;
else :
// Post
update_post_meta( $order_id, '_' . $key, $this->posted[$key] );
@ -513,21 +508,24 @@ class Woocommerce_Checkout {
// Save any other user meta
if ($user_id) do_action('woocommerce_checkout_update_user_meta', $user_id, $this->posted);
// Put order taxes into an array to store
// Prepare order taxes for storage
$order_taxes = array();
if (is_array($woocommerce->cart->taxes) && sizeof($woocommerce->cart->taxes)>0) foreach ( $woocommerce->cart->taxes as $key => $tax ) :
foreach (array_keys($woocommerce->cart->taxes + $woocommerce->cart->shipping_taxes) as $key) {
$is_compound = ($woocommerce->cart->tax->is_compound( $key )) ? 1 : 0;
$cart_tax = (isset($woocommerce->cart->taxes[$key])) ? $woocommerce->cart->taxes[$key] : 0;
$shipping_tax = (isset($woocommerce->cart->shipping_taxes[$key])) ? $woocommerce->cart->shipping_taxes[$key] : 0;
$order_taxes[] = array(
'label' => $woocommerce->cart->tax->get_rate_label( $key ),
'compound' => $is_compound,
'total' => number_format($tax, 2, '.', '')
'cart_tax' => number_format($cart_tax, 2, '.', ''),
'shipping_tax' => number_format($shipping_tax, 2, '.', '')
);
endforeach;
}
// Save other order meta fields
update_post_meta( $order_id, '_shipping_method', $this->posted['shipping_method']);
update_post_meta( $order_id, '_payment_method', $this->posted['payment_method']);
@ -583,7 +581,7 @@ class Woocommerce_Checkout {
else :
$order = new Woocommerce_Order($order_id);
$order = new WC_Order($order_id);
// No payment was required for order
$order->payment_complete();
@ -644,4 +642,12 @@ class Woocommerce_Checkout {
endif;
}
}
/** Depreciated */
class woocommerce_checkout extends WC_Checkout {
public function __construct() {
_deprecated_function( 'woocommerce_checkout', '1.4', 'WC_Checkout()' );
parent::__construct();
}
}

View File

@ -4,12 +4,12 @@
*
* The WooCommerce countries class stores country/state data.
*
* @class Woocommerce_Countries
* @class WC_Countries
* @package WooCommerce
* @category Class
* @author WooThemes
*/
class Woocommerce_Countries {
class WC_Countries {
var $countries;
var $states;
@ -474,7 +474,7 @@ class Woocommerce_Countries {
}
function inc_tax_or_vat() {
$return = ( in_array($this->get_base_country(), $this->get_european_union_countries()) ) ? __('(inc. VAT)', 'woocommerce') : __('(inc. tax)', 'woocommerce');
$return = ( in_array($this->get_base_country(), $this->get_european_union_countries()) ) ? __('(incl. VAT)', 'woocommerce') : __('(incl. tax)', 'woocommerce');
return apply_filters('woocommerce_countries_inc_tax_or_vat', $return);
}
@ -923,4 +923,12 @@ class Woocommerce_Countries {
// Return
return $address_fields;
}
}
/** Depreciated */
class woocommerce_countries extends WC_Countries {
public function __construct() {
_deprecated_function( 'woocommerce_countries', '1.4', 'WC_Countries()' );
parent::__construct();
}
}

View File

@ -4,12 +4,12 @@
*
* The WooCommerce coupons class gets coupon data from storage
*
* @class Woocommerce_Coupon
* @class WC_Coupon
* @package WooCommerce
* @category Class
* @author WooThemes
*/
class Woocommerce_Coupon {
class WC_Coupon {
var $code;
var $id;
@ -24,7 +24,7 @@ class Woocommerce_Coupon {
var $free_shipping;
/** get coupon with $code */
function woocommerce_coupon( $code ) {
function __construct( $code ) {
$this->code = $code;
@ -137,3 +137,11 @@ class Woocommerce_Coupon {
return false;
}
}
/** Depreciated */
class woocommerce_coupon extends WC_Coupon {
public function __construct( $code ) {
_deprecated_function( 'woocommerce_coupon', '1.4', 'WC_Coupon()' );
parent::__construct( $code );
}
}

View File

@ -4,12 +4,12 @@
*
* The WooCommerce customer class handles storage of the current customer's data, such as location.
*
* @class Woocommerce_Customer
* @class WC_Customer
* @package WooCommerce
* @category Class
* @author WooThemes
*/
class Woocommerce_Customer {
class WC_Customer {
/** constructor */
function __construct() {
@ -203,16 +203,16 @@ class Woocommerce_Customer {
if ($result->order_id>0) :
$order = new Woocommerce_Order( $result->order_id );
$order = new WC_Order( $result->order_id );
if ( $order->status!='completed' && $order->status!='processing' ) continue;
$product_post = get_post( $result->product_id );
if ($product_post->post_type=='product_variation') :
$_product = new Woocommerce_Product_Variation( $result->product_id );
$_product = new WC_Product_Variation( $result->product_id );
else :
$_product = new Woocommerce_Product( $result->product_id );
$_product = new WC_Product( $result->product_id );
endif;
if ($_product->exists) :
@ -239,5 +239,12 @@ class Woocommerce_Customer {
return apply_filters('woocommerce_customer_get_downloadable_products', $downloads);
}
}
/** Depreciated */
class woocommerce_customer extends WC_Coupon {
public function __construct() {
_deprecated_function( 'woocommerce_customer', '1.4', 'WC_Customer()' );
parent::__construct();
}
}

View File

@ -2,12 +2,12 @@
/**
* WooCommerce Emails Class
*
* @class Woocommerce_Email
* @class WC_Email
* @package WooCommerce
* @category Class
* @author WooThemes
*/
class Woocommerce_Email {
class WC_Email {
private $_from_address;
private $_from_name;
@ -114,7 +114,7 @@ class Woocommerce_Email {
function new_order( $order_id ) {
global $order, $email_heading;
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
$email_heading = __('New Customer Order', 'woocommerce');
@ -139,7 +139,7 @@ class Woocommerce_Email {
function customer_processing_order( $order_id ) {
global $order, $email_heading;
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
$email_heading = __('Order Received', 'woocommerce');
@ -167,7 +167,7 @@ class Woocommerce_Email {
function customer_completed_order( $order_id ) {
global $order, $email_heading;
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
if ($order->has_downloadable_item()) :
$subject = __('[%s] Order Complete/Download Links', 'woocommerce');
@ -242,7 +242,7 @@ class Woocommerce_Email {
if (!$order_id || !$customer_note) return;
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
$email_heading = __('A note has been added to your order', 'woocommerce');
@ -372,4 +372,12 @@ class Woocommerce_Email {
$this->send( $user_email, $subject, $message );
}
}
/** Depreciated */
class woocommerce_email extends WC_Email {
public function __construct() {
_deprecated_function( 'woocommerce_email', '1.4', 'WC_Email()' );
parent::__construct();
}
}

View File

@ -2,12 +2,12 @@
/**
* Allows log files to be written to for debugging purposes.
*
* @class Woocommerce_Logger
* @class WC_Logger
* @package WooCommerce
* @category Class
* @author WooThemes
*/
class Woocommerce_Logger {
class WC_Logger {
private $handles;
@ -65,4 +65,12 @@ class Woocommerce_Logger {
}
}
/** Depreciated */
class woocommerce_logger extends WC_Logger {
public function __construct() {
_deprecated_function( 'woocommerce_logger', '1.4', 'WC_Logger()' );
parent::__construct();
}
}

View File

@ -4,12 +4,12 @@
*
* The WooCommerce order class handles order data.
*
* @class Woocommerce_Order
* @class WC_Order
* @package WooCommerce
* @category Class
* @author WooThemes
*/
class Woocommerce_Order {
class WC_Order {
var $id;
var $status;
@ -59,7 +59,7 @@ class Woocommerce_Order {
var $formatted_shipping_address;
/** Get the order if ID is passed, otherwise the order is new and empty */
function woocommerce_order( $id = '' ) {
function __construct( $id = '' ) {
$this->prices_include_tax = (get_option('woocommerce_prices_include_tax')=='yes') ? true : false;
$this->display_totals_ex_tax = (get_option('woocommerce_display_totals_excluding_tax')=='yes') ? true : false;
$this->display_cart_ex_tax = (get_option('woocommerce_display_cart_prices_excluding_tax')=='yes') ? true : false;
@ -277,30 +277,39 @@ class Woocommerce_Order {
/** Get item subtotal - this is the cost before discount */
function get_item_subtotal( $item, $inc_tax = false ) {
function get_item_subtotal( $item, $inc_tax = false, $round = true ) {
if ($inc_tax) :
return number_format( ( $item['line_subtotal'] + $item['line_subtotal_tax'] / $item['qty'] ) , 2, '.', '');
$price = ( $item['line_subtotal'] + $item['line_subtotal_tax'] / $item['qty'] );
else :
return number_format( ( $item['line_subtotal'] / $item['qty'] ), 2, '.', '');
$price = ( $item['line_subtotal'] / $item['qty'] );
endif;
return ($round) ? number_format( $price, 2, '.', '') : $price;
}
/** Get line subtotal - this is the cost before discount */
function get_line_subtotal( $item, $inc_tax = false ) {
function get_line_subtotal( $item, $inc_tax = false, $round = true ) {
if ($inc_tax) :
return number_format( $item['line_subtotal'] + $item['line_subtotal_tax'], 2, '.', '');
$price = $item['line_subtotal'] + $item['line_subtotal_tax'];
else :
return number_format( $item['line_subtotal'], 2, '.', '');
$price = $item['line_subtotal'];
endif;
return ($round) ? number_format( $price, 2, '.', '') : $price;
}
/** Calculate item cost - useful for gateways */
function get_item_total( $item, $inc_tax = false ) {
function get_item_total( $item, $inc_tax = false, $round = true ) {
if ($inc_tax) :
return number_format( ( ( $item['line_total'] + $item['line_tax'] ) / $item['qty'] ), 2, '.', '');
$price = ( ( $item['line_total'] + $item['line_tax'] ) / $item['qty'] );
else :
return number_format( $item['line_total'] / $item['qty'] , 2, '.', '');
$price = $item['line_total'] / $item['qty'];
endif;
return ($round) ? number_format( $price, 2, '.', '') : $price;
}
/** Calculate item tax - useful for gateways */
function get_item_tax( $item, $round = true ) {
$price = $item['line_tax'] / $item['qty'];
return ($round) ? number_format( $price, 2, '.', '') : $price;
}
/** Calculate line total - useful for gateways */
@ -312,6 +321,22 @@ class Woocommerce_Order {
endif;
}
/** Calculate line tax - useful for gateways */
function get_line_tax( $item ) {
return number_format( $item['line_tax'], 2, '.', '');
}
/** Depreciated functions */
function get_item_cost( $item, $inc_tax = false ) {
_deprecated_function( __FUNCTION__, '1.4', 'get_item_total()' );
return $this->get_item_total( $item, $inc_tax );
}
function get_row_cost( $item, $inc_tax = false ) {
_deprecated_function( __FUNCTION__, '1.4', 'get_row_cost()' );
return $this->get_line_total( $item, $inc_tax );
}
/** Gets line subtotal - formatted for display */
function get_formatted_line_subtotal( $item ) {
$subtotal = 0;
@ -371,7 +396,7 @@ class Woocommerce_Order {
if (isset($tax['compound']) && $tax['compound']) continue;
$subtotal = $subtotal + $tax['total'];
$subtotal = $subtotal + $tax['cart_tax'] + $tax['shipping_tax'];
endforeach;
@ -421,9 +446,9 @@ class Woocommerce_Order {
function get_product_from_item( $item ) {
if (isset($item['variation_id']) && $item['variation_id']>0) :
$_product = new Woocommerce_Product_Variation( $item['variation_id'] );
$_product = new WC_Product_Variation( $item['variation_id'] );
else :
$_product = new Woocommerce_Product( $item['id'] );
$_product = new WC_Product( $item['id'] );
endif;
return $_product;
@ -453,8 +478,8 @@ class Woocommerce_Order {
foreach ($this->get_taxes() as $tax) :
if ($tax['compound']) : $has_compound_tax = true; continue; endif;
if ($tax['total']==0) continue;
$total_rows[ $tax['label'] ] = woocommerce_price( $tax['total'] );
if (($tax['cart_tax']+$tax['shipping_tax'])==0) continue;
$total_rows[ $tax['label'] ] = woocommerce_price( ($tax['cart_tax']+$tax['shipping_tax']) );
endforeach;
if ($has_compound_tax) :
@ -465,8 +490,8 @@ class Woocommerce_Order {
foreach ($this->get_taxes() as $tax) :
if (!$tax['compound']) continue;
if ($tax['total']==0) continue;
$total_rows[ $tax['label'] ] = woocommerce_price( $tax['total'] );
if (($tax['cart_tax']+$tax['shipping_tax'])==0) continue;
$total_rows[ $tax['label'] ] = woocommerce_price( ($tax['cart_tax']+$tax['shipping_tax']) );
endforeach;
else :
@ -909,4 +934,12 @@ class order_item_meta {
endif;
}
}
/** Depreciated */
class woocommerce_order extends WC_Order {
public function __construct( $id = '' ) {
_deprecated_function( 'woocommerce_order', '1.4', 'WC_Order()' );
parent::__construct( $id );
}
}

View File

@ -4,12 +4,12 @@
*
* The WooCommerce product variation class handles product variation data.
*
* @class Woocommerce_Product_Variation
* @class WC_Product_Variation
* @package WooCommerce
* @category Class
* @author WooThemes
*/
class Woocommerce_Product_Variation extends Woocommerce_Product {
class WC_Product_Variation extends WC_Product {
var $variation_data;
var $variation_id;
@ -27,7 +27,7 @@ class Woocommerce_Product_Variation extends Woocommerce_Product {
*
* @param int $id ID of the product to load
*/
function woocommerce_product_variation( $variation_id, $parent_id = '', $parent_custom_fields = '' ) {
function __construct( $variation_id, $parent_id = '', $parent_custom_fields = '' ) {
$this->variation_id = $variation_id;
@ -213,7 +213,7 @@ class Woocommerce_Product_Variation extends Woocommerce_Product {
if (!$this->is_in_stock()) :
// Check parent
$parent_product = new Woocommerce_Product( $this->id );
$parent_product = new WC_Product( $this->id );
if ($parent_product->managing_stock()) :
if (!$parent_product->backorders_allowed()) :
@ -261,4 +261,12 @@ class Woocommerce_Product_Variation extends Woocommerce_Product {
endif;
}
}
/** Depreciated */
class woocommerce_product_variation extends WC_Product_Variation {
public function __construct( $variation_id, $parent_id = '', $parent_custom_fields = '' ) {
_deprecated_function( 'woocommerce_product_variation', '1.4', 'WC_Product_Variation()' );
parent::__construct( $variation_id, $parent_id, $parent_custom_fields );
}
}

View File

@ -4,12 +4,12 @@
*
* The WooCommerce product class handles individual product data.
*
* @class Woocommerce_Product
* @class WC_Product
* @package WooCommerce
* @category Class
* @author WooThemes
*/
class Woocommerce_Product {
class WC_Product {
var $id;
var $product_custom_fields;
@ -51,7 +51,7 @@ class Woocommerce_Product {
*
* @param int $id ID of the product to load
*/
function woocommerce_product( $id ) {
function __construct( $id ) {
$this->id = (int) $id;
@ -178,9 +178,9 @@ class Woocommerce_Product {
function get_child( $child_id ) {
if ($this->is_type('variable')) :
$child = new Woocommerce_Product_Variation( $child_id, $this->id, $this->product_custom_fields );
$child = new WC_Product_Variation( $child_id, $this->id, $this->product_custom_fields );
else :
$child = new Woocommerce_Product( $child_id );
$child = new WC_Product( $child_id );
endif;
return $child;
}
@ -304,10 +304,10 @@ class Woocommerce_Product {
if ($this->is_type('variable')) :
$url = add_query_arg('add-to-cart', 'variation');
$url = add_query_arg('product', $this->id, $url);
$url = add_query_arg('product_id', $this->id, $url);
elseif ( $this->has_child() ) :
$url = add_query_arg('add-to-cart', 'group');
$url = add_query_arg('product', $this->id, $url);
$url = add_query_arg('product_id', $this->id, $url);
else :
$url = add_query_arg('add-to-cart', $this->id);
endif;
@ -493,25 +493,6 @@ class Woocommerce_Product {
function get_price() {
return $this->price;
}
/** Returns the price (including tax) - ignores tax_class filters */
function get_price_including_tax( $round = true ) {
$price = $this->price;
if ( $this->is_taxable() && get_option('woocommerce_prices_include_tax')=='no' ) :
$_tax = new Woocommerce_Tax();
$tax_rates = $_tax->get_shop_base_rate( $this->tax_class );
$taxes = $_tax->calc_tax( $price, $tax_rates, false );
$tax_amount = $_tax->get_tax_total( $taxes );
$price = round( $price + $tax_amount, 2);
endif;
return $price;
}
/** Returns the price (excluding tax) - ignores tax_class filters since the price may *include* tax and thus needs subtracting */
function get_price_excluding_tax() {
@ -520,7 +501,7 @@ class Woocommerce_Product {
if ( $this->is_taxable() && get_option('woocommerce_prices_include_tax')=='yes' ) :
$_tax = new Woocommerce_Tax();
$_tax = new WC_Tax();
$tax_rates = $_tax->get_shop_base_rate( $this->tax_class );
@ -1041,4 +1022,12 @@ class Woocommerce_Product {
endif;
}
}
/** Depreciated */
class woocommerce_product extends WC_Product {
public function __construct( $id ) {
_deprecated_function( 'woocommerce_product', '1.4', 'WC_Product()' );
parent::__construct( $id );
}
}

View File

@ -2,12 +2,12 @@
/**
* Contains the query functions for WooCommerce which alter the front-end post queries and loops.
*
* @class Woocommerce_Query
* @class WC_Query
* @package WooCommerce
* @category Class
* @author WooThemes
*/
class Woocommerce_Query {
class WC_Query {
var $unfiltered_product_ids = array(); // Unfiltered product ids (before layered nav etc)
var $filtered_product_ids = array(); // Filtered product ids (after layered nav)

View File

@ -2,12 +2,12 @@
/**
* Admin Settings API used by Shipping Methods and Payment Gateways
*
* @class Woocommerce_Settings_Api
* @class WC_Settings_Api
* @package WooCommerce
* @category Class
* @author WooThemes
*/
class Woocommerce_Settings_Api {
class WC_Settings_Api {
var $plugin_id = 'woocommerce_';
var $settings = array();
@ -446,4 +446,12 @@ class Woocommerce_Settings_Api {
return $value;
} // End validate_select_field()
}
/** Depreciated */
class woocommerce_settings_api extends WC_Settings_Api {
public function __construct() {
_deprecated_function( 'woocommerce_settings_api', '1.4', 'WC_Settings_Api()' );
parent::__construct();
}
}

View File

@ -2,12 +2,12 @@
/**
* Performs tax calculations and loads tax rates.
*
* @class Woocommerce_Tax
* @class WC_Tax
* @package WooCommerce
* @category Class
* @author WooThemes
*/
class Woocommerce_Tax {
class WC_Tax {
var $rates; // Simple array of rates
var $parsed_rates; // Parsed into array with counties/states as keys
@ -519,16 +519,6 @@ class Woocommerce_Tax {
return array_sum(array_map(array(&$this, 'round'), $taxes));
}
/**
* Round tax lines
*
* @param array
* @return float
*/
function get_taxes_rounded( $taxes ) {
return array_map(array(&$this, 'round'), $taxes);
}
/**
* Round to 2 DP
*/
@ -536,4 +526,12 @@ class Woocommerce_Tax {
return round($in, 2);
}
}
/** Depreciated */
class woocommerce_tax extends WC_Tax {
public function __construct() {
_deprecated_function( 'woocommerce_tax', '1.4', 'WC_Tax()' );
parent::__construct();
}
}

View File

@ -2,13 +2,13 @@
/**
* Contains Validation functions
*
* @class Woocommerce_Validation
* @class WC_Validation
* @package WooCommerce
* @category Class
* @author WooThemes
*/
class Woocommerce_Validation {
class WC_Validation {
/**
* Validates an email using wordpress native is_email function
@ -121,4 +121,12 @@ class Woocommerce_Validation {
return $postcode;
}
}
/** Depreciated */
class woocommerce_validation extends WC_Validation {
public function __construct() {
_deprecated_function( 'woocommerce_validation', '1.4', 'WC_Validation()' );
parent::__construct();
}
}

View File

@ -4,12 +4,12 @@
*
* Provides a Bank Transfer Payment Gateway. Based on code by Mike Pepper.
*
* @class Woocommerce_Bacs
* @class WC_BACS
* @package WooCommerce
* @category Payment Gateways
* @author WooThemes
*/
class Woocommerce_Bacs extends Woocommerce_Payment_Gateway {
class WC_BACS extends WC_Payment_Gateway {
public function __construct() {
$this->id = 'bacs';
@ -194,7 +194,7 @@ class Woocommerce_Bacs extends Woocommerce_Payment_Gateway {
function process_payment( $order_id ) {
global $woocommerce;
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
// Mark as on-hold (we're awaiting the payment)
$order->update_status('on-hold', __('Awaiting BACS payment', 'woocommerce'));
@ -221,7 +221,7 @@ class Woocommerce_Bacs extends Woocommerce_Payment_Gateway {
* Add the gateway to WooCommerce
**/
function add_bacs_gateway( $methods ) {
$methods[] = 'woocommerce_bacs'; return $methods;
$methods[] = 'WC_BACS'; return $methods;
}
add_filter('woocommerce_payment_gateways', 'add_bacs_gateway' );

View File

@ -4,12 +4,12 @@
*
* Provides a Cheque Payment Gateway, mainly for testing purposes.
*
* @class Woocommerce_Cheque
* @class WC_Cheque
* @package WooCommerce
* @category Payment Gateways
* @author WooThemes
*/
class Woocommerce_Cheque extends Woocommerce_Payment_Gateway {
class WC_Cheque extends WC_Payment_Gateway {
public function __construct() {
$this->id = 'cheque';
@ -109,7 +109,7 @@ class Woocommerce_Cheque extends Woocommerce_Payment_Gateway {
function process_payment( $order_id ) {
global $woocommerce;
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
// Mark as on-hold (we're awaiting the cheque)
$order->update_status('on-hold', __('Awaiting cheque payment', 'woocommerce'));
@ -137,7 +137,7 @@ class Woocommerce_Cheque extends Woocommerce_Payment_Gateway {
* Add the gateway to WooCommerce
**/
function add_cheque_gateway( $methods ) {
$methods[] = 'woocommerce_cheque'; return $methods;
$methods[] = 'WC_Cheque'; return $methods;
}
add_filter('woocommerce_payment_gateways', 'add_cheque_gateway' );

View File

@ -4,12 +4,12 @@ new Woocommercevery Gateway
*
* Provides a Cash on Delivery Payment Gateway.
*
* @class Woocommerce_Cod
* @class WC_COD
* @package WooCommerce
* @category Payment Gateways
* @author Patrick Garman (www.patrickgarman.com)
*/
class Woocommerce_Cod extends Woocommerce_Payment_Gateway {
class WC_COD extends WC_Payment_Gateway {
function __construct() {
$this->id = 'cod';
@ -94,5 +94,5 @@ class Woocommerce_Cod extends Woocommerce_Payment_Gateway {
}
// Adding Gateway to WooCommerce Gateways
function woocommerce_cod_add_gateway ($methods) { $methods[] = 'woocommerce_cod'; return $methods; }
function woocommerce_cod_add_gateway ($methods) { $methods[] = 'WC_COD'; return $methods; }
add_filter ('woocommerce_payment_gateways', 'woocommerce_cod_add_gateway');

View File

@ -4,12 +4,12 @@
*
* Extended by individual payment gateways to handle payments.
*
* @class Woocommerce_Payment_Gateway
* @class WC_Payment_Gateway
* @package WooCommerce
* @category Payment Gateways
* @author WooThemes
*/
class Woocommerce_Payment_Gateway extends Woocommerce_Settings_Api {
class WC_Payment_Gateway extends WC_Settings_Api {
var $id;
var $title;
@ -111,4 +111,12 @@ class Woocommerce_Payment_Gateway extends Woocommerce_Settings_Api {
if ($this->description) echo wpautop(wptexturize($this->description));
}
}
/** Depreciated */
class woocommerce_payment_gateway extends WC_Payment_Gateway {
public function __construct() {
_deprecated_function( 'woocommerce_payment_gateway', '1.4', 'WC_Payment_Gateway()' );
parent::__construct();
}
}

View File

@ -4,12 +4,12 @@
*
* Loads payment gateways via hooks for use in the store.
*
* @class Woocommerce_Payment_Gateways
* @class WC_Payment_Gateways
* @package WooCommerce
* @category Payment Gateways
* @author WooThemes
*/
class Woocommerce_Payment_Gateways {
class WC_Payment_Gateways {
var $payment_gateways;

View File

@ -4,12 +4,12 @@
*
* Provides a PayPal Standard Payment Gateway.
*
* @class Woocommerce_Paypal
* @class WC_Paypal
* @package WooCommerce
* @category Payment Gateways
* @author WooThemes
*/
class Woocommerce_Paypal extends Woocommerce_Payment_Gateway {
class WC_Paypal extends WC_Payment_Gateway {
public function __construct() {
global $woocommerce;
@ -121,6 +121,12 @@ class Woocommerce_Paypal extends Woocommerce_Payment_Gateway {
'label' => __( 'Send shipping details to PayPal. Since PayPal verifies addresses sent to it this can cause errors, therefore we recommend disabling this option.', 'woocommerce' ),
'default' => 'no'
),
'ask_for_shipping' => array(
'title' => __( 'Hide shipping', 'woocommerce' ),
'type' => 'checkbox',
'label' => __( 'Send shipping details to PayPal. Since PayPal verifies addresses sent to it this can cause errors, therefore we recommend disabling this option.', 'woocommerce' ),
'default' => 'no'
),
'testmode' => array(
'title' => __( 'PayPal sandbox', 'woocommerce' ),
'type' => 'checkbox',
@ -150,7 +156,7 @@ class Woocommerce_Paypal extends Woocommerce_Payment_Gateway {
public function generate_paypal_form( $order_id ) {
global $woocommerce;
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
if ( $this->testmode == 'yes' ):
$paypal_adr = $this->testurl . '?test_ipn=1&';
@ -195,7 +201,7 @@ class Woocommerce_Paypal extends Woocommerce_Payment_Gateway {
// IPN
'notify_url' => trailingslashit(home_url()).'?paypalListener=paypal_standard_IPN',
// Address info
// Billing Address info
'first_name' => $order->billing_first_name,
'last_name' => $order->billing_last_name,
'company' => $order->billing_company,
@ -217,6 +223,17 @@ class Woocommerce_Paypal extends Woocommerce_Payment_Gateway {
if ($this->send_shipping=='yes') :
$paypal_args['no_shipping'] = 0;
$paypal_args['address_override'] = 1;
// If we are sending shipping, send shipping address instead of billing
$paypal_args['first_name'] = $order->shipping_first_name;
$paypal_args['last_name'] = $order->shipping_last_name;
$paypal_args['company'] = $order->shipping_company;
$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;
endif;
@ -233,7 +250,7 @@ class Woocommerce_Paypal extends Woocommerce_Payment_Gateway {
// Shipping Cost
if ($order->get_shipping()>0) :
$paypal_args['item_name_2'] = __('Shipping cost', 'woocommerce');
$paypal_args['item_name_2'] = __('Shipping via ', 'woocommerce') . ucwords($order->shipping_method_title);
$paypal_args['quantity_2'] = '1';
$paypal_args['amount_2'] = number_format($order->get_shipping(), 2, '.', '');
endif;
@ -250,7 +267,13 @@ class Woocommerce_Paypal extends Woocommerce_Payment_Gateway {
$item_loop++;
$item_name = $item['name'];
$product = $order->get_product_from_item($item);
$item_name = $item['name'];
if (get_option('woocommerce_enable_sku')=='yes') {
$item_name .= ' ('.$product->get_sku().')';
}
$item_meta = new order_item_meta( $item['item_meta'] );
if ($meta = $item_meta->display( true, true )) :
@ -267,7 +290,7 @@ class Woocommerce_Paypal extends Woocommerce_Payment_Gateway {
// Shipping Cost
if ($order->get_shipping()>0) :
$item_loop++;
$paypal_args['item_name_'.$item_loop] = __('Shipping cost', 'woocommerce');
$paypal_args['item_name_'.$item_loop] = __('Shipping via ', 'woocommerce') . ucwords($order->shipping_method_title);
$paypal_args['quantity_'.$item_loop] = '1';
$paypal_args['amount_'.$item_loop] = number_format($order->get_shipping(), 2, '.', '');
endif;
@ -313,7 +336,7 @@ class Woocommerce_Paypal extends Woocommerce_Payment_Gateway {
**/
function process_payment( $order_id ) {
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
return array(
'result' => 'success',
@ -416,7 +439,7 @@ class Woocommerce_Paypal extends Woocommerce_Payment_Gateway {
// Custom holds post ID
if ( !empty($posted['custom']) && !empty($posted['invoice']) ) {
$order = new Woocommerce_Order( (int) $posted['custom'] );
$order = new WC_Order( (int) $posted['custom'] );
if ($order->order_key!==$posted['invoice']) :
if ($this->debug=='yes') $this->log->add( 'paypal', 'Error: Order Key does not match invoice.' );
exit;
@ -501,7 +524,7 @@ class Woocommerce_Paypal extends Woocommerce_Payment_Gateway {
* Add the gateway to WooCommerce
**/
function add_paypal_gateway( $methods ) {
$methods[] = 'woocommerce_paypal'; return $methods;
$methods[] = 'WC_Paypal'; return $methods;
}
add_filter('woocommerce_payment_gateways', 'add_paypal_gateway' );

View File

@ -4,12 +4,12 @@
*
* A simple shipping method for a flat fee per item or per order
*
* @class Flat_Rate
* @class WC_Flat_Rate
* @package WooCommerce
* @category Shipping
* @author WooThemes
*/
class Woocommerce_Flat_Rate extends Woocommerce_Shipping_Method {
class WC_Flat_Rate extends WC_Shipping_Method {
function __construct() {
$this->id = 'flat_rate';
@ -413,7 +413,7 @@ class Woocommerce_Flat_Rate extends Woocommerce_Shipping_Method {
}
function add_flat_rate_method( $methods ) {
$methods[] = 'woocommerce_flat_rate'; return $methods;
$methods[] = 'WC_Flat_Rate'; return $methods;
}
add_filter('woocommerce_shipping_methods', 'add_flat_rate_method' );

View File

@ -4,12 +4,12 @@
*
* A simple shipping method for free shipping
*
* @class Free_Shipping
* @class WC_Free_Shipping
* @package WooCommerce
* @category Shipping
* @author WooThemes
*/
class Woocommerce_Free_Shipping extends Woocommerce_Shipping_Method {
class WC_Free_Shipping extends WC_Shipping_Method {
function __construct() {
$this->id = 'free_shipping';
@ -131,7 +131,7 @@ class Woocommerce_Free_Shipping extends Woocommerce_Shipping_Method {
if ($this->requires_coupon=="yes") :
if ($woocommerce->cart->applied_coupons) : foreach ($woocommerce->cart->applied_coupons as $code) :
$coupon = new Woocommerce_Coupon( $code );
$coupon = new WC_Coupon( $code );
if ( $coupon->enable_free_shipping() ) :
return true;
@ -171,7 +171,7 @@ class Woocommerce_Free_Shipping extends Woocommerce_Shipping_Method {
}
function add_free_shipping_method( $methods ) {
$methods[] = 'woocommerce_free_shipping'; return $methods;
$methods[] = 'WC_Free_Shipping'; return $methods;
}
add_filter('woocommerce_shipping_methods', 'add_free_shipping_method' );

View File

@ -4,13 +4,13 @@
*
* A simple shipping method allowing local delivery as a shipping method
*
* @class Local_Delivery
* @class WC_Local_Delivery
* @package WooCommerce
* @category Shipping
* @author Patrick Garman (www.patrickgarman.com)
*/
class Woocommerce_Local_Delivery extends Woocommerce_Shipping_Method {
class WC_Local_Delivery extends WC_Shipping_Method {
function __construct() {
$this->id = 'local-delivery';
@ -34,7 +34,7 @@ class Woocommerce_Local_Delivery extends Woocommerce_Shipping_Method {
function calculate_shipping() {
global $woocommerce;
$_tax = new Woocommerce_Tax();
$_tax = new WC_Tax();
if ($this->type=='free') $shipping_total = 0;
if ($this->type=='fixed') $shipping_total = $this->fee;
if ($this->type=='percent') $shipping_total = $woocommerce->cart->cart_contents_total * ($this->fee/100);
@ -94,5 +94,5 @@ class Woocommerce_Local_Delivery extends Woocommerce_Shipping_Method {
}
function add_local_delivery_method($methods) { $methods[] = 'woocommerce_local_delivery'; return $methods; }
function add_local_delivery_method($methods) { $methods[] = 'WC_Local_Delivery'; return $methods; }
add_filter('woocommerce_shipping_methods','add_local_delivery_method');

View File

@ -4,13 +4,13 @@
*
* A simple shipping method allowing free pickup as a shipping method
*
* @class Local_Pickup
* @class WC_Local_Pickup
* @package WooCommerce
* @category Shipping
* @author Patrick Garman (www.patrickgarman.com)
*/
class Woocommerce_Local_Pickup extends Woocommerce_Shipping_Method {
class WC_Local_Pickup extends WC_Shipping_Method {
function __construct() {
$this->id = 'local-pickup';
@ -32,7 +32,7 @@ class Woocommerce_Local_Pickup extends Woocommerce_Shipping_Method {
function calculate_shipping() {
global $woocommerce;
$_tax = new Woocommerce_Tax();
$_tax = new WC_Tax();
$rate = array(
'id' => $this->id,
@ -71,5 +71,5 @@ class Woocommerce_Local_Pickup extends Woocommerce_Shipping_Method {
}
function add_local_pickup_method($methods) { $methods[] = 'woocommerce_local_pickup'; return $methods; }
function add_local_pickup_method($methods) { $methods[] = 'WC_Local_Pickup'; return $methods; }
add_filter('woocommerce_shipping_methods','add_local_pickup_method');

View File

@ -4,12 +4,12 @@
*
* Extended by shipping methods to handle shipping calculations etc.
*
* @class Woocommerce_Shipping_Method
* @class WC_Shipping_Method
* @package WooCommerce
* @category Shipping
* @author WooThemes
*/
class Woocommerce_Shipping_Method extends Woocommerce_Settings_Api {
class WC_Shipping_Method extends WC_Settings_Api {
var $id;
var $method_title; // Method title
@ -59,7 +59,7 @@ class Woocommerce_Shipping_Method extends Woocommerce_Settings_Api {
// This saves shipping methods having to do compelex tax calculations
if (!is_array($taxes) && $taxes!==false && $total_cost>0 && get_option('woocommerce_calc_taxes')=='yes' && $this->tax_status=='taxable' ) :
$_tax = new Woocommerce_Tax();
$_tax = new WC_Tax();
$taxes = array();
switch ($calc_tax) :
@ -71,11 +71,11 @@ class Woocommerce_Shipping_Method extends Woocommerce_Settings_Api {
$cart = $woocommerce->cart->get_cart();
foreach ($cost as $id => $amount) :
foreach ($cost as $cost_key => $amount) :
if (!isset($cart[$id])) continue;
if (!isset($cart[$cost_key])) continue;
$_product = $cart[$id]['data'];
$_product = $cart[$cost_key]['data'];
$rates = $_tax->get_shipping_tax_rates( $_product->get_tax_class() );
$item_taxes = $_tax->calc_shipping_tax( $amount, $rates );
@ -102,7 +102,7 @@ class Woocommerce_Shipping_Method extends Woocommerce_Settings_Api {
endif;
$this->rates[] = new Woocommerce_Shipping_Rate( $id, $label, $total_cost, $taxes );
$this->rates[] = new WC_Shipping_Rate( $id, $label, $total_cost, $taxes );
}
function is_available() {
@ -145,14 +145,14 @@ class Woocommerce_Shipping_Method extends Woocommerce_Settings_Api {
*
* Simple Class for storing rates.
*/
class Woocommerce_Shipping_Rate {
class WC_Shipping_Rate {
var $id = '';
var $label = '';
var $cost = 0;
var $taxes = array();
function woocommerce_shipping_rate( $id, $label, $cost, $taxes ) {
public function __construct( $id, $label, $cost, $taxes ) {
$this->id = $id;
$this->label = $label;
$this->cost = $cost;
@ -166,4 +166,12 @@ class Woocommerce_Shipping_Rate {
endif;
return $taxes;
}
}
/** Depreciated */
class woocommerce_shipping_method extends WC_Shipping_Method {
public function __construct() {
_deprecated_function( 'woocommerce_shipping_method', '1.4', 'WC_Shipping_Method()' );
parent::__construct();
}
}

View File

@ -4,12 +4,12 @@
*
* Handles shipping and loads shipping methods via hooks.
*
* @class Woocommerce_Shipping
* @class WC_Shipping
* @package WooCommerce
* @category Shipping
* @author WooThemes
*/
class Woocommerce_Shipping {
class WC_Shipping {
var $enabled = false;
var $shipping_methods = array();

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -128,6 +128,12 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
* Displaying correct currency symbol (Real of Brazil)
* Added local pickup and local delivery shipping methods (thanks Patrick Garman)
* Improved woocommerce_coupon_is_valid filter
* Random products widget, thanks to Geert De Deckere
* Error are now lists instead of divs so we can show multiple errors at once
* Problem: Stock management off, hide out of stock on meant some product were hidden randomly. Solution: Enable instock/outofstock selector on edit product page regardless of settings
* If sending shipping to paypal, send shipping address
* Send shipping name to paypal
* Code to allow add-on validation
= 1.3.2.1 - 15/12/2011 =
* Category/Ordering fix

View File

@ -260,7 +260,7 @@ function woocommerce_product_add_to_cart_url( $atts ){
if ($product_data->post_type!=='product') return;
$_product = new Woocommerce_Product( $product_data->ID );
$_product = new WC_Product( $product_data->ID );
return esc_url( $_product->add_to_cart_url() );
}
@ -309,11 +309,48 @@ function woocommerce_featured_products( $atts ) {
return ob_get_clean();
}
/**
* Show a single product page
**/
function woocommerce_product_page_shortcode($atts){
if (empty($atts)) return;
if (!$atts['id'] && !$atts['sku']) return;
$args = array(
'posts_per_page' => 1,
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
);
if(isset($atts['sku'])){
$args['meta_query'][] = array(
'key' => '_sku',
'value' => $atts['sku'],
'compare' => '='
);
}
if(isset($atts['id'])){
$args['p'] = $atts['id'];
}
$product_query = new WP_Query($args);
ob_start();
echo '<div class="single-product">';
woocommerce_single_product_content( $product_query );
echo '</div>';
wp_reset_query();
return ob_get_clean();
}
/**
* Shortcode creation
**/
add_shortcode('product_category', 'woocommerce_product_category');
add_shortcode('product', 'woocommerce_product');
add_shortcode('product_page', 'woocommerce_product_page_shortcode');
add_shortcode('product_category', 'woocommerce_product_category');
add_shortcode('add_to_cart', 'woocommerce_product_add_to_cart');
add_shortcode('add_to_cart_url', 'woocommerce_product_add_to_cart_url');
add_shortcode('products', 'woocommerce_products');

View File

@ -243,7 +243,7 @@ function woocommerce_view_order() {
$user_id = get_current_user_id();
$order_id = (isset($_GET['order'])) ? $_GET['order'] : 0;
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
if ( $order_id==0 || $order->user_id != $user_id ) :
echo '<div class="woocommerce_error">' . __('Invalid order.', 'woocommerce') . ' <a href="'.get_permalink( woocommerce_get_page_id('myaccount') ).'">'. __('My Account &rarr;', 'woocommerce') .'</a>' . '</div>';
@ -253,7 +253,7 @@ function woocommerce_view_order() {
$status = get_term_by('slug', $order->status, 'shop_order_status');
echo '<p>'
. sprintf( __('Order <mark>#%s</mark> made on <mark>%s</mark>', 'woocommerce'), $order->id, date(get_option('date_format'), strtotime($order->order_date)) )
. sprintf( __('Order <mark>#%s</mark> made on <mark>%s</mark>', 'woocommerce'), $order->id, date_i18n(get_option('date_format'), strtotime($order->order_date)) )
. sprintf( __('. Order status: <mark>%s</mark>', 'woocommerce'), __($status->name, 'woocommerce') )
. '.</p>';

View File

@ -28,7 +28,7 @@ function woocommerce_order_tracking( $atts ) {
if (isset($_POST['orderid']) && $_POST['orderid'] > 0) $order_id = (int) $_POST['orderid']; else $order_id = 0;
if (isset($_POST['order_email']) && $_POST['order_email']) $order_email = trim($_POST['order_email']); else $order_email = '';
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
if ($order->id && $order_email) :

View File

@ -25,7 +25,7 @@ function woocommerce_pay() {
// Pay for existing order
$order_key = urldecode( $_GET['order'] );
$order_id = (int) $_GET['order_id'];
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
if ($order->id == $order_id && $order->order_key == $order_key && in_array($order->status, array('pending', 'failed'))) :
@ -57,7 +57,7 @@ function woocommerce_pay() {
if ($order_id > 0) :
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
if ($order->order_key == $order_key && in_array($order->status, array('pending', 'failed'))) :
@ -69,7 +69,7 @@ function woocommerce_pay() {
</li>
<li class="date">
<?php _e('Date:', 'woocommerce'); ?>
<strong><?php echo date(get_option('date_format'), strtotime($order->order_date)); ?></strong>
<strong><?php echo date_i18n(get_option('date_format'), strtotime($order->order_date)); ?></strong>
</li>
<li class="total">
<?php _e('Total:', 'woocommerce'); ?>

View File

@ -30,7 +30,7 @@ function woocommerce_thankyou( $atts ) {
unset($_SESSION['order_awaiting_payment']);
if ($order_id > 0) :
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
if ($order->order_key != $order_key) :
unset($order);
endif;

View File

@ -90,16 +90,18 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
<?php
if (get_option('woocommerce_display_cart_taxes')=='yes' && $woocommerce->cart->get_cart_tax()) :
if (isset($woocommerce->cart->taxes) && sizeof($woocommerce->cart->taxes)>0) :
$taxes = $woocommerce->cart->get_taxes();
if (sizeof($taxes)>0) :
$has_compound_tax = false;
foreach ($woocommerce->cart->taxes as $key => $tax) :
foreach ($taxes as $key => $tax) :
if ($woocommerce->cart->tax->is_compound( $key )) : $has_compound_tax = true; continue; endif;
if ($tax==0) continue;
?>
<tr class="tax-rate tax-rate-<?php echo $key; ?>">
<th><?php echo $woocommerce->cart->tax->get_rate_label( $key ); ?></th>
<th><?php if (get_option('woocommerce_prices_include_tax')=='yes') : _e('incl.', 'woocommerce'); endif; ?> <?php echo $woocommerce->cart->tax->get_rate_label( $key ); ?></th>
<td><?php echo woocommerce_price($tax); ?></td>
</tr>
<?php
@ -115,12 +117,12 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
<?php
endif;
foreach ($woocommerce->cart->taxes as $key => $tax) :
foreach ($taxes as $key => $tax) :
if (!$woocommerce->cart->tax->is_compound( $key )) continue;
if ($tax==0) continue;
?>
<tr class="tax-rate tax-rate-<?php echo $key; ?>">
<th><?php echo $woocommerce->cart->tax->get_rate_label( $key ); ?></th>
<th><?php if (get_option('woocommerce_prices_include_tax')=='yes') : _e('incl.', 'woocommerce'); endif; ?> <?php echo $woocommerce->cart->tax->get_rate_label( $key ); ?></th>
<td><?php echo woocommerce_price($tax); ?></td>
</tr>
<?php
@ -167,7 +169,7 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
<p><small><?php
if ($woocommerce->customer->is_customer_outside_base()) :
$estimated_text = ' ' . sprintf(__('(for %s)', 'woocommerce'), $woocommerce->countries->estimated_for_prefix() . __($woocommerce->countries->countries[ $woocommerce->countries->get_base_country() ], 'woocommerce') );
$estimated_text = ' ' . sprintf(__('(taxes estimated for %s)', 'woocommerce'), $woocommerce->countries->estimated_for_prefix() . __($woocommerce->countries->countries[ $woocommerce->countries->get_base_country() ], 'woocommerce') );
else :

View File

@ -92,16 +92,18 @@
<?php
if ($woocommerce->cart->get_cart_tax()) :
if (isset($woocommerce->cart->taxes) && sizeof($woocommerce->cart->taxes)>0) :
$taxes = $woocommerce->cart->get_taxes();
if (sizeof($taxes)>0) :
$has_compound_tax = false;
foreach ($woocommerce->cart->taxes as $key => $tax) : if ($woocommerce->cart->tax->is_compound( $key )) : $has_compound_tax = true; continue; endif;
foreach ($taxes as $key => $tax) : if ($woocommerce->cart->tax->is_compound( $key )) : $has_compound_tax = true; continue; endif;
?>
<tr class="tax-rate tax-rate-<?php echo $key; ?>">
<th colspan="2"><?php echo $woocommerce->cart->tax->get_rate_label( $key ); ?></th>
<th colspan="2"><?php if (get_option('woocommerce_prices_include_tax')=='yes') : _e('incl.', 'woocommerce'); endif; ?> <?php echo $woocommerce->cart->tax->get_rate_label( $key ); ?></th>
<td><?php echo woocommerce_price($tax); ?></td>
</tr>
<?php
@ -117,11 +119,11 @@
<?php
endif;
foreach ($woocommerce->cart->taxes as $key => $tax) : if (!$woocommerce->cart->tax->is_compound( $key )) continue;
foreach ($taxes as $key => $tax) : if (!$woocommerce->cart->tax->is_compound( $key )) continue;
?>
<tr class="tax-rate tax-rate-<?php echo $key; ?>">
<th colspan="2"><?php echo $woocommerce->cart->tax->get_rate_label( $key ); ?></th>
<th colspan="2"><?php if (get_option('woocommerce_prices_include_tax')=='yes') : _e('incl.', 'woocommerce'); endif; ?> <?php echo $woocommerce->cart->tax->get_rate_label( $key ); ?></th>
<td><?php echo woocommerce_price($tax); ?></td>
</tr>
<?php

View File

@ -38,7 +38,7 @@ global $woocommerce, $order;
</li>
<li class="date">
<?php _e('Date:', 'woocommerce'); ?>
<strong><?php echo date(get_option('date_format'), strtotime($order->order_date)); ?></strong>
<strong><?php echo date_i18n(get_option('date_format'), strtotime($order->order_date)); ?></strong>
</li>
<li class="total">
<?php _e('Total:', 'woocommerce'); ?>

View File

@ -49,11 +49,11 @@ if ($customer_orders) :
<tbody><?php
foreach ($customer_orders as $customer_order) :
$order = new Woocommerce_Order();
$order = new WC_Order();
$order->populate($customer_order);
?><tr class="order">
<td><?php echo $order->id; ?></td>
<td><time title="<?php echo esc_attr( strtotime($order->order_date) ); ?>"><?php echo date(get_option('date_format'), strtotime($order->order_date)); ?></time></td>
<td><time title="<?php echo esc_attr( strtotime($order->order_date) ); ?>"><?php echo date_i18n(get_option('date_format'), strtotime($order->order_date)); ?></time></td>
<td><address><?php if ($order->get_formatted_shipping_address()) echo $order->get_formatted_shipping_address(); else echo '&ndash;'; ?></address></td>
<td><?php echo woocommerce_price($order->order_total); ?></td>
<td><?php

View File

@ -5,7 +5,7 @@
global $woocommerce, $order_id;
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
?>
<h2><?php _e('Order Details', 'woocommerce'); ?></h2>
<table class="shop_table">
@ -35,9 +35,9 @@ $order = new Woocommerce_Order( $order_id );
foreach($order->get_items() as $item) :
if (isset($item['variation_id']) && $item['variation_id'] > 0) :
$_product = new Woocommerce_Product_Variation( $item['variation_id'] );
$_product = new WC_Product_Variation( $item['variation_id'] );
else :
$_product = new Woocommerce_Product( $item['id'] );
$_product = new WC_Product( $item['id'] );
endif;
echo '

View File

@ -41,6 +41,5 @@ global $post, $woocommerce;
endforeach;
endif;
wp_reset_query();
?>
</div>

View File

@ -22,6 +22,7 @@ include_once('widget-recently_viewed.php');
include_once('widget-best_sellers.php');
include_once('widget-onsale.php');
include_once('widget-login.php');
include_once('widget-random_products.php');
function woocommerce_register_widgets() {
register_widget('WooCommerce_Widget_Recent_Products');
@ -38,5 +39,6 @@ function woocommerce_register_widgets() {
register_widget('WooCommerce_Widget_Best_Sellers');
register_widget('WooCommerce_Widget_On_Sale');
register_widget('WooCommerce_Widget_Login');
register_widget('WooCommerce_Widget_Random_Products');
}
add_action('widgets_init', 'woocommerce_register_widgets');

View File

@ -107,7 +107,7 @@ class WooCommerce_Widget_Product_Categories extends WP_Widget {
echo '"><a href="'.get_term_link( $cat->slug, 'product_cat' ).'">'.$cat->name.'</a>';
if ($c) echo ' ('.$cat->count.')';
if ($c) echo ' <span class="count">('.$cat->count.')</span>';
if (is_tax('product_cat', $cat->slug) || ($current_cat_parent && $current_cat_parent->term_id==$cat->term_id)) :

View File

@ -0,0 +1,119 @@
<?php
/**
* WooCommerce Random Products Widget
*
* @package WooCommerce
* @category Widgets
* @author WooThemes
*/
class WooCommerce_Widget_Random_Products extends WP_Widget {
/** constructor */
function __construct() {
$this->id_base = 'woocommerce_random_products';
$this->name = __('WooCommerce Random Products', 'woocommerce' );
$this->widget_options = array(
'classname' => 'widget_random_products',
'description' => __( 'Display a list of random products on your site.', 'woocommerce' ),
);
parent::__construct( $this->id_base, $this->name, $this->widget_options );
}
/** @see WP_Widget::widget */
function widget( $args, $instance ) {
global $woocommerce;
// Use default title as fallback
$title = ( '' === $instance['title'] ) ? __('Random Products', 'woocommerce') : $instance['title'];
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
// Setup product query
$query_args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => $instance['number'],
'orderby' => 'rand',
);
if ( $instance['show_variations'] ) {
$query_args['meta_query'] = array(
array(
'key' => '_visibility',
'value' => array('catalog', 'visible'),
'compare' => 'IN',
),
);
$query_args['post_parent'] = 0;
}
$query = new WP_Query( $query_args );
if ( $query->have_posts() ) {
echo $args['before_widget'];
if ( '' !== $title ) {
echo $args['before_title'], $title, $args['after_title'];
} ?>
<ul class="product_list_widget">
<?php while ($query->have_posts()) : $query->the_post(); global $product; ?>
<li>
<a href="<?php the_permalink() ?>">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail('shop_thumbnail');
} else {
echo '<img src="'.$woocommerce->plugin_url().'/assets/images/placeholder.png" alt="Placeholder" width="'.$woocommerce->get_image_size( 'shop_thumbnail_image_width' ).'" height="'.$woocommerce->get_image_size( 'shop_thumbnail_image_height' ).'" />';
} ?>
<?php the_title() ?>
</a>
<?php echo $product->get_price_html() ?>
</li>
<?php endwhile; ?>
</ul>
<?php
echo $args['after_widget'];
}
}
/** @see WP_Widget->update */
function update( $new_instance, $old_instance ) {
$instance = array(
'title' => strip_tags($new_instance['title']),
'number' => min(15, max(1, (int) $new_instance['number'])),
'show_variations' => ! empty($new_instance['show_variations'])
);
return $instance;
}
/** @see WP_Widget->form */
function form( $instance ) {
// Default values
$title = isset( $instance['title'] ) ? $instance['title'] : '';
$number = isset( $instance['number'] ) ? (int) $instance['number'] : 5;
$show_variations = ! empty( $instance['show_variations'] );
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ) ?>"><?php _e( 'Title:', 'woocommerce' ) ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ) ?>" name="<?php echo esc_attr( $this->get_field_name('title') ) ?>" type="text" value="<?php echo esc_attr( $title ) ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'number' ) ?>"><?php _e( 'Number of products to show:', 'woocommerce' ) ?></label>
<input id="<?php echo esc_attr( $this->get_field_id( 'number' ) ) ?>" name="<?php echo esc_attr( $this->get_field_name('number') ) ?>" type="text" value="<?php echo esc_attr( $number ) ?>" size="3" />
</p>
<p>
<input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'show_variations' ) ) ?>" name="<?php echo esc_attr( $this->get_field_name('show_variations') ) ?>" <?php checked( $show_variations ) ?> />
<label for="<?php echo $this->get_field_id( 'show_variations' ) ?>"><?php _e( 'Show hidden product variations', 'woocommerce' ) ?></label>
</p>
<?php
}
} // class WooCommerce_Widget_Random_Products

View File

@ -64,7 +64,7 @@ class WooCommerce_Widget_Recent_Reviews extends WP_Widget {
foreach ( (array) $comments as $comment) :
$_product = new Woocommerce_Product( $comment->comment_post_ID );
$_product = new WC_Product( $comment->comment_post_ID );
$star_size = apply_filters('woocommerce_star_rating_size_recent_reviews', 16);

View File

@ -140,16 +140,19 @@ function woocommerce_ajax_add_to_cart() {
check_ajax_referer( 'add-to-cart', 'security' );
$product_id = (int) apply_filters('woocommerce_add_to_cart_product_id', $_POST['product_id']);
if ($woocommerce->cart->add_to_cart($product_id, 1)) :
$passed_validation = apply_filters('woocommerce_add_to_cart_validation', true, $product_id, 1);
if ($passed_validation && $woocommerce->cart->add_to_cart($product_id, 1)) :
// Return html fragments
$data = apply_filters('add_to_cart_fragments', array());
else :
// Return error
// If there was an error adding to the cart, redirect to the product page to show any errors
$data = array(
'error' => $woocommerce->errors[0]
'error' => true,
'product_url' => get_permalink( $product_id )
);
$woocommerce->clear_messages();
$woocommerce->set_messages();
endif;
echo json_encode( $data );
@ -197,7 +200,7 @@ function woocommerce_feature_product() {
if($post->post_type !== 'product') die;
$product = new Woocommerce_Product($post->ID);
$product = new WC_Product($post->ID);
if ($product->is_featured()) update_post_meta($post->ID, '_featured', 'no');
else update_post_meta($post->ID, '_featured', 'yes');
@ -219,7 +222,7 @@ function woocommerce_mark_order_complete() {
$order_id = isset($_GET['order_id']) && (int) $_GET['order_id'] ? (int) $_GET['order_id'] : '';
if(!$order_id) die;
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
$order->update_status( 'completed' );
wp_safe_redirect( wp_get_referer() );
@ -238,7 +241,7 @@ function woocommerce_mark_order_processing() {
$order_id = isset($_GET['order_id']) && (int) $_GET['order_id'] ? (int) $_GET['order_id'] : '';
if(!$order_id) die;
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
$order->update_status( 'processing' );
wp_safe_redirect( wp_get_referer() );
@ -322,7 +325,7 @@ function woocommerce_link_all_variations() {
$variations = array();
$_product = new Woocommerce_Product( $post_id );
$_product = new WC_Product( $post_id );
// Put variation attributes into an array
foreach ($_product->get_attributes() as $attribute) :
@ -355,7 +358,7 @@ function woocommerce_link_all_variations() {
foreach($_product->get_children() as $child_id) {
$child = $_product->get_child( $child_id );
if($child instanceof woocommerce_product_variation) {
if($child instanceof WC_Product_Variation) {
$available_variations[] = $child->get_variation_attributes();
}
}
@ -533,9 +536,9 @@ function woocommerce_add_order_item() {
endif;
if ($post->post_type=="product") :
$_product = new Woocommerce_Product( $post->ID );
$_product = new WC_Product( $post->ID );
else :
$_product = new Woocommerce_Product_Variation( $post->ID );
$_product = new WC_Product_Variation( $post->ID );
endif;
?>
<tr class="item" rel="<?php echo $index; ?>">
@ -620,7 +623,7 @@ function woocommerce_calc_line_taxes() {
check_ajax_referer( 'calc-totals', 'security' );
$tax = new Woocommerce_Tax();
$tax = new WC_Tax();
$base_tax_amount = 0;
$line_tax_amount = 0;
@ -636,7 +639,7 @@ function woocommerce_calc_line_taxes() {
$tax_class = esc_attr($_POST['tax_class']);
// Get product details
$_product = new Woocommerce_Product($item_id);
$_product = new WC_Product($item_id);
$item_tax_status = $_product->get_tax_status();
if ($item_tax_status=='taxable') :
@ -678,7 +681,7 @@ function woocommerce_add_order_note() {
$is_customer_note = ($note_type=='customer') ? 1 : 0;
if ($post_id>0) :
$order = new Woocommerce_Order( $post_id );
$order = new WC_Order( $post_id );
$comment_id = $order->add_order_note( $note, $is_customer_note );
echo '<li rel="'.$comment_id.'" class="note ';

View File

@ -24,10 +24,13 @@ function woocommerce_mail( $to, $subject, $message, $headers = "Content-Type: te
* WooCommerce page IDs
*
* retrieve page ids - used for myaccount, edit_address, change_password, shop, cart, checkout, pay, view_order, thanks, terms, order_tracking
*
* returns -1 if no page is found
**/
if (!function_exists('woocommerce_get_page_id')) {
function woocommerce_get_page_id( $page ) {
return apply_filters('woocommerce_get_' . $page . '_page_id', get_option('woocommerce_' . $page . '_page_id'));
$page = apply_filters('woocommerce_get_' . $page . '_page_id', get_option('woocommerce_' . $page . '_page_id'));
return ($page) ? $page : -1;
}
}
@ -159,7 +162,7 @@ function woocommerce_price( $price, $args = array() ) {
$price = number_format( (double) $price, $num_decimals, get_option('woocommerce_price_decimal_sep'), get_option('woocommerce_price_thousand_sep') );
if (get_option('woocommerce_price_trim_zeros')=='yes' && $num_decimals>0) :
$price = preg_replace('/'.preg_quote(get_option('woocommerce_price_decimal_sep'), '/').'0++$/', '', $price);
$price = woocommerce_trim_zeros($price);
endif;
switch ($currency_pos) :
@ -182,6 +185,13 @@ function woocommerce_price( $price, $args = array() ) {
return $return;
}
/**
* Trim trailing zeros
**/
function woocommerce_trim_zeros( $price ) {
return preg_replace('/'.preg_quote(get_option('woocommerce_price_decimal_sep'), '/').'0++$/', '', $price);
}
/**
* Clean variables
**/
@ -381,7 +391,7 @@ add_action('woocommerce_order_status_completed', 'woocommerce_downloadable_produ
function woocommerce_downloadable_product_permissions( $order_id ) {
global $wpdb;
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
if (sizeof($order->get_items())>0) foreach ($order->get_items() as $item) :
@ -442,7 +452,7 @@ add_action('woocommerce_order_status_completed', 'woocommerce_paying_customer');
function woocommerce_paying_customer( $order_id ) {
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
if ( $order->user_id > 0 ) update_user_meta( $order->user_id, 'paying_customer', 1 );
}
@ -570,7 +580,7 @@ function woocommerce_walk_category_dropdown_tree() {
$args = func_get_args();
// the user's options are the third parameter
if ( empty($args[2]['walker']) || !is_a($args[2]['walker'], 'Walker') )
$walker = new Woocommerce_Walker_CategoryDropdown;
$walker = new WC_Walker_CategoryDropdown;
else
$walker = $args[2]['walker'];
@ -580,7 +590,7 @@ function woocommerce_walk_category_dropdown_tree() {
/**
* Create HTML dropdown list of Product Categories.
*/
class Woocommerce_Walker_CategoryDropdown extends Walker {
class WC_Walker_CategoryDropdown extends Walker {
var $tree_type = 'category';
var $db_fields = array ('parent' => 'parent', 'id' => 'term_id', 'slug' => 'slug' );

View File

@ -16,7 +16,7 @@ function woocommerce_redirects() {
global $woocommerce;
// When default permalinks are enabled, redirect shop page to post type archive url
if ( isset($_GET['page_id']) && get_option( 'permalink_structure' )=="" && $_GET['page_id'] == woocommerce_get_page_id('shop') ) :
if ( isset($_GET['page_id']) && $_GET['page_id'] > 0 && get_option( 'permalink_structure' )=="" && $_GET['page_id'] == woocommerce_get_page_id('shop') ) :
wp_safe_redirect( get_post_type_archive_link('product') );
exit;
endif;
@ -176,7 +176,7 @@ function woocommerce_update_catalog_ordering() {
function woocommerce_increase_coupon_counts() {
global $woocommerce;
if ($applied_coupons = $woocommerce->cart->get_applied_coupons()) foreach ($applied_coupons as $code) :
$coupon = new Woocommerce_Coupon( $code );
$coupon = new WC_Coupon( $code );
$coupon->inc_usage_count();
endforeach;
}
@ -218,132 +218,156 @@ function woocommerce_update_cart_action() {
}
/**
* Add to cart
* Add to cart action
*
* Checks for a valid request, does validation (via hooks) and then redirects if valid
**/
function woocommerce_add_to_cart_action( $url = false ) {
global $woocommerce;
if (empty($_GET['add-to-cart']) || !$woocommerce->verify_nonce('add_to_cart', '_GET')) return;
if (is_numeric($_GET['add-to-cart'])) :
//single product
$quantity = (isset($_POST['quantity'])) ? (int) $_POST['quantity'] : 1;
// Add to the cart
if ($woocommerce->cart->add_to_cart($_GET['add-to-cart'], $quantity)) :
woocommerce_add_to_cart_message();
endif;
elseif ($_GET['add-to-cart']=='variation') :
// Variation add to cart
if (empty($_POST['variation_id']) || !is_numeric($_POST['variation_id'])) :
$woocommerce->add_error( __('Please choose product options&hellip;', 'woocommerce') );
wp_safe_redirect(apply_filters('woocommerce_add_to_cart_product_id', get_permalink($_GET['product'])));
exit;
else :
$product_id = (int) apply_filters('woocommerce_add_to_cart_product_id', $_GET['product']);
$variation_id = (int) $_POST['variation_id'];
$quantity = (isset($_POST['quantity'])) ? (int) $_POST['quantity'] : 1;
$attributes = (array) maybe_unserialize(get_post_meta($product_id, '_product_attributes', true));
$variations = array();
$all_variations_set = true;
foreach ($attributes as $attribute) :
$added_to_cart = false;
switch ($_GET['add-to-cart']) {
// Variable Products
case 'variation' :
// Only allow integer variation ID - if its not set, redirect to the product page
if (empty($_POST['variation_id']) || !is_numeric($_POST['variation_id']) || $_POST['variation_id']<1) {
$woocommerce->add_error( __('Please choose product options&hellip;', 'woocommerce') );
wp_redirect(apply_filters('woocommerce_add_to_cart_product_id', get_permalink($_GET['product_id'])));
exit;
}
// Get product ID to add and quantity
$product_id = (int) apply_filters('woocommerce_add_to_cart_product_id', $_GET['product_id']);
$variation_id = (int) $_POST['variation_id'];
$quantity = (isset($_POST['quantity'])) ? (int) $_POST['quantity'] : 1;
$attributes = (array) maybe_unserialize(get_post_meta($product_id, '_product_attributes', true));
$variations = array();
$all_variations_set = true;
// Verify all attributes for the variable product were set
foreach ($attributes as $attribute) {
if ( !$attribute['is_variation'] ) continue;
$taxonomy = 'attribute_' . sanitize_title($attribute['name']);
if (!empty($_POST[$taxonomy])) :
if (!empty($_POST[$taxonomy])) {
// Get value from post data
$value = esc_attr(stripslashes($_POST[$taxonomy]));
// Use name so it looks nicer in the cart widget/order page etc - instead of a sanitized string
$variations[esc_attr($attribute['name'])] = $value;
else :
} else {
$all_variations_set = false;
endif;
endforeach;
if ($all_variations_set && $variation_id > 0) :
// Add to cart
if ($woocommerce->cart->add_to_cart($product_id, $quantity, $variation_id, $variations)) :
woocommerce_add_to_cart_message();
endif;
else :
$woocommerce->add_error( __('Please choose product options&hellip;', 'woocommerce') );
wp_redirect(get_permalink($_GET['product']));
exit;
endif;
endif;
elseif ($_GET['add-to-cart']=='group') :
// Group add to cart
if (isset($_POST['quantity']) && is_array($_POST['quantity'])) :
$total_quantity = 0;
foreach ($_POST['quantity'] as $item => $quantity) :
if ($quantity>0) :
if ($woocommerce->cart->add_to_cart($item, $quantity)) :
}
}
if ($all_variations_set) {
// Add to cart validation
$passed_validation = apply_filters('woocommerce_add_to_cart_validation', true, $product_id, $quantity);
if ($passed_validation) {
if ($woocommerce->cart->add_to_cart($product_id, $quantity, $variation_id, $variations)) {
woocommerce_add_to_cart_message();
endif;
$added_to_cart = true;
}
}
} else {
$woocommerce->add_error( __('Please choose product options&hellip;', 'woocommerce') );
wp_redirect(apply_filters('woocommerce_add_to_cart_product_id', get_permalink($_GET['product_id'])));
exit;
}
break;
// Grouped Products
case 'group' :
if (isset($_POST['quantity']) && is_array($_POST['quantity'])) {
$quantity_set = false;
foreach ($_POST['quantity'] as $item => $quantity) {
if ($quantity<1) continue;
$total_quantity = $total_quantity + $quantity;
endif;
endforeach;
$quantity_set = true;
// Add to cart validation
$passed_validation = apply_filters('woocommerce_add_to_cart_validation', true, $item, $quantity);
if ($passed_validation) {
if ($woocommerce->cart->add_to_cart($item, $quantity)) {
woocommerce_add_to_cart_message();
$added_to_cart = true;
}
}
}
if (!$added_to_cart && !$quantity_set) {
$woocommerce->add_error( __('Please choose a quantity&hellip;', 'woocommerce') );
wp_redirect(apply_filters('woocommerce_add_to_cart_product_id', get_permalink($_GET['product_id'])));
exit;
}
} elseif ($_GET['product_id']) {
if ($total_quantity==0) :
$woocommerce->add_error( __('Please choose a quantity&hellip;', 'woocommerce') );
endif;
/* Link on product archives */
$woocommerce->add_error( __('Please choose a product&hellip;', 'woocommerce') );
wp_redirect( get_permalink( $_GET['product_id'] ) );
exit;
}
break;
// Simple Products - add-to-cart contains product ID
default :
// Only allow integers
if (!is_numeric($_GET['add-to-cart'])) break;
// Get product ID to add and quantity
$product_id = (int) $_GET['add-to-cart'];
$quantity = (isset($_POST['quantity'])) ? (int) $_POST['quantity'] : 1;
// Add to cart validation
$passed_validation = apply_filters('woocommerce_add_to_cart_validation', true, $product_id, $quantity);
if ($passed_validation) {
// Add the product to the cart
if ($woocommerce->cart->add_to_cart($_GET['add-to-cart'], $quantity)) {
woocommerce_add_to_cart_message();
$added_to_cart = true;
}
}
break;
}
// If we added the product to the cart we can now do a redirect, otherwise just continue loading the page to show errors
if ($added_to_cart) {
$url = apply_filters('add_to_cart_redirect', $url);
elseif ($_GET['product']) :
/* Link on product pages */
$woocommerce->add_error( __('Please choose a product&hellip;', 'woocommerce') );
wp_redirect( get_permalink( $_GET['product'] ) );
// If has custom URL redirect there
if ( $url ) {
wp_safe_redirect( $url );
exit;
}
endif;
endif;
$url = apply_filters('add_to_cart_redirect', $url);
// If has custom URL redirect there
if ( $url ) {
wp_safe_redirect( $url );
exit;
}
// Redirect to cart option
elseif (get_option('woocommerce_cart_redirect_after_add')=='yes' && $woocommerce->error_count() == 0) {
wp_safe_redirect( $woocommerce->cart->get_cart_url() );
exit;
}
// Otherwise redirect to where they came
elseif ( wp_get_referer() ) {
wp_safe_redirect( wp_get_referer() );
exit;
}
// If all else fails redirect to root
else {
wp_safe_redirect(home_url());
exit;
}
// Redirect to cart option
elseif (get_option('woocommerce_cart_redirect_after_add')=='yes' && $woocommerce->error_count() == 0) {
wp_safe_redirect( $woocommerce->cart->get_cart_url() );
exit;
}
}
}
/**
@ -375,7 +399,7 @@ function woocommerce_clear_cart_after_payment() {
if (isset($_GET['order'])) $order_id = $_GET['order']; else $order_id = 0;
if (isset($_GET['key'])) $order_key = $_GET['key']; else $order_key = '';
if ($order_id > 0) :
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
if ($order->order_key == $order_key) :
$woocommerce->cart->empty_cart();
@ -389,7 +413,7 @@ function woocommerce_clear_cart_after_payment() {
if (isset($_SESSION['order_awaiting_payment']) && $_SESSION['order_awaiting_payment'] > 0) :
$order = new Woocommerce_Order($_SESSION['order_awaiting_payment']);
$order = new WC_Order($_SESSION['order_awaiting_payment']);
if ($order->id > 0 && $order->status!=='pending') :
@ -433,7 +457,7 @@ function woocommerce_pay_action() {
// Pay for existing order
$order_key = urldecode( $_GET['order'] );
$order_id = (int) $_GET['order_id'];
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
if ($order->id == $order_id && $order->order_key == $order_key && in_array($order->status, array('pending', 'failed'))) :
@ -646,7 +670,7 @@ function woocommerce_cancel_order() {
$order_key = urldecode( $_GET['order'] );
$order_id = (int) $_GET['order_id'];
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
if ($order->id == $order_id && $order->order_key == $order_key && in_array($order->status, array('pending', 'failed')) && $woocommerce->verify_nonce('cancel_order', '_GET')) :
@ -706,7 +730,7 @@ function woocommerce_download_product() {
$downloads_remaining = $download_result->downloads_remaining;
if ($order_id) :
$order = new Woocommerce_Order( $order_id );
$order = new WC_Order( $order_id );
if ($order->status!='completed' && $order->status!='processing' && $order->status!='publish') :
wp_die( __('Invalid order.', 'woocommerce') . ' <a href="'.home_url().'">' . __('Go to homepage &rarr;', 'woocommerce') . '</a>' );
exit;
@ -945,7 +969,7 @@ function woocommerce_ecommerce_tracking( $order_id ) {
remove_action('wp_footer', 'woocommerce_google_tracking');
// Get the order and output tracking code
$order = new Woocommerce_Order($order_id);
$order = new WC_Order($order_id);
$loggedin = (is_user_logged_in()) ? 'yes' : 'no';
if (is_user_logged_in()) :
@ -1021,7 +1045,7 @@ function woocommerce_ecommerce_tracking_piwik( $order_id ) {
$GLOBALS['wp_piwik']->footer();
// Get the order and output tracking code
$order = new Woocommerce_Order($order_id);
$order = new WC_Order($order_id);
?>
<script type="text/javascript">
try {

View File

@ -68,9 +68,16 @@ if (!function_exists('woocommerce_product_taxonomy_content')) {
}
}
if (!function_exists('woocommerce_single_product_content')) {
function woocommerce_single_product_content() {
if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
function woocommerce_single_product_content( $wc_query = false ) {
// Let developers override the query used, in case they want to use this function for their own loop/wp_query
if (!$wc_query) {
global $wp_query;
$wc_query = $wp_query;
}
if ( $wc_query->have_posts() ) while ( $wc_query->have_posts() ) : $wc_query->the_post(); ?>
<?php do_action('woocommerce_before_single_product'); ?>
@ -89,9 +96,9 @@ if (!function_exists('woocommerce_single_product_content')) {
<?php do_action('woocommerce_after_single_product_summary'); ?>
</div>
<?php do_action('woocommerce_after_single_product'); ?>
<?php endwhile;
}
@ -280,7 +287,7 @@ if (!function_exists('woocommerce_variable_add_to_cart')) {
$variation = $product->get_child( $child_id );
if($variation instanceof woocommerce_product_variation) {
if($variation instanceof WC_Product_Variation) {
if (get_post_status( $variation->get_variation_id() ) != 'publish') continue; // Disabled

View File

@ -89,9 +89,9 @@ class Woocommerce {
if (is_admin() && !defined('DOING_AJAX')) $this->install();
// Load class instances
$this->payment_gateways = new Woocommerce_Payment_gateways(); // Payment gateways. Loads and stores payment methods, and handles incoming requests such as IPN
$this->shipping = new Woocommerce_Shipping(); // Shipping class. loads and stores shipping methods
$this->countries = new Woocommerce_Countries(); // Countries class
$this->payment_gateways = new WC_Payment_gateways(); // Payment gateways. Loads and stores payment methods, and handles incoming requests such as IPN
$this->shipping = new WC_Shipping(); // Shipping class. loads and stores shipping methods
$this->countries = new WC_Countries(); // Countries class
// Variables
$this->template_url = apply_filters( 'woocommerce_template_url', 'woocommerce/' );
@ -121,9 +121,9 @@ class Woocommerce {
if ( !is_admin() || defined('DOING_AJAX') ) :
// Class instances
$this->cart = new Woocommerce_Cart(); // Cart class, stores the cart contents
$this->customer = new Woocommerce_Customer(); // Customer class, sorts out session data such as location
$this->query = new Woocommerce_Query(); // Query class, handles front-end queries and loops
$this->cart = new WC_Cart(); // Cart class, stores the cart contents
$this->customer = new WC_Customer(); // Customer class, sorts out session data such as location
$this->query = new WC_Query(); // Query class, handles front-end queries and loops
// Load messages
$this->load_messages();
@ -133,6 +133,7 @@ class Woocommerce {
add_filter( 'comments_template', array(&$this, 'comments_template_loader') );
add_action( 'init', array(&$this, 'include_template_functions'), 99 );
add_filter( 'wp_redirect', array(&$this, 'redirect'), 1, 2 );
add_action( 'wp', array(&$this, 'buffer_checkout') );
add_action( 'wp_enqueue_scripts', array(&$this, 'frontend_scripts') );
add_action( 'wp_head', array(&$this, 'wp_head') );
add_filter( 'body_class', array(&$this, 'output_body_class') );
@ -161,27 +162,27 @@ class Woocommerce {
include( 'woocommerce-core-functions.php' ); // Contains core functions for the front/back end
include( 'widgets/widget-init.php' ); // Widget classes
include( 'classes/class-woocommerce-countries.php' ); // Defines countries and states
include( 'classes/class-woocommerce-order.php' ); // Single order class
include( 'classes/class-woocommerce-product.php' ); // Product class
include( 'classes/class-woocommerce-product-variation.php' ); // Product variation class
include( 'classes/class-woocommerce-tax.php' ); // Tax class
include( 'classes/class-wc-countries.php' ); // Defines countries and states
include( 'classes/class-wc-order.php' ); // Single order class
include( 'classes/class-wc-product.php' ); // Product class
include( 'classes/class-wc-product-variation.php' ); // Product variation class
include( 'classes/class-wc-tax.php' ); // Tax class
// Include shipping modules and gateways
include( 'classes/class-woocommerce-settings-api.php' );
include( 'classes/gateways/class-woocommerce-payment-gateways.php' );
include( 'classes/gateways/class-woocommerce-payment-gateway.php' );
include( 'classes/shipping/class-woocommerce-shipping.php' );
include( 'classes/shipping/class-woocommerce-shipping-method.php' );
include( 'classes/class-wc-settings-api.php' );
include( 'classes/gateways/class-wc-payment-gateways.php' );
include( 'classes/gateways/class-wc-payment-gateway.php' );
include( 'classes/shipping/class-wc-shipping.php' );
include( 'classes/shipping/class-wc-shipping-method.php' );
include( 'classes/shipping/class-woocommerce-flat-rate.php' );
include( 'classes/shipping/class-woocommerce-free-shipping.php' );
include( 'classes/shipping/class-woocommerce-local-delivery.php' );
include( 'classes/shipping/class-woocommerce-local-pickup.php' );
include( 'classes/gateways/class-woocommerce-bacs.php' );
include( 'classes/gateways/class-woocommerce-cheque.php' );
include( 'classes/gateways/class-woocommerce-paypal.php' );
include( 'classes/gateways/class-woocommerce-cod.php' );
include( 'classes/shipping/class-wc-flat-rate.php' );
include( 'classes/shipping/class-wc-free-shipping.php' );
include( 'classes/shipping/class-wc-local-delivery.php' );
include( 'classes/shipping/class-wc-local-pickup.php' );
include( 'classes/gateways/class-wc-bacs.php' );
include( 'classes/gateways/class-wc-cheque.php' );
include( 'classes/gateways/class-wc-paypal.php' );
include( 'classes/gateways/class-wc-cod.php' );
}
/**
@ -205,10 +206,10 @@ class Woocommerce {
include( 'woocommerce-hooks.php' ); // Template hooks used on the front-end
include( 'woocommerce-functions.php' ); // Contains functions for various front-end events
include( 'shortcodes/shortcode-init.php' ); // Init the shortcodes
include( 'classes/class-woocommerce-query.php' ); // The main store queries
include( 'classes/class-woocommerce-cart.php' ); // The main cart class
include( 'classes/class-woocommerce-coupon.php' ); // Coupon class
include( 'classes/class-woocommerce-customer.php' ); // Customer class
include( 'classes/class-wc-query.php' ); // The main store queries
include( 'classes/class-wc-cart.php' ); // The main cart class
include( 'classes/class-wc-coupon.php' ); // Coupon class
include( 'classes/class-wc-customer.php' ); // Customer class
}
/**
@ -290,6 +291,13 @@ class Woocommerce {
do_action( 'woocommerce_init' );
}
/**
* Output buffering on the checkout allows gateways to do header redirects
**/
function buffer_checkout() {
if (is_checkout()) ob_start();
}
/**
* Register WC environment globals
@ -304,7 +312,7 @@ class Woocommerce {
function setup_product_data( $post ) {
if ($post->post_type!=='product') return;
unset($GLOBALS['product']);
$GLOBALS['product'] = new Woocommerce_Product( $post->ID );
$GLOBALS['product'] = new WC_Product( $post->ID );
return $GLOBALS['product'];
}
@ -468,7 +476,7 @@ class Woocommerce {
register_taxonomy( 'product_cat',
array('product'),
array(
'hierarchical' => true,
'hierarchical' => false, // Hierarcal causes memory issues - WP loads all records!
'update_count_callback' => '_update_post_term_count',
'label' => __( 'Product Categories', 'woocommerce'),
'labels' => array(
@ -892,9 +900,9 @@ class Woocommerce {
* Get Checkout Class
*/
function checkout() {
if ( !class_exists('Woocommerce_Checkout') ) :
include( 'classes/class-woocommerce-checkout.php' );
$this->checkout = new Woocommerce_Checkout();
if ( !class_exists('WC_Checkout') ) :
include( 'classes/class-wc-checkout.php' );
$this->checkout = new WC_Checkout();
endif;
return $this->checkout;
@ -904,16 +912,16 @@ class Woocommerce {
* Get Logging Class
*/
function logger() {
if ( !class_exists('Woocommerce_Logger') ) include( 'classes/class-woocommerce-logger.php' );
return new Woocommerce_Logger();
if ( !class_exists('WC_Logger') ) include( 'classes/class-wc-logger.php' );
return new WC_Logger();
}
/**
* Get Validation Class
*/
function validation() {
if ( !class_exists('Woocommerce_Validation') ) include( 'classes/class-woocommerce-validation.php' );
return new Woocommerce_Validation();
if ( !class_exists('WC_Validation') ) include( 'classes/class-wc-validation.php' );
return new WC_Validation();
}
/**
@ -926,9 +934,9 @@ class Woocommerce {
function mailer() {
// Init mail class
if ( !class_exists('Woocommerce_Email') ) :
include( 'classes/class-woocommerce-email.php' );
$this->woocommerce_email = new Woocommerce_Email();
if ( !class_exists('WC_Email') ) :
include( 'classes/class-wc-email.php' );
$this->woocommerce_email = new WC_Email();
endif;
return $this->woocommerce_email;
}
@ -1032,17 +1040,34 @@ class Woocommerce {
* Output the errors and messages
*/
function show_messages() {
if (isset($this->errors) && sizeof($this->errors)>0) :
echo '<div class="woocommerce_error">'.$this->errors[0].'</div>';
// Show multiple errors in a list format
if (isset($this->errors) && sizeof($this->errors)>0) {
echo '<ul class="woocommerce_error">';
foreach ($this->errors as $error) {
echo '<li>' . $error . '</li>';
}
echo '</ul>';
$this->clear_messages();
return true;
elseif (isset($this->messages) && sizeof($this->messages)>0) :
// Show a single message in a div
} elseif (isset($this->messages) && sizeof($this->messages)>0) {
echo '<div class="woocommerce_message">'.$this->messages[0].'</div>';
$this->clear_messages();
return true;
else :
} else {
return false;
endif;
}
}
/**
* Set session data for messages
*/
function set_messages() {
$_SESSION['errors'] = $this->errors;
$_SESSION['messages'] = $this->messages;
}
/**
@ -1051,8 +1076,7 @@ class Woocommerce {
function redirect( $location, $status ) {
global $is_IIS;
$_SESSION['errors'] = $this->errors;
$_SESSION['messages'] = $this->messages;
$this->set_messages();
// IIS fix
if ($is_IIS) session_write_close();