|
@ -1,6 +1,6 @@
|
|||
# How to contribute
|
||||
|
||||
Community made patches, localisations, bug reports and contributions are always welcome are are crucial to ensure WooCommerce remains the #1 eCommerce platform for WordPress ;)
|
||||
Community made patches, localisations, bug reports and contributions are always welcome and are crucial to ensure WooCommerce remains the #1 eCommerce platform for WordPress ;)
|
||||
|
||||
When contributing please ensure you follow the guidelines below so that we can keep on top of things.
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/Importers
|
||||
* @version 1.7.0
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -14,7 +14,7 @@ register_importer( 'woocommerce_tax_rate_csv', __( 'WooCommerce Tax Rates (CSV)'
|
|||
|
||||
/**
|
||||
* woocommerce_tax_rates_importer function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -25,7 +25,7 @@ function woocommerce_tax_rates_importer() {
|
|||
|
||||
if ( ! class_exists( 'WP_Importer' ) ) {
|
||||
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
|
||||
if ( file_exists( $class_wp_importer ) )
|
||||
if ( file_exists( $class_wp_importer ) )
|
||||
require $class_wp_importer;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
"country","state","postcode","class","label","rate","compound","shipping"
|
||||
"US","FL","12345","","Florida tax","5.0000","0","1"
|
|
|
@ -1,4 +1,6 @@
|
|||
"countries","class","label","rate","compound","shipping"
|
||||
"GB","","VAT","20.0000","0","1"
|
||||
"GB","reduced-rate","VAT","5.0000","0","1"
|
||||
"GB","zero-rate","VAT","0.0000","0","1"
|
||||
Country Code,State Code,ZIP/Postcode,City,Rate %,Tax Name,Priority,Compound,Shipping,Tax Class
|
||||
GB,*,*,*,20.0000,VAT,1,1,1,
|
||||
GB,*,*,*,5.0000,VAT,1,1,1,reduced-rate
|
||||
GB,*,*,*,0.0000,VAT,1,1,1,zero-rate
|
||||
US,*,*,*,10.0000,US,1,1,1,
|
||||
US,AL,12345; 123456,*,2.0000,US AL,2,1,1,
|
|
|
@ -5,14 +5,14 @@
|
|||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/Importers
|
||||
* @version 1.7.0
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if ( class_exists( 'WP_Importer' ) ) {
|
||||
class WC_CSV_Tax_Rates_Import extends WP_Importer {
|
||||
|
||||
|
||||
var $id;
|
||||
var $file_url;
|
||||
var $import_page;
|
||||
|
@ -20,17 +20,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||
var $posts = array();
|
||||
var $imported;
|
||||
var $skipped;
|
||||
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->import_page = 'woocommerce_tax_rate_csv';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registered callback function for the WordPress Importer
|
||||
*
|
||||
|
@ -38,13 +38,13 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||
*/
|
||||
function dispatch() {
|
||||
$this->header();
|
||||
|
||||
|
||||
if ( ! empty( $_POST['delimiter'] ) )
|
||||
$this->delimiter = stripslashes( trim( $_POST['delimiter'] ) );
|
||||
|
||||
if ( ! $this->delimiter )
|
||||
|
||||
if ( ! $this->delimiter )
|
||||
$this->delimiter = ',';
|
||||
|
||||
|
||||
$step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
|
||||
switch ( $step ) {
|
||||
case 0:
|
||||
|
@ -58,26 +58,26 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||
$file = get_attached_file( $this->id );
|
||||
else
|
||||
$file = ABSPATH . $this->file_url;
|
||||
|
||||
|
||||
add_filter( 'http_request_timeout', array( &$this, 'bump_request_timeout' ) );
|
||||
|
||||
|
||||
if ( function_exists( 'gc_enable' ) )
|
||||
gc_enable();
|
||||
|
||||
|
||||
@set_time_limit(0);
|
||||
@ob_flush();
|
||||
@flush();
|
||||
|
||||
|
||||
$this->import( $file );
|
||||
}
|
||||
break;
|
||||
}
|
||||
$this->footer();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* format_data_from_csv function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $data
|
||||
* @param mixed $enc
|
||||
|
@ -89,134 +89,123 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||
|
||||
/**
|
||||
* import function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $file
|
||||
* @return void
|
||||
*/
|
||||
function import( $file ) {
|
||||
global $woocommerce, $wpdb;
|
||||
|
||||
|
||||
$this->imported = $this->skipped = 0;
|
||||
|
||||
|
||||
if ( ! is_file($file) ) {
|
||||
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'woocommerce' ) . '</strong><br />';
|
||||
echo __( 'The file does not exist, please try again.', 'woocommerce' ) . '</p>';
|
||||
$this->footer();
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
$new_rates = array();
|
||||
|
||||
|
||||
if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
|
||||
|
||||
|
||||
$header = fgetcsv( $handle, 0, $this->delimiter );
|
||||
|
||||
if ( sizeof( $header ) == 6 ) {
|
||||
|
||||
$rates = get_option( 'woocommerce_tax_rates' );
|
||||
|
||||
|
||||
if ( sizeof( $header ) == 10 ) {
|
||||
|
||||
$loop = 0;
|
||||
|
||||
while ( ( $row = fgetcsv( $handle, 0, $this->delimiter ) ) !== FALSE ) {
|
||||
|
||||
$rate = array();
|
||||
|
||||
list( $rate['countries'], $rate['class'], $rate['label'], $rate['rate'], $rate['compound'], $rate['shipping'] ) = $row;
|
||||
|
||||
$parsed_countries = array();
|
||||
$rate['countries'] = array_map( 'trim', explode( '|', $rate['countries'] ) );
|
||||
|
||||
foreach( $rate['countries'] as $country ) {
|
||||
if ( strstr( $country, ':' ) ) {
|
||||
list( $country, $state ) = array_map( 'trim', explode( ':', $country ) );
|
||||
|
||||
if ( ! isset( $parsed_countries[ $country ] ) )
|
||||
$parsed_countries[ $country ] = array();
|
||||
|
||||
$parsed_countries[ $country ][] = $state;
|
||||
} else {
|
||||
|
||||
if ( ! isset( $parsed_countries[ $country ] ) )
|
||||
$parsed_countries[ $country ] = array();
|
||||
|
||||
$parsed_countries[ $country ][] = '*';
|
||||
}
|
||||
|
||||
list( $country, $state, $postcode, $city, $rate, $name, $priority, $compound, $shipping, $class ) = $row;
|
||||
|
||||
$country = trim( strtoupper( $country ) );
|
||||
$state = trim( strtoupper( $state ) );
|
||||
|
||||
if ( $country == '*' )
|
||||
$country = '';
|
||||
if ( $state == '*' )
|
||||
$state = '';
|
||||
|
||||
$wpdb->insert(
|
||||
$wpdb->prefix . "woocommerce_tax_rates",
|
||||
array(
|
||||
'tax_rate_country' => $country,
|
||||
'tax_rate_state' => $state,
|
||||
'tax_rate' => number_format( $rate, 4, '.', '' ),
|
||||
'tax_rate_name' => trim( $name ),
|
||||
'tax_rate_priority' => absint( $priority ),
|
||||
'tax_rate_compound' => $compound ? 1 : 0,
|
||||
'tax_rate_shipping' => $shipping ? 1 : 0,
|
||||
'tax_rate_order' => $loop,
|
||||
'tax_rate_class' => sanitize_title( $class )
|
||||
)
|
||||
);
|
||||
|
||||
$tax_rate_id = $wpdb->insert_id;
|
||||
|
||||
$postcode = woocommerce_clean( $postcode );
|
||||
$postcodes = explode( ';', $postcode );
|
||||
$postcodes = array_map( 'strtoupper', array_map( 'woocommerce_clean', $postcodes ) );
|
||||
foreach( $postcodes as $postcode ) {
|
||||
$wpdb->insert(
|
||||
$wpdb->prefix . "woocommerce_tax_rate_locations",
|
||||
array(
|
||||
'location_code' => $postcode,
|
||||
'tax_rate_id' => $tax_rate_id,
|
||||
'location_type' => 'postcode',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$rate['countries'] = $parsed_countries;
|
||||
$rate['shipping'] = $rate['shipping'] ? 'yes' : 'no';
|
||||
$rate['compound'] = $rate['compound'] ? 'yes' : 'no';
|
||||
|
||||
$new_rates[] = $rate;
|
||||
|
||||
unset( $rate, $row );
|
||||
|
||||
|
||||
$city = woocommerce_clean( $city );
|
||||
$cities = explode( ';', $city );
|
||||
$cities = array_map( 'strtoupper', array_map( 'woocommerce_clean', $cities ) );
|
||||
foreach( $cities as $city ) {
|
||||
$wpdb->insert(
|
||||
$wpdb->prefix . "woocommerce_tax_rate_locations",
|
||||
array(
|
||||
'location_code' => $city,
|
||||
'tax_rate_id' => $tax_rate_id,
|
||||
'location_type' => 'city',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$loop ++;
|
||||
$this->imported++;
|
||||
}
|
||||
|
||||
$rates = array_merge( $rates, $new_rates );
|
||||
|
||||
update_option( 'woocommerce_tax_rates', $rates );
|
||||
|
||||
} elseif ( sizeof( $header ) == 8 ) {
|
||||
|
||||
$rates = get_option( 'woocommerce_local_tax_rates' );
|
||||
|
||||
while ( ( $row = fgetcsv( $handle, 0, $this->delimiter ) ) !== FALSE ) {
|
||||
|
||||
$rate = array();
|
||||
|
||||
list( $rate['country'], $rate['state'], $rate['postcode'], $rate['class'], $rate['label'], $rate['rate'], $rate['compound'], $rate['shipping'] ) = $row;
|
||||
|
||||
if ( ! $rate['country'] || ! $rate['postcode'] || ! $rate['rate'] ) {
|
||||
$this->skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$rate['state'] = $rate['state'] ? $rate['state'] : '*';
|
||||
$rate['shipping'] = $rate['shipping'] ? 'yes' : 'no';
|
||||
$rate['compound'] = $rate['compound'] ? 'yes' : 'no';
|
||||
$rate['postcode'] = array_map( 'trim', explode( '|', $rate['postcode'] ) );
|
||||
|
||||
$new_rates[] = $rate;
|
||||
|
||||
unset( $rate, $row );
|
||||
|
||||
$this->imported++;
|
||||
}
|
||||
|
||||
$rates = array_merge( $rates, $new_rates );
|
||||
|
||||
update_option( 'woocommerce_local_tax_rates', $rates );
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'woocommerce' ) . '</strong><br />';
|
||||
echo __( 'The CSV is invalid.', 'woocommerce' ) . '</p>';
|
||||
$this->footer();
|
||||
die();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
fclose( $handle );
|
||||
}
|
||||
|
||||
|
||||
// Show Result
|
||||
echo '<div class="updated settings-error below-h2"><p>
|
||||
'.sprintf( __( 'Import complete - imported <strong>%s</strong> tax rates and skipped <strong>%s</strong>.', 'woocommerce' ), $this->imported, $this->skipped ).'
|
||||
</p></div>';
|
||||
|
||||
|
||||
$this->import_end();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs post-import cleanup of files and the cache
|
||||
*/
|
||||
function import_end() {
|
||||
echo '<p>' . __( 'All done!', 'woocommerce' ) . ' <a href="' . admin_url('admin.php?page=woocommerce_settings&tab=tax') . '">' . __( 'View Tax Rates', 'woocommerce' ) . '</a>' . '</p>';
|
||||
|
||||
|
||||
do_action( 'import_end' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles the CSV upload and initial parsing of the file to prepare for
|
||||
* displaying author import options
|
||||
|
@ -224,76 +213,74 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||
* @return bool False if error uploading or invalid file, true otherwise
|
||||
*/
|
||||
function handle_upload() {
|
||||
|
||||
|
||||
if ( empty( $_POST['file_url'] ) ) {
|
||||
|
||||
|
||||
$file = wp_import_handle_upload();
|
||||
|
||||
|
||||
if ( isset( $file['error'] ) ) {
|
||||
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'woocommerce' ) . '</strong><br />';
|
||||
echo esc_html( $file['error'] ) . '</p>';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$this->id = (int) $file['id'];
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
if ( file_exists( ABSPATH . $_POST['file_url'] ) ) {
|
||||
|
||||
|
||||
$this->file_url = esc_attr( $_POST['file_url'] );
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'woocommerce' ) . '</strong></p>';
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* header function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function header() {
|
||||
echo '<div class="wrap"><div class="icon32" id="icon-woocommerce-importer"><br></div>';
|
||||
echo '<div class="wrap"><div class="icon32 icon32-woocommerce-importer" id="icon-woocommerce"><br></div>';
|
||||
echo '<h2>' . __( 'Import Tax Rates', 'woocommerce' ) . '</h2>';
|
||||
}
|
||||
|
||||
/**
|
||||
* footer function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function footer() {
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* greet function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function greet() {
|
||||
global $woocommerce;
|
||||
|
||||
|
||||
echo '<div class="narrow">';
|
||||
echo '<p>' . __( 'Hi there! Upload a CSV file containing tax rates to import the contents into your shop. Choose a .csv file to upload, then click "Upload file and import".', 'woocommerce' ).'</p>';
|
||||
|
||||
echo '<p>' . sprintf( __( 'Tax rates need to be defined with columns in a specific order (6 columns). <a href="%s">Click here to download a sample</a>.', 'woocommerce' ), $woocommerce->plugin_url() . '/admin/importers/samples/sample_tax_rates.csv' ) . '</p>';
|
||||
|
||||
echo '<p>' . sprintf( __( 'Local tax rates also need to be defined with columns in a specific order (8 columns). <a href="%s">Click here to download a sample</a>.', 'woocommerce' ), $woocommerce->plugin_url() . '/admin/importers/samples/sample_local_tax_rates.csv' ) . '</p>';
|
||||
|
||||
|
||||
echo '<p>' . sprintf( __( 'Tax rates need to be defined with columns in a specific order (10 columns). <a href="%s">Click here to download a sample</a>.', 'woocommerce' ), $woocommerce->plugin_url() . '/admin/importers/samples/sample_tax_rates.csv' ) . '</p>';
|
||||
|
||||
$action = 'admin.php?import=woocommerce_tax_rate_csv&step=1';
|
||||
|
||||
|
||||
$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
|
||||
$size = wp_convert_bytes_to_hr( $bytes );
|
||||
$upload_dir = wp_upload_dir();
|
||||
|
@ -336,10 +323,10 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||
</form>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Added to http_request_timeout filter to force timeout at 60 seconds during import
|
||||
* @return int 60
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* WC_CSV_Exporter class.
|
||||
*
|
||||
* Takes any data and turns it into a CSV for output.
|
||||
*
|
||||
* @class WC_Cart
|
||||
* @version 1.6.4
|
||||
* @package WooCommerce/Classes
|
||||
* @author WooThemes
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
class WC_CSV_Exporter {
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
* @access private
|
||||
*/
|
||||
private $_csv = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
private $_filename = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
private $_output = true;
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @param bool $output (default: true)
|
||||
* @param mixed $filename
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $columns = array(), $output = true, $filename = '' ) {
|
||||
$this->_csv = '';
|
||||
$this->_filename = $filename ? $filename : 'export.csv';
|
||||
|
||||
if ( $this->_output = $output )
|
||||
$this->start();
|
||||
|
||||
if ( $columns )
|
||||
$this->set_columns( $columns );
|
||||
}
|
||||
|
||||
function set_filename( $filename ) {
|
||||
$this->_filename = $filename ? $filename : 'export.csv';
|
||||
}
|
||||
|
||||
/**
|
||||
* set_columns function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function set_columns( $columns = array() ) {
|
||||
$this->add_row( $columns );
|
||||
unset( $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* add_row function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function add_row( $row ) {
|
||||
|
||||
$row = implode( ',', array_map( array( &$this, 'wrap_column' ), $row ) ) . "\n";
|
||||
|
||||
if ( $this->_output )
|
||||
fwrite( $this->_csv, $row );
|
||||
else
|
||||
$this->_csv += $row;
|
||||
|
||||
unset( $row );
|
||||
}
|
||||
|
||||
/**
|
||||
* start function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function start() {
|
||||
if ( headers_sent() )
|
||||
wp_die( 'Headers already sent' );
|
||||
|
||||
@set_time_limit(0);
|
||||
@ob_clean();
|
||||
|
||||
header( "Content-Type: text/csv; charset=UTF-8" );
|
||||
header( "Content-Disposition: attachment; filename={$this->_filename}" );
|
||||
header( "Pragma: no-cache" );
|
||||
header( "Expires: 0" );
|
||||
|
||||
$this->_csv = fopen( 'php://output', 'w') ;
|
||||
}
|
||||
|
||||
/**
|
||||
* end function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function end() {
|
||||
fclose( $this->_csv );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* wrap_column function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $data
|
||||
* @return void
|
||||
*/
|
||||
function wrap_column( $data ) {
|
||||
return '"' . str_replace( '"', '""', $data ) . '"';
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<div id="message" class="updated woocommerce-message wc-connect">
|
||||
<div class="squeezer">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<div id="message" class="updated woocommerce-message wc-connect">
|
||||
<div class="squeezer">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<div id="message" class="updated woocommerce-message wc-connect">
|
||||
<div class="squeezer">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<div id="message" class="updated woocommerce-message wc-connect">
|
||||
<div class="squeezer">
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/Updates
|
||||
* @version 1.7.0
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/Updates
|
||||
* @version 1.7.0
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
global $wpdb, $woocommerce;
|
||||
|
||||
// Update woocommerce_downloadable_product_permissions table to include order ID's as well as keys
|
||||
$results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "woocommerce_downloadable_product_permissions WHERE order_id = 0;" ) );
|
||||
$results = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE order_id = 0;" );
|
||||
|
||||
if ( $results ) foreach ( $results as $result ) {
|
||||
|
||||
|
@ -38,10 +38,10 @@ if ( $results ) foreach ( $results as $result ) {
|
|||
// 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( $wpdb->prepare( "
|
||||
$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')
|
||||
" ) );
|
||||
" );
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* Update WC to 1.7
|
||||
* Update WC to 2.0
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/Updates
|
||||
* @version 1.7.0
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -13,30 +13,30 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
global $wpdb, $woocommerce;
|
||||
|
||||
// Upgrade old style files paths to support multiple file paths
|
||||
$existing_file_paths = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM ". $wpdb->postmeta . " WHERE meta_key = '_file_path'" ) );
|
||||
$existing_file_paths = $wpdb->get_results( "SELECT * FROM {$wpdb->postmeta} WHERE meta_key = '_file_path'" );
|
||||
|
||||
if ( $existing_file_paths ) {
|
||||
|
||||
|
||||
foreach( $existing_file_paths as $existing_file_path ) {
|
||||
|
||||
$existing_file_path->meta_value = trim( $existing_file_path->meta_value );
|
||||
|
||||
if ( $existing_file_path->meta_value )
|
||||
$file_paths = maybe_serialize( array( md5( $existing_file_path->meta_value ) => $existing_file_path->meta_value ) );
|
||||
else
|
||||
$file_paths = '';
|
||||
|
||||
$wpdb->query( $wpdb->prepare( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_file_paths', meta_value = %s WHERE meta_id = %d", $file_paths, $existing_file_path->meta_id ) );
|
||||
|
||||
$wpdb->query( $wpdb->prepare( "UPDATE " . $wpdb->prefix . "woocommerce_downloadable_product_permissions SET download_id = %s WHERE product_id = %d", md5( $existing_file_path->meta_value ), $existing_file_path->post_id ) );
|
||||
|
||||
$old_file_path = trim( $existing_file_path->meta_value );
|
||||
|
||||
if ( ! empty( $old_file_path ) ) {
|
||||
$file_paths = maybe_serialize( array( md5( $old_file_path ) => $old_file_path ) );
|
||||
|
||||
|
||||
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_key = '_file_paths', meta_value = %s WHERE meta_id = %d", $file_paths, $existing_file_path->meta_id ) );
|
||||
|
||||
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}woocommerce_downloadable_product_permissions SET download_id = %s WHERE product_id = %d", md5( $old_file_path ), $existing_file_path->post_id ) );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update table primary keys
|
||||
$wpdb->query( $wpdb->prepare( "ALTER TABLE ". $wpdb->prefix . "woocommerce_downloadable_product_permissions DROP PRIMARY KEY" ) );
|
||||
$wpdb->query( "ALTER TABLE {$wpdb->prefix}woocommerce_downloadable_product_permissions DROP PRIMARY KEY" );
|
||||
|
||||
$wpdb->query( $wpdb->prepare( "ALTER TABLE ". $wpdb->prefix . "woocommerce_downloadable_product_permissions ADD PRIMARY KEY ( `product_id` , `order_id` , `order_key` , `download_id` )" ) );
|
||||
$wpdb->query( "ALTER TABLE {$wpdb->prefix}woocommerce_downloadable_product_permissions ADD PRIMARY KEY ( `product_id` , `order_id` , `order_key` , `download_id` )" );
|
||||
|
||||
// Setup default permalinks if shop page is defined
|
||||
$permalinks = get_option( 'woocommerce_permalinks' );
|
||||
|
@ -45,11 +45,11 @@ $shop_page_id = woocommerce_get_page_id( 'shop' );
|
|||
if ( empty( $permalinks ) && $shop_page_id > 0 ) {
|
||||
|
||||
$base_slug = $shop_page_id > 0 && get_page( $shop_page_id ) ? get_page_uri( $shop_page_id ) : 'shop';
|
||||
|
||||
|
||||
$category_base = get_option('woocommerce_prepend_shop_page_to_urls') == "yes" ? trailingslashit( $base_slug ) : '';
|
||||
$category_slug = get_option('woocommerce_product_category_slug') ? get_option('woocommerce_product_category_slug') : _x( 'product-category', 'slug', 'woocommerce' );
|
||||
$tag_slug = get_option('woocommerce_product_tag_slug') ? get_option('woocommerce_product_tag_slug') : _x( 'product-tag', 'slug', 'woocommerce' );
|
||||
|
||||
|
||||
if ( 'yes' == get_option('woocommerce_prepend_shop_page_to_products') ) {
|
||||
$product_base = trailingslashit( $base_slug );
|
||||
} else {
|
||||
|
@ -59,8 +59,8 @@ if ( empty( $permalinks ) && $shop_page_id > 0 ) {
|
|||
$product_base = trailingslashit( _x('product', 'slug', 'woocommerce') );
|
||||
}
|
||||
}
|
||||
|
||||
if ( get_option('woocommerce_prepend_category_to_products') == 'yes' )
|
||||
|
||||
if ( get_option('woocommerce_prepend_category_to_products') == 'yes' )
|
||||
$product_base .= trailingslashit('%product_cat%');
|
||||
|
||||
$permalinks = array(
|
||||
|
@ -69,8 +69,8 @@ if ( empty( $permalinks ) && $shop_page_id > 0 ) {
|
|||
'attribute_base' => untrailingslashit( $category_base ),
|
||||
'tag_base' => untrailingslashit( $category_base . $tag_slug )
|
||||
);
|
||||
|
||||
update_option( 'woocommerce_permalinks', $permalinks );
|
||||
|
||||
update_option( 'woocommerce_permalinks', $permalinks );
|
||||
}
|
||||
|
||||
// Update subcat display settings
|
||||
|
@ -90,36 +90,123 @@ if ( get_option( 'woocommerce_show_subcategories' ) == 'yes' ) {
|
|||
}
|
||||
}
|
||||
|
||||
// Update tax rates
|
||||
$loop = 0;
|
||||
$tax_rates = get_option( 'woocommerce_tax_rates' );
|
||||
|
||||
if ( $tax_rates )
|
||||
foreach ( $tax_rates as $tax_rate ) {
|
||||
|
||||
foreach ( $tax_rate['countries'] as $country => $states ) {
|
||||
|
||||
$states = array_reverse( $states );
|
||||
|
||||
foreach ( $states as $state ) {
|
||||
|
||||
if ( $state == '*' )
|
||||
$state = '';
|
||||
|
||||
$wpdb->insert(
|
||||
$wpdb->prefix . "woocommerce_tax_rates",
|
||||
array(
|
||||
'tax_rate_country' => $country,
|
||||
'tax_rate_state' => $state,
|
||||
'tax_rate' => $tax_rate['rate'],
|
||||
'tax_rate_name' => $tax_rate['label'],
|
||||
'tax_rate_priority' => 1,
|
||||
'tax_rate_compound' => $tax_rate['compound'] == 'yes' ? 1 : 0,
|
||||
'tax_rate_shipping' => $tax_rate['shipping'] == 'yes' ? 1 : 0,
|
||||
'tax_rate_order' => $loop,
|
||||
'tax_rate_class' => $tax_rate['class']
|
||||
)
|
||||
);
|
||||
|
||||
$loop++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$local_tax_rates = get_option( 'woocommerce_local_tax_rates' );
|
||||
|
||||
if ( $local_tax_rates )
|
||||
foreach ( $local_tax_rates as $tax_rate ) {
|
||||
|
||||
$location_type = $tax_rate['location_type'] == 'postcode' ? 'postcode' : 'city';
|
||||
|
||||
if ( $tax_rate['state'] == '*' )
|
||||
$tax_rate['state'] = '';
|
||||
|
||||
$wpdb->insert(
|
||||
$wpdb->prefix . "woocommerce_tax_rates",
|
||||
array(
|
||||
'tax_rate_country' => $tax_rate['country'],
|
||||
'tax_rate_state' => $tax_rate['state'],
|
||||
'tax_rate' => $tax_rate['rate'],
|
||||
'tax_rate_name' => $tax_rate['label'],
|
||||
'tax_rate_priority' => 2,
|
||||
'tax_rate_compound' => $tax_rate['compound'] == 'yes' ? 1 : 0,
|
||||
'tax_rate_shipping' => $tax_rate['shipping'] == 'yes' ? 1 : 0,
|
||||
'tax_rate_order' => $loop,
|
||||
'tax_rate_class' => $tax_rate['class']
|
||||
)
|
||||
);
|
||||
|
||||
$tax_rate_id = $wpdb->insert_id;
|
||||
|
||||
if ( $tax_rate['locations'] ) {
|
||||
foreach ( $tax_rate['locations'] as $location ) {
|
||||
|
||||
$wpdb->insert(
|
||||
$wpdb->prefix . "woocommerce_tax_rate_locations",
|
||||
array(
|
||||
'location_code' => $location,
|
||||
'tax_rate_id' => $tax_rate_id,
|
||||
'location_type' => $location_type,
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$loop++;
|
||||
}
|
||||
|
||||
update_option( 'woocommerce_tax_rates_backup', $tax_rates );
|
||||
update_option( 'woocommerce_local_tax_rates_backup', $local_tax_rates );
|
||||
delete_option( 'woocommerce_tax_rates' );
|
||||
delete_option( 'woocommerce_local_tax_rates' );
|
||||
|
||||
|
||||
// Now its time for the massive update to line items - move them to the new DB tables
|
||||
// Reverse with UPDATE `wpwc_postmeta` SET meta_key = '_order_items' WHERE meta_key = '_order_items_old'
|
||||
$order_item_rows = $wpdb->get_results( $wpdb->prepare( "
|
||||
$order_item_rows = $wpdb->get_results( "
|
||||
SELECT * FROM {$wpdb->postmeta}
|
||||
WHERE meta_key = '_order_items'
|
||||
" ) );
|
||||
" );
|
||||
|
||||
foreach ( $order_item_rows as $order_item_row ) {
|
||||
|
||||
|
||||
$order_items = (array) maybe_unserialize( $order_item_row->meta_value );
|
||||
|
||||
|
||||
foreach ( $order_items as $order_item ) {
|
||||
|
||||
|
||||
if ( ! isset( $order_item['line_total'] ) && isset( $order_item['taxrate'] ) && isset( $order_item['cost'] ) ) {
|
||||
$order_item['line_tax'] = number_format( ( $order_item['cost'] * $order_item['qty'] ) * ( $order_item['taxrate'] / 100 ), 2, '.', '' );
|
||||
$order_item['line_total'] = $order_item['cost'] * $order_item['qty'];
|
||||
$order_item['line_subtotal_tax'] = $order_item['line_tax'];
|
||||
$order_item['line_subtotal'] = $order_item['line_total'];
|
||||
}
|
||||
|
||||
|
||||
$order_item['line_tax'] = isset( $order_item['line_tax'] ) ? $order_item['line_tax'] : 0;
|
||||
$order_item['line_total'] = isset( $order_item['line_total'] ) ? $order_item['line_total'] : 0;
|
||||
$order_item['line_subtotal_tax'] = isset( $order_item['line_subtotal_tax'] ) ? $order_item['line_subtotal_tax'] : 0;
|
||||
$order_item['line_subtotal'] = isset( $order_item['line_subtotal'] ) ? $order_item['line_subtotal'] : 0;
|
||||
|
||||
|
||||
$item_id = woocommerce_add_order_item( $order_item_row->post_id, array(
|
||||
'order_item_name' => $order_item['name'],
|
||||
'order_item_type' => 'line_item'
|
||||
) );
|
||||
|
||||
|
||||
// Add line item meta
|
||||
if ( $item_id ) {
|
||||
woocommerce_add_order_item_meta( $item_id, '_qty', absint( $order_item['qty'] ) );
|
||||
|
@ -130,9 +217,9 @@ foreach ( $order_item_rows as $order_item_row ) {
|
|||
woocommerce_add_order_item_meta( $item_id, '_line_subtotal_tax', woocommerce_format_decimal( $order_item['line_subtotal_tax'] ) );
|
||||
woocommerce_add_order_item_meta( $item_id, '_line_total', woocommerce_format_decimal( $order_item['line_total'] ) );
|
||||
woocommerce_add_order_item_meta( $item_id, '_line_tax', woocommerce_format_decimal( $order_item['line_tax'] ) );
|
||||
|
||||
|
||||
$meta_rows = array();
|
||||
|
||||
|
||||
// Insert meta
|
||||
if ( ! empty( $order_item['item_meta'] ) ) {
|
||||
foreach ( $order_item['item_meta'] as $key => $meta ) {
|
||||
|
@ -144,7 +231,7 @@ foreach ( $order_item_rows as $order_item_row ) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Insert meta rows at once
|
||||
if ( sizeof( $meta_rows ) > 0 ) {
|
||||
$wpdb->query( $wpdb->prepare( "
|
||||
|
@ -152,7 +239,7 @@ foreach ( $order_item_rows as $order_item_row ) {
|
|||
VALUES " . implode( ',', $meta_rows ) . ";
|
||||
", $order_item_row->post_id ) );
|
||||
}
|
||||
|
||||
|
||||
// Delete from DB (rename)
|
||||
$wpdb->query( $wpdb->prepare( "
|
||||
UPDATE {$wpdb->postmeta}
|
||||
|
@ -161,40 +248,40 @@ foreach ( $order_item_rows as $order_item_row ) {
|
|||
AND post_id = %d
|
||||
", $order_item_row->post_id ) );
|
||||
}
|
||||
|
||||
|
||||
unset( $meta_rows, $item_id, $order_item );
|
||||
}
|
||||
}
|
||||
|
||||
// Do the same kind of update for order_taxes - move to lines
|
||||
// Reverse with UPDATE `wpwc_postmeta` SET meta_key = '_order_taxes' WHERE meta_key = '_order_taxes_old'
|
||||
$order_tax_rows = $wpdb->get_results( $wpdb->prepare( "
|
||||
$order_tax_rows = $wpdb->get_results( "
|
||||
SELECT * FROM {$wpdb->postmeta}
|
||||
WHERE meta_key = '_order_taxes'
|
||||
" ) );
|
||||
" );
|
||||
|
||||
foreach ( $order_tax_rows as $order_tax_row ) {
|
||||
|
||||
|
||||
$order_taxes = (array) maybe_unserialize( $order_tax_row->meta_value );
|
||||
|
||||
|
||||
if ( $order_taxes ) {
|
||||
foreach( $order_taxes as $order_tax ) {
|
||||
|
||||
|
||||
if ( ! isset( $order_tax['label'] ) || ! isset( $order_tax['cart_tax'] ) || ! isset( $order_tax['shipping_tax'] ) )
|
||||
continue;
|
||||
|
||||
|
||||
$item_id = woocommerce_add_order_item( $order_tax_row->post_id, array(
|
||||
'order_item_name' => $order_tax['label'],
|
||||
'order_item_type' => 'tax'
|
||||
) );
|
||||
|
||||
|
||||
// Add line item meta
|
||||
if ( $item_id ) {
|
||||
woocommerce_add_order_item_meta( $item_id, 'compound', absint( isset( $order_tax['compound'] ) ? $order_tax['compound'] : 0 ) );
|
||||
woocommerce_add_order_item_meta( $item_id, 'tax_amount', woocommerce_clean( $order_tax['cart_tax'] ) );
|
||||
woocommerce_add_order_item_meta( $item_id, 'shipping_tax_amount', woocommerce_clean( $order_tax['shipping_tax'] ) );
|
||||
}
|
||||
|
||||
|
||||
// Delete from DB (rename)
|
||||
$wpdb->query( $wpdb->prepare( "
|
||||
UPDATE {$wpdb->postmeta}
|
||||
|
@ -202,42 +289,8 @@ foreach ( $order_tax_rows as $order_tax_row ) {
|
|||
WHERE meta_key = '_order_taxes'
|
||||
AND post_id = %d
|
||||
", $order_tax_row->post_id ) );
|
||||
|
||||
|
||||
unset( $tax_amount );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update manual counters for product categories (only counting visible products, so visibility: 'visible' or 'catalog')
|
||||
// Loop through all products and put the IDs in array with each product category term id as index
|
||||
$products_query_args = array(
|
||||
'post_type' => 'product',
|
||||
'posts_per_page' => -1,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => '_visibility',
|
||||
'value' => array( 'visible', 'catalog' ),
|
||||
'compare' => 'IN',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$products_query = new WP_Query( $products_query_args );
|
||||
|
||||
$counted_ids = array();
|
||||
|
||||
foreach( $products_query->posts as $visible_product ) {
|
||||
$product_terms = wp_get_post_terms( $visible_product->ID, 'product_cat', array( 'fields' => 'ids' ) );
|
||||
|
||||
foreach ( $product_terms as $product_term_id ) {
|
||||
if ( ! isset( $counted_ids[ $product_term_id ] ) || ! is_array( $counted_ids[ $product_term_id ] ) ) {
|
||||
$counted_ids[ $product_term_id ] = array();
|
||||
}
|
||||
|
||||
if ( ! in_array( $visible_product->ID, $counted_ids[ $product_term_id ] ) ) {
|
||||
array_push( $counted_ids[ $product_term_id ], $visible_product->ID );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'wc_prod_cat_counts', $counted_ids );
|
||||
}
|
|
@ -78,7 +78,7 @@ function woocommerce_edit_product_columns( $columns ) {
|
|||
|
||||
if ( empty( $columns ) && ! is_array( $columns ) )
|
||||
$columns = array();
|
||||
|
||||
|
||||
unset( $columns['title'], $columns['comments'], $columns['date'] );
|
||||
|
||||
$columns["cb"] = "<input type=\"checkbox\" />";
|
||||
|
@ -115,7 +115,7 @@ add_filter('manage_edit-product_columns', 'woocommerce_edit_product_columns');
|
|||
*/
|
||||
function woocommerce_custom_product_columns( $column ) {
|
||||
global $post, $woocommerce;
|
||||
$product = new WC_Product($post->ID);
|
||||
$product = get_product($post);
|
||||
|
||||
switch ($column) {
|
||||
case "thumb" :
|
||||
|
@ -712,7 +712,7 @@ function woocommerce_admin_product_quick_edit_save( $post_id, $post ) {
|
|||
|
||||
global $woocommerce, $wpdb;
|
||||
|
||||
$product = new WC_Product( $post_id );
|
||||
$product = get_product( $post );
|
||||
|
||||
// Save fields
|
||||
if(isset($_POST['_sku'])) update_post_meta($post_id, '_sku', esc_html(stripslashes($_POST['_sku'])));
|
||||
|
@ -1003,41 +1003,41 @@ function woocommerce_admin_product_bulk_edit_save( $post_id, $post ) {
|
|||
|
||||
global $woocommerce, $wpdb;
|
||||
|
||||
$product = new WC_Product( $post_id );
|
||||
$product = get_product( $post );
|
||||
|
||||
// Save fields
|
||||
if ( ! empty( $_REQUEST['change_weight'] ) && isset( $_REQUEST['_weight'] ) )
|
||||
update_post_meta( $post_id, '_weight', esc_html( stripslashes( $_REQUEST['_weight'] ) ) );
|
||||
|
||||
if ( ! empty( $_REQUEST['change_dimensions'] ) ) {
|
||||
if ( isset( $_REQUEST['_length'] ) )
|
||||
if ( isset( $_REQUEST['_length'] ) )
|
||||
update_post_meta( $post_id, '_length', esc_html( stripslashes( $_REQUEST['_length'] ) ) );
|
||||
if ( isset( $_REQUEST['_width'] ) )
|
||||
if ( isset( $_REQUEST['_width'] ) )
|
||||
update_post_meta( $post_id, '_width', esc_html( stripslashes( $_REQUEST['_width'] ) ) );
|
||||
if ( isset( $_REQUEST['_height'] ) )
|
||||
if ( isset( $_REQUEST['_height'] ) )
|
||||
update_post_meta( $post_id, '_height', esc_html( stripslashes( $_REQUEST['_height'] ) ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $_REQUEST['_stock_status'] ) )
|
||||
if ( ! empty( $_REQUEST['_stock_status'] ) )
|
||||
update_post_meta( $post_id, '_stock_status', stripslashes( $_REQUEST['_stock_status'] ) );
|
||||
|
||||
if ( ! empty( $_REQUEST['_visibility'] ) )
|
||||
if ( ! empty( $_REQUEST['_visibility'] ) )
|
||||
update_post_meta( $post_id, '_visibility', stripslashes( $_REQUEST['_visibility'] ) );
|
||||
|
||||
if ( ! empty( $_REQUEST['_featured'] ) )
|
||||
if ( ! empty( $_REQUEST['_featured'] ) )
|
||||
update_post_meta( $post_id, '_featured', stripslashes( $_REQUEST['_featured'] ) );
|
||||
|
||||
// Handle price - remove dates and set to lowest
|
||||
if ( $product->is_type( 'simple' ) || $product->is_type( 'external' ) ) {
|
||||
|
||||
$price_changed = false;
|
||||
|
||||
|
||||
if ( ! empty( $_REQUEST['change_regular_price'] ) ) {
|
||||
|
||||
|
||||
$old_price = $product->regular_price;
|
||||
$change_regular_price = absint( $_REQUEST['change_regular_price'] );
|
||||
$regular_price = esc_attr( stripslashes( $_REQUEST['_regular_price'] ) );
|
||||
|
||||
|
||||
switch ( $change_regular_price ) {
|
||||
case 1 :
|
||||
$new_price = $regular_price;
|
||||
|
@ -1050,7 +1050,7 @@ function woocommerce_admin_product_bulk_edit_save( $post_id, $post ) {
|
|||
$new_price = $old_price + $regular_price;
|
||||
}
|
||||
break;
|
||||
case 3 :
|
||||
case 3 :
|
||||
if ( strstr( $regular_price, '%' ) ) {
|
||||
$percent = str_replace( '%', '', $regular_price ) / 100;
|
||||
$new_price = $old_price - ( $old_price * $percent );
|
||||
|
@ -1059,20 +1059,20 @@ function woocommerce_admin_product_bulk_edit_save( $post_id, $post ) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ( isset( $new_price ) && $new_price != $product->regular_price ) {
|
||||
$price_changed = true;
|
||||
update_post_meta( $post_id, '_regular_price', $new_price );
|
||||
$product->regular_price = $new_price;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( ! empty( $_REQUEST['change_sale_price'] ) ) {
|
||||
|
||||
|
||||
$old_price = $product->sale_price;
|
||||
$change_sale_price = absint( $_REQUEST['change_sale_price'] );
|
||||
$sale_price = esc_attr( stripslashes( $_REQUEST['_sale_price'] ) );
|
||||
|
||||
|
||||
switch ( $change_sale_price ) {
|
||||
case 1 :
|
||||
$new_price = $sale_price;
|
||||
|
@ -1085,7 +1085,7 @@ function woocommerce_admin_product_bulk_edit_save( $post_id, $post ) {
|
|||
$new_price = $old_price + $sale_price;
|
||||
}
|
||||
break;
|
||||
case 3 :
|
||||
case 3 :
|
||||
if ( strstr( $sale_price, '%' ) ) {
|
||||
$percent = str_replace( '%', '', $sale_price ) / 100;
|
||||
$new_price = $old_price - ( $old_price * $percent );
|
||||
|
@ -1093,7 +1093,7 @@ function woocommerce_admin_product_bulk_edit_save( $post_id, $post ) {
|
|||
$new_price = $old_price - $sale_price;
|
||||
}
|
||||
break;
|
||||
case 4 :
|
||||
case 4 :
|
||||
if ( strstr( $sale_price, '%' ) ) {
|
||||
$percent = str_replace( '%', '', $sale_price ) / 100;
|
||||
$new_price = $product->regular_price - ( $product->regular_price * $percent );
|
||||
|
@ -1102,18 +1102,18 @@ function woocommerce_admin_product_bulk_edit_save( $post_id, $post ) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ( isset( $new_price ) && $new_price != $product->sale_price ) {
|
||||
$price_changed = true;
|
||||
update_post_meta( $post_id, '_sale_price', $new_price );
|
||||
$product->sale_price = $new_price;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( $price_changed ) {
|
||||
update_post_meta( $post_id, '_sale_price_dates_from', '' );
|
||||
update_post_meta( $post_id, '_sale_price_dates_to', '' );
|
||||
|
||||
|
||||
if ( $product->regular_price < $product->sale_price ) {
|
||||
$product->sale_price = '';
|
||||
update_post_meta( $post_id, '_sale_price', '' );
|
||||
|
@ -1129,22 +1129,22 @@ function woocommerce_admin_product_bulk_edit_save( $post_id, $post ) {
|
|||
|
||||
// Handle stock
|
||||
if ( ! $product->is_type( 'grouped' ) ) {
|
||||
|
||||
|
||||
if ( ! empty( $_REQUEST['change_stock'] ) ) {
|
||||
update_post_meta( $post_id, '_stock', (int) $_REQUEST['_stock'] );
|
||||
update_post_meta( $post_id, '_manage_stock', 'yes' );
|
||||
update_post_meta( $post_id, '_manage_stock', 'yes' );
|
||||
}
|
||||
|
||||
|
||||
if ( ! empty( $_REQUEST['_manage_stock'] ) ) {
|
||||
|
||||
if ( $_REQUEST['_manage_stock'] == 'yes' ) {
|
||||
update_post_meta( $post_id, '_manage_stock', 'yes' );
|
||||
update_post_meta( $post_id, '_manage_stock', 'yes' );
|
||||
} else {
|
||||
update_post_meta( $post_id, '_manage_stock', 'no' );
|
||||
update_post_meta( $post_id, '_stock', '0' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Clear transient
|
||||
|
@ -1176,4 +1176,24 @@ function woocommerce_default_sorting_link( $views ) {
|
|||
return $views;
|
||||
}
|
||||
|
||||
add_filter( 'views_edit-product', 'woocommerce_default_sorting_link' );
|
||||
add_filter( 'views_edit-product', 'woocommerce_default_sorting_link' );
|
||||
|
||||
|
||||
/**
|
||||
* woocommerce_disable_checked_ontop function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $args
|
||||
* @param mixed $post_id
|
||||
* @return void
|
||||
*/
|
||||
function woocommerce_disable_checked_ontop( $args ) {
|
||||
|
||||
if ( $args['taxonomy'] == 'product_cat' ) {
|
||||
$args['checked_ontop'] = false;
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
add_filter( 'wp_terms_checklist_args', 'woocommerce_disable_checked_ontop' );
|
||||
|
|
|
@ -22,7 +22,7 @@ function woocommerce_edit_coupon_columns($columns){
|
|||
$columns = array();
|
||||
|
||||
$columns["cb"] = "<input type=\"checkbox\" />";
|
||||
$columns["title"] = __( 'Code', 'woocommerce' );
|
||||
$columns["coupon_code"] = __( 'Code', 'woocommerce' );
|
||||
$columns["type"] = __( 'Coupon type', 'woocommerce' );
|
||||
$columns["amount"] = __( 'Coupon amount', 'woocommerce' );
|
||||
$columns["description"] = __( 'Description', 'woocommerce' );
|
||||
|
@ -47,6 +47,43 @@ function woocommerce_custom_coupon_columns( $column ) {
|
|||
global $post, $woocommerce;
|
||||
|
||||
switch ( $column ) {
|
||||
case "coupon_code" :
|
||||
$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 '<div class="code tips" data-tip="' . __( 'Edit coupon', 'woocommerce' ) . '"><a href="' . esc_attr( $edit_link ) . '"><span>' . esc_html( $title ). '</span></a></div>';
|
||||
|
||||
_post_states( $post );
|
||||
|
||||
// Get actions
|
||||
$actions = array();
|
||||
|
||||
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', 'woocommerce' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __( 'Restore', 'woocommerce' ) . "</a>";
|
||||
elseif ( EMPTY_TRASH_DAYS )
|
||||
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash', 'woocommerce' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash', 'woocommerce' ) . "</a>";
|
||||
if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
|
||||
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently', 'woocommerce' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently', 'woocommerce' ) . "</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>';
|
||||
|
||||
break;
|
||||
case "type" :
|
||||
echo esc_html( $woocommerce->get_coupon_discount_type( get_post_meta( $post->ID, 'discount_type', true ) ) );
|
||||
break;
|
||||
|
@ -56,34 +93,34 @@ function woocommerce_custom_coupon_columns( $column ) {
|
|||
case "products" :
|
||||
$product_ids = get_post_meta( $post->ID, 'product_ids', true );
|
||||
$product_ids = $product_ids ? array_map( 'absint', explode( ',', $product_ids ) ) : array();
|
||||
if ( sizeof( $product_ids ) > 0 )
|
||||
echo esc_html( implode( ', ', $product_ids ) );
|
||||
else
|
||||
if ( sizeof( $product_ids ) > 0 )
|
||||
echo esc_html( implode( ', ', $product_ids ) );
|
||||
else
|
||||
echo '–';
|
||||
break;
|
||||
case "usage_limit" :
|
||||
$usage_limit = get_post_meta( $post->ID, 'usage_limit', true );
|
||||
|
||||
if ( $usage_limit )
|
||||
echo esc_html( $usage_limit );
|
||||
else
|
||||
|
||||
if ( $usage_limit )
|
||||
echo esc_html( $usage_limit );
|
||||
else
|
||||
echo '–';
|
||||
break;
|
||||
case "usage" :
|
||||
$usage_count = absint( get_post_meta( $post->ID, 'usage_count', true ) );
|
||||
$usage_limit = esc_html( get_post_meta($post->ID, 'usage_limit', true) );
|
||||
|
||||
if ( $usage_limit )
|
||||
|
||||
if ( $usage_limit )
|
||||
printf( __( '%s / %s', 'woocommerce' ), $usage_count, $usage_limit );
|
||||
else
|
||||
printf( __( '%s / ∞', 'woocommerce' ), $usage_count );
|
||||
break;
|
||||
case "expiry_date" :
|
||||
$expiry_date = get_post_meta($post->ID, 'expiry_date', true);
|
||||
|
||||
if ( $expiry_date )
|
||||
echo esc_html( date_i18n( 'F j, Y', strtotime( $expiry_date ) ) );
|
||||
else
|
||||
|
||||
if ( $expiry_date )
|
||||
echo esc_html( date_i18n( 'F j, Y', strtotime( $expiry_date ) ) );
|
||||
else
|
||||
echo '–';
|
||||
break;
|
||||
case "description" :
|
||||
|
@ -92,4 +129,63 @@ function woocommerce_custom_coupon_columns( $column ) {
|
|||
}
|
||||
}
|
||||
|
||||
add_action( 'manage_shop_coupon_posts_custom_column', 'woocommerce_custom_coupon_columns', 2 );
|
||||
add_action( 'manage_shop_coupon_posts_custom_column', 'woocommerce_custom_coupon_columns', 2 );
|
||||
|
||||
/**
|
||||
* Show custom filters to filter coupons by type.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function woocommerce_restrict_manage_coupons() {
|
||||
global $woocommerce, $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'shop_coupon' )
|
||||
return;
|
||||
|
||||
// Type
|
||||
?>
|
||||
<select name='coupon_type' id='dropdown_shop_coupon_type'>
|
||||
<option value=""><?php _e( 'Show all statuses', 'woocommerce' ); ?></option>
|
||||
<?php
|
||||
$types = $woocommerce->get_coupon_discount_types();
|
||||
|
||||
foreach ( $types as $name => $type ) {
|
||||
echo '<option value="' . esc_attr( $name ) . '"';
|
||||
|
||||
if ( isset( $_GET['coupon_type'] ) )
|
||||
selected( $name, $_GET['coupon_type'] );
|
||||
|
||||
echo '>' . esc_html__( $type, 'woocommerce' ) . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
|
||||
$woocommerce->add_inline_js( "
|
||||
jQuery('select#dropdown_shop_coupon_type, select[name=m]').css('width', '150px').chosen();
|
||||
" );
|
||||
}
|
||||
|
||||
add_action( 'restrict_manage_posts', 'woocommerce_restrict_manage_coupons' );
|
||||
|
||||
/**
|
||||
* Filter the coupons by the type.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $vars
|
||||
* @return array
|
||||
*/
|
||||
function woocommerce_coupons_by_type_query( $vars ) {
|
||||
global $typenow, $wp_query;
|
||||
if ( $typenow == 'shop_coupon' && ! empty( $_GET['coupon_type'] ) ) {
|
||||
|
||||
$vars['meta_key'] = 'discount_type';
|
||||
$vars['meta_value'] = woocommerce_clean( $_GET['coupon_type'] );
|
||||
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
add_filter( 'request', 'woocommerce_coupons_by_type_query' );
|
|
@ -76,16 +76,16 @@ function woocommerce_custom_order_columns( $column ) {
|
|||
break;
|
||||
case "order_title" :
|
||||
|
||||
if ( $order->user_id )
|
||||
if ( $order->user_id )
|
||||
$user_info = get_userdata( $order->user_id );
|
||||
|
||||
if ( ! empty( $user_info ) ) {
|
||||
|
||||
$user = '<a href="user-edit.php?user_id=' . absint( $user_info->ID ) . '">';
|
||||
|
||||
if ( $user_info->first_name || $user_info->last_name )
|
||||
if ( $user_info->first_name || $user_info->last_name )
|
||||
$user .= esc_html( $user_info->first_name . ' ' . $user_info->last_name );
|
||||
else
|
||||
else
|
||||
$user .= esc_html( $user_info->display_name );
|
||||
|
||||
$user .= '</a>';
|
||||
|
@ -98,7 +98,7 @@ function woocommerce_custom_order_columns( $column ) {
|
|||
|
||||
if ( $order->billing_email )
|
||||
echo '<small class="meta">' . __( 'Email:', 'woocommerce' ) . ' ' . '<a href="' . esc_url( 'mailto:' . $order->billing_email ) . '">' . esc_html( $order->billing_email ) . '</a></small>';
|
||||
|
||||
|
||||
if ( $order->billing_phone )
|
||||
echo '<small class="meta">' . __( 'Tel:', 'woocommerce' ) . ' ' . esc_html( $order->billing_phone ) . '</small>';
|
||||
|
||||
|
@ -394,7 +394,7 @@ add_filter( "manage_edit-shop_order_sortable_columns", 'woocommerce_custom_shop_
|
|||
*/
|
||||
function woocommerce_custom_shop_order_orderby( $vars ) {
|
||||
global $typenow, $wp_query;
|
||||
if ( $typenow != 'shop_order' )
|
||||
if ( $typenow != 'shop_order' )
|
||||
return $vars;
|
||||
|
||||
// Sorting
|
||||
|
@ -443,9 +443,9 @@ function woocommerce_shop_order_search_custom_fields( $wp ) {
|
|||
) ) );
|
||||
|
||||
// Query matching custom fields - this seems faster than meta_query
|
||||
$post_ids = $wpdb->get_col(
|
||||
$wpdb->prepare(
|
||||
"SELECT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN ('" . implode( "','", $search_fields ) . "') AND meta_value LIKE '%%%s%%'", esc_attr( $_GET['s'] )
|
||||
$post_ids = $wpdb->get_col(
|
||||
$wpdb->prepare(
|
||||
"SELECT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN ('" . implode( "','", $search_fields ) . "') AND meta_value LIKE '%%%s%%'", esc_attr( $_GET['s'] )
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -473,7 +473,7 @@ function woocommerce_shop_order_search_custom_fields( $wp ) {
|
|||
|
||||
// Add ID
|
||||
$search_order_id = str_replace( 'Order #', '', $_GET['s'] );
|
||||
if ( is_numeric( $search_order_id ) )
|
||||
if ( is_numeric( $search_order_id ) )
|
||||
$post_ids[] = $search_order_id;
|
||||
|
||||
// Add blank ID so not all results are returned if the search finds nothing
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<div class="wc-metabox closed">
|
||||
|
@ -16,11 +16,11 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
<label><?php _e( 'Downloads Remaining', 'woocommerce' ); ?>:</label>
|
||||
<input type="hidden" name="product_id[<?php echo $loop; ?>]" value="<?php echo absint( $download->product_id ); ?>" />
|
||||
<input type="hidden" name="download_id[<?php echo $loop; ?>]" value="<?php echo esc_attr( $download->download_id ); ?>" />
|
||||
<input type="text" class="short" name="downloads_remaining[<?php echo $loop; ?>]" value="<?php echo esc_attr( $download->downloads_remaining ); ?>" placeholder="<?php _e( 'Unlimited', 'woocommerce' ); ?>" />
|
||||
<input type="number" step="1" min="0" class="short" name="downloads_remaining[<?php echo $loop; ?>]" value="<?php echo esc_attr( $download->downloads_remaining ); ?>" placeholder="<?php _e( 'Unlimited', 'woocommerce' ); ?>" />
|
||||
</td>
|
||||
<td>
|
||||
<label><?php _e( 'Access Expires', 'woocommerce' ); ?>:</label>
|
||||
<input type="text" class="short date-picker" name="access_expires[<?php echo $loop; ?>]" value="<?php echo $download->access_expires > 0 ? date_i18n( 'Y-m-d', strtotime( $download->access_expires ) ) : ''; ?>" maxlength="10" placeholder="<?php _e( 'Never', 'woocommerce' ); ?>" />
|
||||
<input type="text" class="short date-picker" name="access_expires[<?php echo $loop; ?>]" value="<?php echo $download->access_expires > 0 ? date_i18n( 'Y-m-d', strtotime( $download->access_expires ) ) : ''; ?>" maxlength="10" placeholder="<?php _e( 'Never', 'woocommerce' ); ?>" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<tr class="fee" data-order_item_id="<?php echo $item_id; ?>">
|
||||
<tr class="fee <?php if ( ! empty( $class ) ) echo $class; ?>" data-order_item_id="<?php echo $item_id; ?>">
|
||||
<td class="check-column"><input type="checkbox" /></td>
|
||||
|
||||
|
||||
<td class="thumb"></td>
|
||||
|
||||
|
||||
<td class="name">
|
||||
<input type="text" placeholder="<?php _e( 'Fee Name', 'woocommerce' ); ?>" name="order_item_name[<?php echo absint( $item_id ); ?>]" value="<?php if ( isset( $item['name'] ) ) echo esc_attr( $item['name'] ); ?>" />
|
||||
<input type="hidden" class="order_item_id" name="order_item_id[]" value="<?php echo esc_attr( $item_id ); ?>" />
|
||||
</td>
|
||||
|
||||
|
||||
<td class="tax_class" width="1%">
|
||||
<select class="tax_class" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" title="<?php _e( 'Tax class', 'woocommerce' ); ?>">
|
||||
<?php $tax_class = isset( $item['tax_class'] ) ? sanitize_title( $item['tax_class'] ) : ''; ?>
|
||||
|
@ -18,15 +18,15 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
<optgroup label="<?php _e( 'Taxable', 'woocommerce' ); ?>">
|
||||
<?php
|
||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('woocommerce_tax_classes' ) ) ) );
|
||||
|
||||
|
||||
$classes_options = array();
|
||||
$classes_options[''] = __( 'Standard', 'woocommerce' );
|
||||
|
||||
if ( $tax_classes )
|
||||
|
||||
if ( $tax_classes )
|
||||
foreach ( $tax_classes as $class )
|
||||
$classes_options[ sanitize_title( $class ) ] = $class;
|
||||
|
||||
foreach ( $classes_options as $value => $name )
|
||||
|
||||
foreach ( $classes_options as $value => $name )
|
||||
echo '<option value="' . esc_attr( $value ) . '" ' . selected( $value, $tax_class, false ) . '>'. esc_html( $name ) . '</option>';
|
||||
?>
|
||||
</optgroup>
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
<?php
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<tr class="item <?php if ( ! empty( $class ) ) echo $class; ?>" data-order_item_id="<?php echo $item_id; ?>">
|
||||
<td class="check-column"><input type="checkbox" /></td>
|
||||
<td class="thumb">
|
||||
<a href="<?php echo esc_url( admin_url( 'post.php?post=' . absint( $_product->id ) . '&action=edit' ) ); ?>" class="tips" data-tip="<?php
|
||||
|
||||
|
||||
echo '<strong>' . __( 'Product ID:', 'woocommerce' ) . '</strong> ' . absint( $item['product_id'] );
|
||||
|
||||
if ( $item['variation_id'] )
|
||||
echo '<br/><strong>' . __( 'Variation ID:', 'woocommerce' ) . '</strong> ' . absint( $item['variation_id'] );
|
||||
|
||||
if ( $_product->get_sku() )
|
||||
|
||||
if ( $item['variation_id'] )
|
||||
echo '<br/><strong>' . __( 'Variation ID:', 'woocommerce' ) . '</strong> ' . absint( $item['variation_id'] );
|
||||
|
||||
if ( $_product->get_sku() )
|
||||
echo '<br/><strong>' . __( 'Product SKU:', 'woocommerce' ).'</strong> ' . esc_html( $_product->get_sku() );
|
||||
|
||||
?>"><?php echo $_product->get_image(); ?></a>
|
||||
|
||||
?>"><?php echo $_product->get_image( 'shop_thumbnail', array( 'title' => '' ) ); ?></a>
|
||||
</td>
|
||||
<td class="name">
|
||||
|
||||
<?php if ( $_product->get_sku() ) echo esc_html( $_product->get_sku() ) . ' – '; ?>
|
||||
|
||||
|
||||
<a target="_blank" href="<?php echo esc_url( admin_url( 'post.php?post='. absint( $_product->id ) .'&action=edit' ) ); ?>"><?php echo esc_html( $item['name'] ); ?></a>
|
||||
<input type="hidden" class="order_item_id" name="order_item_id[]" value="<?php echo esc_attr( $item_id ); ?>" />
|
||||
|
||||
|
||||
<?php
|
||||
if ( isset( $_product->variation_data ) )
|
||||
if ( isset( $_product->variation_data ) )
|
||||
echo '<br/>' . woocommerce_get_formatted_variation( $_product->variation_data, true );
|
||||
?>
|
||||
<table class="meta" cellspacing="0">
|
||||
|
@ -37,9 +37,9 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
<?php
|
||||
if ( $metadata = $order->has_meta( $item_id )) {
|
||||
foreach ( $metadata as $meta ) {
|
||||
|
||||
|
||||
// Skip hidden core fields
|
||||
if ( in_array( $meta['meta_key'], apply_filters( 'woocommerce_hidden_order_itemmeta', array(
|
||||
if ( in_array( $meta['meta_key'], apply_filters( 'woocommerce_hidden_order_itemmeta', array(
|
||||
'_qty',
|
||||
'_tax_class',
|
||||
'_product_id',
|
||||
|
@ -47,9 +47,10 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
'_line_subtotal',
|
||||
'_line_subtotal_tax',
|
||||
'_line_total',
|
||||
'_line_tax'
|
||||
'_line_tax',
|
||||
'_refunded'
|
||||
) ) ) ) continue;
|
||||
|
||||
|
||||
// Handle serialised fields
|
||||
if ( is_serialized( $meta['meta_value'] ) ) {
|
||||
if ( is_serialized_string( $meta['meta_value'] ) ) {
|
||||
|
@ -62,8 +63,8 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
|
||||
$meta['meta_key'] = esc_attr( $meta['meta_key'] );
|
||||
$meta['meta_value'] = esc_textarea( $meta['meta_value'] ); // using a <textarea />
|
||||
$meta['meta_id'] = (int) $meta['meta_id'];
|
||||
|
||||
$meta['meta_id'] = (int) $meta['meta_id'];
|
||||
|
||||
echo '<tr data-meta_id="' . $meta['meta_id'] . '">
|
||||
<td><input type="text" name="meta_key[' . $meta['meta_id'] . ']" value="' . $meta['meta_key'] . '" /></td>
|
||||
<td><input type="text" name="meta_value[' . $meta['meta_id'] . ']" value="' . $meta['meta_value'] . '" /></td>
|
||||
|
@ -82,36 +83,36 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
<select class="tax_class" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" title="<?php _e( 'Tax class', 'woocommerce' ); ?>">
|
||||
<?php
|
||||
$item_value = isset( $item['tax_class'] ) ? sanitize_title( $item['tax_class'] ) : '';
|
||||
|
||||
|
||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('woocommerce_tax_classes' ) ) ) );
|
||||
|
||||
|
||||
$classes_options = array();
|
||||
$classes_options[''] = __( 'Standard', 'woocommerce' );
|
||||
|
||||
if ( $tax_classes )
|
||||
|
||||
if ( $tax_classes )
|
||||
foreach ( $tax_classes as $class )
|
||||
$classes_options[ sanitize_title( $class ) ] = $class;
|
||||
|
||||
foreach ( $classes_options as $value => $name )
|
||||
|
||||
foreach ( $classes_options as $value => $name )
|
||||
echo '<option value="' . esc_attr( $value ) . '" ' . selected( $value, $item_value, false ) . '>'. esc_html( $name ) . '</option>';
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
|
||||
<td class="quantity" width="1%">
|
||||
<input type="number" step="any" min="0" autocomplete="off" name="order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" value="<?php echo esc_attr( $item['qty'] ); ?>" size="4" class="quantity" />
|
||||
<input type="number" step="<?php echo apply_filters( 'woocommerce_quantity_input_step', '1', $_product ); ?>" min="0" autocomplete="off" name="order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" value="<?php echo esc_attr( $item['qty'] ); ?>" size="4" class="quantity" />
|
||||
</td>
|
||||
|
||||
<td class="line_cost" width="1%">
|
||||
<label><?php _e( 'Total', 'woocommerce' ); ?>: <input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_total'] ) ) echo esc_attr( $item['line_total'] ); ?>" class="line_total" /></label>
|
||||
|
||||
<span class="subtotal"><label><?php _e( 'Subtotal', 'woocommerce' ); ?>: <input type="text" name="line_subtotal[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_subtotal'] ) ) echo esc_attr( $item['line_subtotal'] ); ?>" class="line_subtotal" /></label></span>
|
||||
<label><?php _e( 'Total', 'woocommerce' ); ?>: <input type="number" step="any" min="0" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_total'] ) ) echo esc_attr( $item['line_total'] ); ?>" class="line_total" /></label>
|
||||
|
||||
<span class="subtotal"><label><?php _e( 'Subtotal', 'woocommerce' ); ?>: <input type="number" step="any" min="0" name="line_subtotal[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_subtotal'] ) ) echo esc_attr( $item['line_subtotal'] ); ?>" class="line_subtotal" /></label></span>
|
||||
</td>
|
||||
|
||||
<td class="line_tax" width="1%">
|
||||
<input type="text" name="line_tax[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_tax'] ) ) echo esc_attr( $item['line_tax'] ); ?>" class="line_tax" />
|
||||
|
||||
<span class="subtotal"><input type="text" name="line_subtotal_tax[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_subtotal_tax'] ) ) echo esc_attr( $item['line_subtotal_tax'] ); ?>" class="line_subtotal_tax" /></span>
|
||||
<input type="number" step="any" min="0" name="line_tax[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_tax'] ) ) echo esc_attr( $item['line_tax'] ); ?>" class="line_tax" />
|
||||
|
||||
<span class="subtotal"><input type="number" step="any" min="0" name="line_subtotal_tax[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_subtotal_tax'] ) ) echo esc_attr( $item['line_subtotal_tax'] ); ?>" class="line_subtotal_tax" /></span>
|
||||
</td>
|
||||
|
||||
</tr>
|
|
@ -1,23 +1,24 @@
|
|||
<?php
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<div class="tax_row" data-order_item_id="<?php echo $item_id; ?>">
|
||||
<p class="first">
|
||||
<label><?php _e( 'Tax Label:', 'woocommerce' ) ?></label>
|
||||
<input type="text" name="order_taxes_label[<?php echo $item_id; ?>]" placeholder="<?php echo $woocommerce->countries->tax_or_vat(); ?>" value="<?php if ( isset( $item['name'] ) ) echo esc_attr( $item['name'] ); ?>" />
|
||||
<p class="wide">
|
||||
<label><?php _e( 'Tax Rate:', 'woocommerce' ) ?></label>
|
||||
<select name="order_taxes_rate_id[<?php echo $item_id; ?>]">
|
||||
<option value=""><?php _e( 'N/A', 'woocommerce' ); ?></option>
|
||||
<?php foreach( $tax_codes as $tax_id => $tax_code ) : ?>
|
||||
<option value="<?php echo $tax_id; ?>" <?php selected( $tax_id, isset( $item['rate_id'] ) ? $item['rate_id'] : '' ); ?>><?php echo esc_html( $tax_code ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<input type="hidden" name="order_taxes_id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item_id ); ?>" />
|
||||
</p>
|
||||
<p class="last">
|
||||
<label><?php _e( 'Compound:', 'woocommerce' ) ?>
|
||||
<input type="checkbox" name="order_taxes_compound[<?php echo $item_id; ?>]" <?php if ( isset( $item['compound'] ) ) checked( $item['compound'], 1 ); ?> /></label>
|
||||
</p>
|
||||
<p class="first">
|
||||
<label><?php _e( 'Sales Tax:', 'woocommerce' ) ?></label>
|
||||
<input type="text" name="order_taxes_amount[<?php echo $item_id; ?>]" placeholder="0.00" value="<?php if ( isset( $item['tax_amount'] ) ) echo esc_attr( $item['tax_amount'] ); ?>" />
|
||||
<input type="number" step="any" min="0" name="order_taxes_amount[<?php echo $item_id; ?>]" placeholder="0.00" value="<?php if ( isset( $item['tax_amount'] ) ) echo esc_attr( $item['tax_amount'] ); ?>" />
|
||||
</p>
|
||||
<p class="last">
|
||||
<label><?php _e( 'Shipping Tax:', 'woocommerce' ) ?></label>
|
||||
<input type="text" name="order_taxes_shipping_amount[<?php echo $item_id; ?>]" placeholder="0.00" value="<?php if ( isset( $item['shipping_tax_amount'] ) ) echo esc_attr( $item['shipping_tax_amount'] ); ?>" />
|
||||
<input type="number" step="any" min="0" name="order_taxes_shipping_amount[<?php echo $item_id; ?>]" placeholder="0.00" value="<?php if ( isset( $item['shipping_tax_amount'] ) ) echo esc_attr( $item['shipping_tax_amount'] ); ?>" />
|
||||
</p>
|
||||
<a href="#" class="delete_tax_row">×</a>
|
||||
<div class="clear"></div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<div class="woocommerce_variation wc-metabox closed">
|
||||
|
@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
foreach ( $parent_data['attributes'] as $attribute ) {
|
||||
|
||||
// Only deal with attributes that are variations
|
||||
if ( ! $attribute['is_variation'] )
|
||||
if ( ! $attribute['is_variation'] )
|
||||
continue;
|
||||
|
||||
// Get current value for variation (if set)
|
||||
|
@ -55,40 +55,40 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
<tr>
|
||||
<td>
|
||||
<label><?php _e( 'Stock Qty:', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Enter a quantity to enable stock management for this variation, or leave blank to use the variable product stock options.', 'woocommerce' ); ?>" href="#">[?]</a></label>
|
||||
<input type="text" size="5" name="variable_stock[<?php echo $loop; ?>]" value="<?php if ( isset( $_stock ) ) echo esc_attr( $_stock ); ?>" />
|
||||
<input type="number" size="5" name="variable_stock[<?php echo $loop; ?>]" value="<?php if ( isset( $_stock ) ) echo esc_attr( $_stock ); ?>" step="any" />
|
||||
</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<label><?php _e( 'Price:', 'woocommerce' ); ?></label>
|
||||
<input type="text" size="5" name="variable_regular_price[<?php echo $loop; ?>]" value="<?php if ( isset( $_regular_price ) ) echo esc_attr( $_regular_price ); ?>" />
|
||||
<input type="number" size="5" name="variable_regular_price[<?php echo $loop; ?>]" value="<?php if ( isset( $_regular_price ) ) echo esc_attr( $_regular_price ); ?>" step="any" min="0" />
|
||||
</td>
|
||||
<td>
|
||||
<label><?php _e( 'Sale Price:', 'woocommerce' ); ?> <a href="#" class="sale_schedule"><?php _e( 'Schedule', 'woocommerce' ); ?></a><a href="#" class="cancel_sale_schedule" style="display:none"><?php _e( 'Cancel schedule', 'woocommerce' ); ?></a></label>
|
||||
<input type="text" size="5" name="variable_sale_price[<?php echo $loop; ?>]" value="<?php if ( isset( $_sale_price ) ) echo esc_attr( $_sale_price ); ?>" />
|
||||
<input type="number" size="5" name="variable_sale_price[<?php echo $loop; ?>]" value="<?php if ( isset( $_sale_price ) ) echo esc_attr( $_sale_price ); ?>" step="any" min="0" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr class="sale_price_dates_fields" style="display:none">
|
||||
<td>
|
||||
<label><?php _e( 'Sale start date:', 'woocommerce' ) ?></label>
|
||||
<input type="text" class="sale_price_dates_from" name="variable_sale_price_dates_from[<?php echo $loop; ?>]" value="<?php echo ! empty( $_sale_price_dates_from ) ? date_i18n( 'Y-m-d', $_sale_price_dates_from ) : ''; ?>" placeholder="<?php echo _x( 'From…', 'placeholder', 'woocommerce' ) ?>" maxlength="10" />
|
||||
<input type="text" class="sale_price_dates_from" name="variable_sale_price_dates_from[<?php echo $loop; ?>]" value="<?php echo ! empty( $_sale_price_dates_from ) ? date_i18n( 'Y-m-d', $_sale_price_dates_from ) : ''; ?>" placeholder="<?php echo _x( 'From…', 'placeholder', 'woocommerce' ) ?> YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
|
||||
</td>
|
||||
<td>
|
||||
<label><?php _e( 'Sale end date:', 'woocommerce' ) ?></label>
|
||||
<input type="text" name="variable_sale_price_dates_to[<?php echo $loop; ?>]" value="<?php echo ! empty( $_sale_price_dates_to ) ? date_i18n( 'Y-m-d', $_sale_price_dates_to ) : ''; ?>" placeholder="<?php echo _x('To…', 'placeholder', 'woocommerce') ?>" maxlength="10" />
|
||||
<input type="text" name="variable_sale_price_dates_to[<?php echo $loop; ?>]" value="<?php echo ! empty( $_sale_price_dates_to ) ? date_i18n( 'Y-m-d', $_sale_price_dates_to ) : ''; ?>" placeholder="<?php echo _x('To…', 'placeholder', 'woocommerce') ?> YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<?php if ( get_option( 'woocommerce_enable_weight', true ) !== 'no' || get_option( 'woocommerce_enable_dimensions', true ) !== 'no' ) : ?>
|
||||
<tr>
|
||||
<?php if ( get_option( 'woocommerce_enable_weight', true ) !== 'no' ) : ?>
|
||||
<td class="hide_if_variation_virtual">
|
||||
<label><?php _e( 'Weight', 'woocommerce' ) . ' (' . esc_html( get_option( 'woocommerce_weight_unit' ) ) . '):'; ?> <a class="tips" data-tip="<?php _e( 'Enter a weight for this variation or leave blank to use the parent product weight.', 'woocommerce' ); ?>" href="#">[?]</a></label>
|
||||
<input type="text" size="5" name="variable_weight[<?php echo $loop; ?>]" value="<?php if ( isset( $_weight ) ) echo esc_attr( $_weight ); ?>" placeholder="<?php echo esc_attr( $parent_data['weight'] ); ?>" />
|
||||
<input type="number" size="5" name="variable_weight[<?php echo $loop; ?>]" value="<?php if ( isset( $_weight ) ) echo esc_attr( $_weight ); ?>" placeholder="<?php echo esc_attr( $parent_data['weight'] ); ?>" step="any" min="0" />
|
||||
</td>
|
||||
<?php else : ?>
|
||||
<td> </td>
|
||||
|
@ -96,9 +96,9 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
<?php if ( get_option( 'woocommerce_enable_dimensions', true ) !== 'no' ) : ?>
|
||||
<td class="dimensions_field hide_if_variation_virtual">
|
||||
<label for"product_length"><?php echo __( 'Dimensions (L×W×H)', 'woocommerce' ); ?></label>
|
||||
<input id="product_length" class="input-text" size="6" type="text" name="variable_length[<?php echo $loop; ?>]" value="<?php if ( isset( $_length ) ) echo esc_attr( $_length ); ?>" placeholder="<?php echo esc_attr( $parent_data['length'] ); ?>" />
|
||||
<input class="input-text" size="6" type="text" name="variable_width[<?php echo $loop; ?>]" value="<?php if ( isset( $_width ) ) echo esc_attr( $_width ); ?>" placeholder="<?php echo esc_attr( $parent_data['width'] ); ?>" />
|
||||
<input class="input-text last" size="6" type="text" name="variable_height[<?php echo $loop; ?>]" value="<?php if ( isset( $_height ) ) echo esc_attr( $_height ); ?>" placeholder="<?php echo esc_attr( $parent_data['height'] ); ?>" />
|
||||
<input id="product_length" class="input-text" size="6" type="number" step="any" min="0" name="variable_length[<?php echo $loop; ?>]" value="<?php if ( isset( $_length ) ) echo esc_attr( $_length ); ?>" placeholder="<?php echo esc_attr( $parent_data['length'] ); ?>" />
|
||||
<input class="input-text" size="6" type="number" step="any" min="0" name="variable_width[<?php echo $loop; ?>]" value="<?php if ( isset( $_width ) ) echo esc_attr( $_width ); ?>" placeholder="<?php echo esc_attr( $parent_data['width'] ); ?>" />
|
||||
<input class="input-text last" size="6" type="number" step="any" min="0" name="variable_height[<?php echo $loop; ?>]" value="<?php if ( isset( $_height ) ) echo esc_attr( $_height ); ?>" placeholder="<?php echo esc_attr( $parent_data['height'] ); ?>" />
|
||||
</td>
|
||||
<?php else : ?>
|
||||
<td> </td>
|
||||
|
@ -116,11 +116,11 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
'selected' => isset( $shipping_class ) ? esc_attr( $shipping_class ) : '',
|
||||
'echo' => 0
|
||||
);
|
||||
|
||||
|
||||
echo wp_dropdown_categories( $args );
|
||||
?></td>
|
||||
<td>
|
||||
<label><?php _e( 'Tax class:', 'woocommerce' ); ?></label>
|
||||
<label><?php _e( 'Tax class:', 'woocommerce' ); ?></label>
|
||||
<select name="variable_tax_class[<?php echo $loop; ?>]"><?php
|
||||
foreach ( $parent_data['tax_class_options'] as $key => $value )
|
||||
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $key, $_tax_class, false ) . '>' . esc_html( $value ) . '</option>';
|
||||
|
@ -131,14 +131,14 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
<td rowspan="2">
|
||||
<div class="file_path_field">
|
||||
<label><?php _e( 'File paths:', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Enter one or more File Paths, one per line, to make this variation a downloadable product, or leave blank.', 'woocommerce' ); ?>" href="#">[?]</a></label>
|
||||
<textarea style="float:left;" class="short file_paths" cols="20" rows="2" placeholder="<?php _e( 'File paths/URLs, one per line', 'woocommerce' ); ?>" name="variable_file_paths[<?php echo $loop; ?>]" wrap="off"><?php if ( isset( $_file_paths ) ) echo esc_textarea( $_file_paths ); ?></textarea>
|
||||
<textarea style="float:left;" class="short file_paths" cols="20" rows="2" placeholder="<?php _e( 'File paths/URLs, one per line', 'woocommerce' ); ?>" name="variable_file_paths[<?php echo $loop; ?>]" wrap="off"><?php if ( isset( $_file_paths ) ) echo esc_textarea( $_file_paths ); ?></textarea>
|
||||
<input type="button" class="upload_file_button button" value="<?php _e( 'Upload a file', 'woocommerce' ); ?>" title="<?php _e( 'Upload', 'woocommerce' ); ?>" />
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<label><?php _e( 'Download Limit:', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Leave blank for unlimited re-downloads.', 'woocommerce' ); ?>" href="#">[?]</a></label>
|
||||
<input type="text" size="5" name="variable_download_limit[<?php echo $loop; ?>]" value="<?php if ( isset( $_download_limit ) ) echo esc_attr( $_download_limit ); ?>" placeholder="<?php _e( 'Unlimited', 'woocommerce' ); ?>" />
|
||||
<input type="number" size="5" name="variable_download_limit[<?php echo $loop; ?>]" value="<?php if ( isset( $_download_limit ) ) echo esc_attr( $_download_limit ); ?>" placeholder="<?php _e( 'Unlimited', 'woocommerce' ); ?>" step="1" min="0" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -146,7 +146,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
<td>
|
||||
<div>
|
||||
<label><?php _e( 'Download Expiry:', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Enter the number of days before a download link expires, or leave blank.', 'woocommerce' ); ?>" href="#">[?]</a></label>
|
||||
<input type="text" size="5" name="variable_download_expiry[<?php echo $loop; ?>]" value="<?php if ( isset( $_download_expiry ) ) echo esc_attr( $_download_expiry ); ?>" placeholder="<?php _e( 'Unlimited', 'woocommerce' ); ?>" />
|
||||
<input type="number" size="5" name="variable_download_expiry[<?php echo $loop; ?>]" value="<?php if ( isset( $_download_expiry ) ) echo esc_attr( $_download_expiry ); ?>" placeholder="<?php _e( 'Unlimited', 'woocommerce' ); ?>" step="1" min="0" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -35,15 +35,18 @@ function woocommerce_coupon_data_meta_box( $post ) {
|
|||
|
||||
// Description
|
||||
woocommerce_wp_text_input( array( 'id' => 'coupon_description', 'label' => __( 'Coupon description', 'woocommerce' ), 'description' => __( 'Optionally enter a description for this coupon for your reference.', 'woocommerce' ), 'value' => $post->post_excerpt, 'name' => 'excerpt' ) );
|
||||
|
||||
|
||||
echo '</div><div class="options_group">';
|
||||
|
||||
|
||||
// Type
|
||||
woocommerce_wp_select( array( 'id' => 'discount_type', 'label' => __( 'Discount type', 'woocommerce' ), 'options' => $woocommerce->get_coupon_discount_types() ) );
|
||||
|
||||
// Amount
|
||||
woocommerce_wp_text_input( array( 'id' => 'coupon_amount', 'label' => __( 'Coupon amount', 'woocommerce' ), 'placeholder' => '0.00', 'description' => __( 'Enter an amount e.g. 2.99', 'woocommerce' ) ) );
|
||||
|
||||
woocommerce_wp_text_input( array( 'id' => 'coupon_amount', 'label' => __( 'Coupon amount', 'woocommerce' ), 'placeholder' => '0.00', 'description' => __( 'Enter an amount e.g. 2.99', 'woocommerce' ), 'type' => 'number', 'custom_attributes' => array(
|
||||
'step' => 'any',
|
||||
'min' => '0'
|
||||
) ) );
|
||||
|
||||
// Free Shipping
|
||||
woocommerce_wp_checkbox( array( 'id' => 'free_shipping', 'label' => __( 'Enable free shipping', 'woocommerce' ), 'description' => sprintf(__( 'Check this box if the coupon grants free shipping. The <a href="%s">free shipping method</a> must be enabled with the "must use coupon" setting checked.', 'woocommerce' ), admin_url('admin.php?page=woocommerce_settings&tab=shipping§ion=WC_Free_Shipping')) ) );
|
||||
|
||||
|
@ -52,11 +55,14 @@ function woocommerce_coupon_data_meta_box( $post ) {
|
|||
|
||||
// Apply before tax
|
||||
woocommerce_wp_checkbox( array( 'id' => 'apply_before_tax', 'label' => __( 'Apply before tax', 'woocommerce' ), 'description' => __( 'Check this box if the coupon should be applied before calculating cart tax.', 'woocommerce' ) ) );
|
||||
|
||||
|
||||
echo '</div><div class="options_group">';
|
||||
|
||||
// minimum spend
|
||||
woocommerce_wp_text_input( array( 'id' => 'minimum_amount', 'label' => __( 'Minimum amount', 'woocommerce' ), 'placeholder' => __( 'No minimum', 'woocommerce' ), 'description' => __( 'This field allows you to set the minimum subtotal needed to use the coupon.', 'woocommerce' ) ) );
|
||||
woocommerce_wp_text_input( array( 'id' => 'minimum_amount', 'label' => __( 'Minimum amount', 'woocommerce' ), 'placeholder' => __( 'No minimum', 'woocommerce' ), 'description' => __( 'This field allows you to set the minimum subtotal needed to use the coupon.', 'woocommerce' ), 'type' => 'number', 'custom_attributes' => array(
|
||||
'step' => 'any',
|
||||
'min' => '0'
|
||||
) ) );
|
||||
|
||||
echo '</div><div class="options_group">';
|
||||
|
||||
|
@ -72,17 +78,17 @@ function woocommerce_coupon_data_meta_box( $post ) {
|
|||
$title = get_the_title( $product_id );
|
||||
$sku = get_post_meta( $product_id, '_sku', true );
|
||||
|
||||
if ( ! $title )
|
||||
if ( ! $title )
|
||||
continue;
|
||||
|
||||
if ( ! empty( $sku ) )
|
||||
if ( ! empty( $sku ) )
|
||||
$sku = ' (SKU: ' . $sku . ')';
|
||||
|
||||
echo '<option value="' . esc_attr( $product_id ) . '" selected="selected">' . esc_html( $title . $sku ) . '</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select> <img class="help_tip" data-tip='<?php _e( 'Products which need to be in the cart to use this coupon or, for "Product Discounts", which products are discounted.', 'woocommerce' ) ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" /></p>
|
||||
</select> <img class="help_tip" data-tip='<?php _e( 'Products which need to be in the cart to use this coupon or, for "Product Discounts", which products are discounted.', 'woocommerce' ) ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" height="16" width="16" /></p>
|
||||
<?php
|
||||
|
||||
// Exclude Product ids
|
||||
|
@ -97,17 +103,17 @@ function woocommerce_coupon_data_meta_box( $post ) {
|
|||
$title = get_the_title( $product_id );
|
||||
$sku = get_post_meta( $product_id, '_sku', true );
|
||||
|
||||
if ( ! $title )
|
||||
if ( ! $title )
|
||||
continue;
|
||||
|
||||
if ( ! empty( $sku ) )
|
||||
if ( ! empty( $sku ) )
|
||||
$sku = ' (SKU: ' . $sku . ')';
|
||||
|
||||
echo '<option value="' . esc_attr( $product_id ) . '" selected="selected">' . esc_html( $title . $sku ) . '</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select> <img class="help_tip" data-tip='<?php _e( 'Products which must not be in the cart to use this coupon or, for "Product Discounts", which products are not discounted.', 'woocommerce' ) ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" /></p>
|
||||
</select> <img class="help_tip" data-tip='<?php _e( 'Products which must not be in the cart to use this coupon or, for "Product Discounts", which products are not discounted.', 'woocommerce' ) ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" height="16" width="16" /></p>
|
||||
<?php
|
||||
|
||||
echo '</div><div class="options_group">';
|
||||
|
@ -123,7 +129,7 @@ function woocommerce_coupon_data_meta_box( $post ) {
|
|||
if ( $categories ) foreach ( $categories as $cat )
|
||||
echo '<option value="' . esc_attr( $cat->term_id ) . '"' . selected( in_array( $cat->term_id, $category_ids ), true, false ) . '>' . esc_html( $cat->name ) . '</option>';
|
||||
?>
|
||||
</select> <img class="help_tip" data-tip='<?php _e( 'A product must be in this category for the coupon to remain valid or, for "Product Discounts", products in these categories will be discounted.', 'woocommerce' ) ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" /></p>
|
||||
</select> <img class="help_tip" data-tip='<?php _e( 'A product must be in this category for the coupon to remain valid or, for "Product Discounts", products in these categories will be discounted.', 'woocommerce' ) ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" height="16" width="16" /></p>
|
||||
<?php
|
||||
|
||||
// Exclude Categories
|
||||
|
@ -137,21 +143,26 @@ function woocommerce_coupon_data_meta_box( $post ) {
|
|||
if ( $categories ) foreach ( $categories as $cat )
|
||||
echo '<option value="' . esc_attr( $cat->term_id ) . '"' . selected( in_array( $cat->term_id, $category_ids ), true, false ) . '>' . esc_html( $cat->name ) . '</option>';
|
||||
?>
|
||||
</select> <img class="help_tip" data-tip='<?php _e( 'Product must not be in this category for the coupon to remain valid or, for "Product Discounts", products in these categories will not be discounted.', 'woocommerce' ) ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" /></p>
|
||||
</select> <img class="help_tip" data-tip='<?php _e( 'Product must not be in this category for the coupon to remain valid or, for "Product Discounts", products in these categories will not be discounted.', 'woocommerce' ) ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" height="16" width="16" /></p>
|
||||
<?php
|
||||
|
||||
echo '</div><div class="options_group">';
|
||||
|
||||
// Customers
|
||||
woocommerce_wp_text_input( array( 'id' => 'customer_email', 'label' => __( 'Customer emails', 'woocommerce' ), 'placeholder' => __( 'Any customer', 'woocommerce' ), 'description' => __( 'Comma separate email addresses to restrict this coupon to specific billing and user emails.', 'woocommerce' ), 'value' => implode(', ', (array) get_post_meta( $post->ID, 'customer_email', true )) ) );
|
||||
woocommerce_wp_text_input( array( 'id' => 'customer_email', 'label' => __( 'Customer emails', 'woocommerce' ), 'placeholder' => __( 'Any customer', 'woocommerce' ), 'description' => __( 'Comma separate email addresses to restrict this coupon to specific billing and user emails.', 'woocommerce' ), 'value' => implode(', ', (array) get_post_meta( $post->ID, 'customer_email', true ) ), 'type' => 'email', 'custom_attributes' => array(
|
||||
'multiple' => 'multiple'
|
||||
) ) );
|
||||
|
||||
echo '</div><div class="options_group">';
|
||||
|
||||
// Usage limit
|
||||
woocommerce_wp_text_input( array( 'id' => 'usage_limit', 'label' => __( 'Usage limit', 'woocommerce' ), 'placeholder' => _x('Unlimited usage', 'placeholder', 'woocommerce'), 'description' => __( 'How many times this coupon can be used before it is void.', 'woocommerce' ) ) );
|
||||
woocommerce_wp_text_input( array( 'id' => 'usage_limit', 'label' => __( 'Usage limit', 'woocommerce' ), 'placeholder' => _x('Unlimited usage', 'placeholder', 'woocommerce'), 'description' => __( 'How many times this coupon can be used before it is void.', 'woocommerce' ), 'type' => 'number', 'custom_attributes' => array(
|
||||
'step' => '1',
|
||||
'min' => '0'
|
||||
) ) );
|
||||
|
||||
// Expiry date
|
||||
woocommerce_wp_text_input( array( 'id' => 'expiry_date', 'label' => __( 'Expiry date', 'woocommerce' ), 'placeholder' => _x('Never expire', 'placeholder', 'woocommerce'), 'description' => __( 'The date this coupon will expire, <code>YYYY-MM-DD</code>.', 'woocommerce' ), 'class' => 'short date-picker' ) );
|
||||
woocommerce_wp_text_input( array( 'id' => 'expiry_date', 'label' => __( 'Expiry date', 'woocommerce' ), 'placeholder' => _x('Never expire', 'placeholder', 'woocommerce'), 'description' => __( 'The date this coupon will expire, <code>YYYY-MM-DD</code>.', 'woocommerce' ), 'class' => 'short date-picker', 'custom_attributes' => array( 'pattern' => "[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" ) ) );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
|
@ -172,11 +183,11 @@ function woocommerce_coupon_data_meta_box( $post ) {
|
|||
*/
|
||||
function woocommerce_process_shop_coupon_meta( $post_id, $post ) {
|
||||
global $wpdb, $woocommerce_errors;
|
||||
|
||||
|
||||
// Ensure coupon code is correctly formatted
|
||||
$post->post_title = apply_filters( 'woocommerce_coupon_code', $post->post_title );
|
||||
$wpdb->update( $wpdb->posts, array( 'post_title' => $post->post_title ), array( 'ID' => $post_id ) );
|
||||
|
||||
|
||||
// Check for dupe coupons
|
||||
$coupon_found = $wpdb->get_var( $wpdb->prepare( "
|
||||
SELECT $wpdb->posts.ID
|
||||
|
@ -186,7 +197,7 @@ function woocommerce_process_shop_coupon_meta( $post_id, $post ) {
|
|||
AND $wpdb->posts.post_title = '%s'
|
||||
AND $wpdb->posts.ID != %s
|
||||
", $post->post_title, $post_id ) );
|
||||
|
||||
|
||||
if ( $coupon_found )
|
||||
$woocommerce_errors[] = __( 'Coupon code already exists - customers will use the latest coupon with this code.', 'woocommerce' );
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/WritePanels
|
||||
* @version 1.7.0
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -23,7 +23,7 @@ function woocommerce_order_data_meta_box($post) {
|
|||
global $post, $wpdb, $thepostid, $theorder, $order_status, $woocommerce;
|
||||
|
||||
$thepostid = absint( $post->ID );
|
||||
|
||||
|
||||
if ( ! is_object( $theorder ) )
|
||||
$theorder = new WC_Order( $thepostid );
|
||||
|
||||
|
@ -71,7 +71,7 @@ function woocommerce_order_data_meta_box($post) {
|
|||
</select></p>
|
||||
|
||||
<p class="form-field last"><label for="order_date"><?php _e( 'Order Date:', 'woocommerce' ) ?></label>
|
||||
<input type="text" class="date-picker-field" name="order_date" id="order_date" maxlength="10" value="<?php echo date_i18n( 'Y-m-d', strtotime( $post->post_date ) ); ?>" /> @ <input type="text" class="hour" placeholder="<?php _e( 'h', 'woocommerce' ) ?>" name="order_date_hour" id="order_date_hour" maxlength="2" size="2" value="<?php echo date_i18n( 'H', strtotime( $post->post_date ) ); ?>" />:<input type="text" class="minute" placeholder="<?php _e( 'm', 'woocommerce' ) ?>" name="order_date_minute" id="order_date_minute" maxlength="2" size="2" value="<?php echo date_i18n( 'i', strtotime( $post->post_date ) ); ?>" />
|
||||
<input type="text" class="date-picker-field" name="order_date" id="order_date" maxlength="10" value="<?php echo date_i18n( 'Y-m-d', strtotime( $post->post_date ) ); ?>" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" /> @ <input type="text" class="hour" placeholder="<?php _e( 'h', 'woocommerce' ) ?>" name="order_date_hour" id="order_date_hour" maxlength="2" size="2" value="<?php echo date_i18n( 'H', strtotime( $post->post_date ) ); ?>" pattern="\-?\d+(\.\d{0,})?" />:<input type="text" class="minute" placeholder="<?php _e( 'm', 'woocommerce' ) ?>" name="order_date_minute" id="order_date_minute" maxlength="2" size="2" value="<?php echo date_i18n( 'i', strtotime( $post->post_date ) ); ?>" pattern="\-?\d+(\.\d{0,})?" />
|
||||
</p>
|
||||
|
||||
<p class="form-field form-field-wide">
|
||||
|
@ -176,16 +176,16 @@ function woocommerce_order_data_meta_box($post) {
|
|||
// Display values
|
||||
echo '<div class="address">';
|
||||
|
||||
if ( $order->get_formatted_billing_address() )
|
||||
echo '<p><strong>' . __( 'Address', 'woocommerce' ) . ':</strong><br/> ' . $order->get_formatted_billing_address() . '</p>';
|
||||
else
|
||||
if ( $order->get_formatted_billing_address() )
|
||||
echo '<p><strong>' . __( 'Address', 'woocommerce' ) . ':</strong><br/> ' . $order->get_formatted_billing_address() . '</p>';
|
||||
else
|
||||
echo '<p class="none_set"><strong>' . __( 'Address', 'woocommerce' ) . ':</strong> ' . __( 'No billing address set.', 'woocommerce' ) . '</p>';
|
||||
|
||||
foreach ( $billing_data as $key => $field ) {
|
||||
if ( empty( $field['show'] ) )
|
||||
foreach ( $billing_data as $key => $field ) {
|
||||
if ( empty( $field['show'] ) )
|
||||
continue;
|
||||
$field_name = 'billing_' . $key;
|
||||
if ( $order->$field_name )
|
||||
if ( $order->$field_name )
|
||||
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . esc_html( $order->$field_name ) . '</p>';
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ function woocommerce_order_data_meta_box($post) {
|
|||
echo '<div class="edit_address"><p><button class="button load_customer_billing">'.__( 'Load billing address', 'woocommerce' ).'</button></p>';
|
||||
|
||||
foreach ( $billing_data as $key => $field ) {
|
||||
if ( ! isset( $field['type'] ) )
|
||||
if ( ! isset( $field['type'] ) )
|
||||
$field['type'] = 'text';
|
||||
switch ( $field['type'] ) {
|
||||
case "select" :
|
||||
|
@ -260,16 +260,16 @@ function woocommerce_order_data_meta_box($post) {
|
|||
// Display values
|
||||
echo '<div class="address">';
|
||||
|
||||
if ( $order->get_formatted_shipping_address() )
|
||||
echo '<p><strong>' . __( 'Address', 'woocommerce' ) . ':</strong><br/> ' . $order->get_formatted_shipping_address() . '</p>';
|
||||
else
|
||||
if ( $order->get_formatted_shipping_address() )
|
||||
echo '<p><strong>' . __( 'Address', 'woocommerce' ) . ':</strong><br/> ' . $order->get_formatted_shipping_address() . '</p>';
|
||||
else
|
||||
echo '<p class="none_set"><strong>' . __( 'Address', 'woocommerce' ) . ':</strong> ' . __( 'No shipping address set.', 'woocommerce' ) . '</p>';
|
||||
|
||||
if ( $shipping_data ) foreach ( $shipping_data as $key => $field ) {
|
||||
if ( empty( $field['show'] ) )
|
||||
if ( $shipping_data ) foreach ( $shipping_data as $key => $field ) {
|
||||
if ( empty( $field['show'] ) )
|
||||
continue;
|
||||
$field_name = 'shipping_' . $key;
|
||||
if ( $order->$field_name )
|
||||
if ( $order->$field_name )
|
||||
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . esc_html( $order->$field_name ) . '</p>';
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,7 @@ function woocommerce_order_data_meta_box($post) {
|
|||
echo '<div class="edit_address"><p><button class="button load_customer_shipping">' . __( 'Load shipping address', 'woocommerce' ) . '</button> <button class="button billing-same-as-shipping">'. __( 'Copy from billing', 'woocommerce' ) . '</button></p>';
|
||||
|
||||
if ( $shipping_data ) foreach ( $shipping_data as $key => $field ) {
|
||||
if ( ! isset( $field['type'] ) )
|
||||
if ( ! isset( $field['type'] ) )
|
||||
$field['type'] = 'text';
|
||||
switch ( $field['type'] ) {
|
||||
case "select" :
|
||||
|
@ -315,7 +315,7 @@ function woocommerce_order_items_meta_box( $post ) {
|
|||
$theorder = new WC_Order( $thepostid );
|
||||
|
||||
$order = $theorder;
|
||||
|
||||
|
||||
$data = get_post_custom( $post->ID );
|
||||
?>
|
||||
<div class="woocommerce_order_items_wrapper">
|
||||
|
@ -324,7 +324,7 @@ function woocommerce_order_items_meta_box( $post ) {
|
|||
<tr>
|
||||
<th><input type="checkbox" class="check-column" /></th>
|
||||
<th class="item" colspan="2"><?php _e( 'Item', 'woocommerce' ); ?></th>
|
||||
|
||||
|
||||
<?php do_action( 'woocommerce_admin_order_item_headers' ); ?>
|
||||
|
||||
<th class="tax_class"><?php _e( 'Tax Class', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Tax class for the line item', 'woocommerce' ); ?>." href="#">[?]</a></th>
|
||||
|
@ -339,29 +339,33 @@ function woocommerce_order_items_meta_box( $post ) {
|
|||
<tbody id="order_items_list">
|
||||
|
||||
<?php
|
||||
// List order items
|
||||
$order_items = $order->get_items( array( 'line_item', 'fee' ) );
|
||||
|
||||
// List order items
|
||||
$order_items = $order->get_items( apply_filters( 'woocommerce_admin_order_item_types', array( 'line_item', 'fee' ) ) );
|
||||
|
||||
foreach ( $order_items as $item_id => $item ) {
|
||||
|
||||
|
||||
$class = ( isset( $item['refunded'] ) ) ? 'refunded' : '';
|
||||
|
||||
switch ( $item['type'] ) {
|
||||
case 'line_item' :
|
||||
$_product = $order->get_product_from_item( $item );
|
||||
$item_meta = $order->get_item_meta( $item_id );
|
||||
|
||||
|
||||
include( 'order-item-html.php' );
|
||||
break;
|
||||
case 'fee' :
|
||||
case 'fee' :
|
||||
include( 'order-fee-html.php' );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
do_action( 'woocommerce_order_item_' . $item['type'] . '_html' );
|
||||
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<p class="bulk_actions">
|
||||
<select>
|
||||
<option value=""><?php _e( 'Actions', 'woocommerce' ); ?></option>
|
||||
|
@ -369,18 +373,20 @@ function woocommerce_order_items_meta_box( $post ) {
|
|||
<option value="delete"><?php _e( 'Delete Lines', 'woocommerce' ); ?></option>
|
||||
|
||||
<?php
|
||||
$gateways = $woocommerce->payment_gateways->get_available_payment_gateways();
|
||||
$gateways = $woocommerce->payment_gateways->payment_gateways();
|
||||
|
||||
if ( isset( $gateways[ $order->payment_method ] ) ) {
|
||||
$gateway = $gateways[ $order->payment_method ];
|
||||
|
||||
if ( ! in_array( 'refunds', $gateway->supports ) || ! method_exists( $gateway, 'refund' ) ) {
|
||||
$disabled = ' disabled="disabled"';
|
||||
$supports_refunds = false;
|
||||
} else {
|
||||
$supports_refunds = true;
|
||||
}
|
||||
}
|
||||
|
||||
echo '<option value="refund"' . $disabled . '>' . __( 'Refund Lines', 'woocommerce' ) . '</option>';
|
||||
echo '<option value="refund">' . __( 'Manual Refund Lines', 'woocommerce' ) . '</option>';
|
||||
echo '<option value="refund" ' . disabled( $supports_refunds, false ) . '>' . sprintf( __( 'Refund Lines via %s', 'woocommerce' ), $order->payment_method ) . '</option>';
|
||||
}
|
||||
echo '<option value="manual_refund">' . __( 'Mark Lines Refunded', 'woocommerce' ) . '</option>';
|
||||
?>
|
||||
</optgroup>
|
||||
<optgroup label="<?php _e( 'Stock Actions', 'woocommerce' ); ?>">
|
||||
|
@ -388,7 +394,7 @@ function woocommerce_order_items_meta_box( $post ) {
|
|||
<option value="increase_stock"><?php _e( 'Increase Line Stock', 'woocommerce' ); ?></option>
|
||||
</optgroup>
|
||||
</select>
|
||||
|
||||
|
||||
<button type="button" class="button do_bulk_action"><?php _e( 'Apply', 'woocommerce' ); ?></button>
|
||||
</p>
|
||||
|
||||
|
@ -412,40 +418,59 @@ function woocommerce_order_items_meta_box( $post ) {
|
|||
* @param mixed $post
|
||||
* @return void
|
||||
*/
|
||||
function woocommerce_order_actions_meta_box($post) {
|
||||
function woocommerce_order_actions_meta_box( $post ) {
|
||||
global $woocommerce, $theorder, $wpdb;
|
||||
|
||||
if ( ! is_object( $theorder ) )
|
||||
$theorder = new WC_Order( $post->ID );
|
||||
|
||||
$order = $theorder;
|
||||
?>
|
||||
<ul class="order_actions submitbox">
|
||||
|
||||
<?php do_action( 'woocommerce_order_actions', $post->ID ); ?>
|
||||
|
||||
<li class="wide" id="order-emails">
|
||||
<a href="#order-emails" class="show-order-emails hide-if-no-js tips" data-tip="<?php _e( 'Lets you send or resend order emails to the admin or customer.', 'woocommerce' ); ?>"><?php _e( 'Show order emails', 'woocommerce' ); ?></a>
|
||||
<li class="wide" id="actions">
|
||||
<select name="wc_order_action">
|
||||
<option value=""><?php _e( 'Actions', 'woocommerce' ); ?></option>
|
||||
<optgroup label="<?php _e( 'Resend order emails', 'woocommerce' ); ?>">
|
||||
<?php
|
||||
global $woocommerce;
|
||||
$mailer = $woocommerce->mailer();
|
||||
|
||||
<div id="order-emails-select" class="hide-if-js">
|
||||
<?php
|
||||
global $woocommerce;
|
||||
$mailer = $woocommerce->mailer();
|
||||
$available_emails = apply_filters( 'woocommerce_resend_order_emails_available', array( 'new_order', 'customer_processing_order', 'customer_completed_order', 'customer_invoice' ) );
|
||||
$mails = $mailer->get_emails();
|
||||
|
||||
$available_emails = apply_filters( 'woocommerce_resend_order_emails_available', array( 'new_order', 'customer_processing_order', 'customer_completed_order', 'customer_invoice' ) );
|
||||
$mails = $mailer->get_emails();
|
||||
|
||||
if ( ! empty( $mails ) ) {
|
||||
foreach ( $mails as $mail ) {
|
||||
if ( in_array( $mail->id, $available_emails ) ) {
|
||||
echo '<label><input name="order_email[]" type="checkbox" value="'. esc_attr( $mail->id ) .'" id="'. esc_attr( $mail->id ) .'_email"> ' . $mail->title. '</label>';
|
||||
echo '<img class="help_tip" data-tip="' . esc_attr( $mail->description ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" /></br >';
|
||||
if ( ! empty( $mails ) ) {
|
||||
foreach ( $mails as $mail ) {
|
||||
if ( in_array( $mail->id, $available_emails ) ) {
|
||||
echo '<option value="send_email_'. esc_attr( $mail->id ) .'">' . esc_html( $mail->title ) . '</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<p>
|
||||
<input type="submit" class="save-post-visibility hide-if-no-js button" value="<?php _e( 'Send selected emails', 'woocommerce' ); ?>">
|
||||
<a href="#order-emails" class="hide-order-emails hide-if-no-js"><?php _e( 'Cancel', 'woocommerce' ); ?></a>
|
||||
</p>
|
||||
</optgroup>
|
||||
<optgroup label="<?php _e( 'Refund Order', 'woocommerce' ); ?>">
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
$gateways = $woocommerce->payment_gateways->payment_gateways();
|
||||
|
||||
if ( isset( $gateways[ $order->payment_method ] ) ) {
|
||||
$gateway = $gateways[ $order->payment_method ];
|
||||
|
||||
if ( ! in_array( 'refunds', $gateway->supports ) || ! method_exists( $gateway, 'refund' ) ) {
|
||||
$supports_refunds = false;
|
||||
} else {
|
||||
$supports_refunds = true;
|
||||
}
|
||||
|
||||
echo '<option value="refund_order" ' . disabled( $supports_refunds, false ) . '>' . sprintf( __( 'Refund Order via %s', 'woocommerce' ), $order->payment_method ) . '</option>';
|
||||
}
|
||||
echo '<option value="manual_refund_order">' . __( 'Mark Order Refunded', 'woocommerce' ) . '</option>';
|
||||
?>
|
||||
</optgroup>
|
||||
</select>
|
||||
|
||||
<button class="button"><?php _e( 'Apply', 'woocommerce' ); ?></button>
|
||||
</li>
|
||||
|
||||
<li class="wide">
|
||||
|
@ -456,9 +481,9 @@ function woocommerce_order_actions_meta_box($post) {
|
|||
else
|
||||
$delete_text = __( 'Move to Trash', 'woocommerce' );
|
||||
?><a class="submitdelete deletion" href="<?php echo esc_url( get_delete_post_link( $post->ID ) ); ?>"><?php echo $delete_text; ?></a><?php
|
||||
}
|
||||
}
|
||||
?></div>
|
||||
|
||||
|
||||
<input type="submit" class="button save_order button-primary tips" name="save" value="<?php _e( 'Save Order', 'woocommerce' ); ?>" data-tip="<?php _e( 'Save/update the order', 'woocommerce' ); ?>" />
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -474,11 +499,11 @@ function woocommerce_order_actions_meta_box($post) {
|
|||
* @return void
|
||||
*/
|
||||
function woocommerce_order_totals_meta_box( $post ) {
|
||||
global $woocommerce, $theorder;
|
||||
|
||||
global $woocommerce, $theorder, $wpdb;
|
||||
|
||||
if ( ! is_object( $theorder ) )
|
||||
$theorder = new WC_Order( $post->ID );
|
||||
|
||||
|
||||
$order = $theorder;
|
||||
|
||||
$data = get_post_custom( $post->ID );
|
||||
|
@ -489,39 +514,57 @@ function woocommerce_order_totals_meta_box( $post ) {
|
|||
|
||||
<li class="left">
|
||||
<label><?php _e( 'Cart Discount:', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Discounts before tax - calculated by comparing subtotals to totals.', 'woocommerce' ); ?>" href="#">[?]</a></label>
|
||||
<input type="text" id="_cart_discount" name="_cart_discount" placeholder="0.00" value="<?php
|
||||
if ( isset( $data['_cart_discount'][0] ) )
|
||||
<input type="number" step="any" min="0" id="_cart_discount" name="_cart_discount" placeholder="0.00" value="<?php
|
||||
if ( isset( $data['_cart_discount'][0] ) )
|
||||
echo esc_attr( $data['_cart_discount'][0] );
|
||||
?>" class="calculated" />
|
||||
</li>
|
||||
|
||||
<li class="right">
|
||||
<label><?php _e( 'Order Discount:', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Discounts after tax - user defined.', 'woocommerce' ); ?>" href="#">[?]</a></label>
|
||||
<input type="text" id="_order_discount" name="_order_discount" placeholder="0.00" value="<?php
|
||||
if ( isset( $data['_order_discount'][0] ) )
|
||||
<input type="number" step="any" min="0" id="_order_discount" name="_order_discount" placeholder="0.00" value="<?php
|
||||
if ( isset( $data['_order_discount'][0] ) )
|
||||
echo esc_attr( $data['_order_discount'][0] );
|
||||
?>" />
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<div class="clear"></div>
|
||||
|
||||
<ul class="wc_coupon_list">
|
||||
|
||||
<?php
|
||||
$coupons = $order->get_items( array( 'coupon' ) );
|
||||
|
||||
foreach ( $coupons as $item_id => $item ) {
|
||||
|
||||
$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' LIMIT 1;", $item['name'] ) );
|
||||
|
||||
$link = $post_id ? admin_url( 'post.php?post=' . $post_id . '&action=edit' ) : admin_url( 'edit.php?s=' . esc_url( $item['name'] ) . '&post_status=all&post_type=shop_coupon' );
|
||||
|
||||
echo '<li class="tips code" data-tip="' . esc_attr( woocommerce_price( $item['discount_amount'] ) ) . '"><a href="' . $link . '"><span>' . esc_html( $item['name'] ). '</span></a></li>';
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="totals_group">
|
||||
<h4><?php _e( 'Shipping', 'woocommerce' ); ?></h4>
|
||||
<ul class="totals">
|
||||
|
||||
|
||||
<li class="wide">
|
||||
<label><?php _e( 'Label:', 'woocommerce' ); ?></label>
|
||||
<input type="text" id="_shipping_method_title" name="_shipping_method_title" placeholder="<?php _e( 'The shipping title the customer sees', 'woocommerce' ); ?>" value="<?php
|
||||
if ( isset( $data['_shipping_method_title'][0] ) )
|
||||
<input type="text" id="_shipping_method_title" name="_shipping_method_title" placeholder="<?php _e( 'The shipping title the customer sees', 'woocommerce' ); ?>" value="<?php
|
||||
if ( isset( $data['_shipping_method_title'][0] ) )
|
||||
echo esc_attr( $data['_shipping_method_title'][0] );
|
||||
?>" class="first" />
|
||||
</li>
|
||||
|
||||
|
||||
<li class="left">
|
||||
<label><?php _e( 'Cost:', 'woocommerce' ); ?></label>
|
||||
<input type="text" id="_order_shipping" name="_order_shipping" placeholder="0.00 <?php _e( '(ex. tax)', 'woocommerce' ); ?>" value="<?php
|
||||
if ( isset( $data['_order_shipping'][0] ) )
|
||||
<input type="number" step="any" min="0" id="_order_shipping" name="_order_shipping" placeholder="0.00 <?php _e( '(ex. tax)', 'woocommerce' ); ?>" value="<?php
|
||||
if ( isset( $data['_order_shipping'][0] ) )
|
||||
echo esc_attr( $data['_order_shipping'][0] );
|
||||
?>" class="first" />
|
||||
</li>
|
||||
|
@ -536,8 +579,14 @@ function woocommerce_order_totals_meta_box( $post ) {
|
|||
|
||||
if ( $woocommerce->shipping ) {
|
||||
foreach ( $woocommerce->shipping->load_shipping_methods() as $method ) {
|
||||
echo '<option value="' . esc_attr( $method->id ) . '" ' . selected( ( strpos( $chosen_method, $method->id ) === 0 ), true, false ) . '>' . esc_html( $method->get_title() ) . '</option>';
|
||||
|
||||
if ( strpos( $chosen_method, $method->id ) === 0 )
|
||||
$value = $chosen_method;
|
||||
else
|
||||
$value = $method->id;
|
||||
|
||||
echo '<option value="' . esc_attr( $value ) . '" ' . selected( $chosen_method == $value, true, false ) . '>' . esc_html( $method->get_title() ) . '</option>';
|
||||
if ( $chosen_method == $value )
|
||||
$found_method = true;
|
||||
}
|
||||
}
|
||||
|
@ -559,6 +608,23 @@ function woocommerce_order_totals_meta_box( $post ) {
|
|||
<h4><?php _e( 'Tax Rows', 'woocommerce' ); ?></h4>
|
||||
<div id="tax_rows" class="total_rows">
|
||||
<?php
|
||||
global $wpdb;
|
||||
|
||||
$rates = $wpdb->get_results( "SELECT tax_rate_id, tax_rate_country, tax_rate_state, tax_rate_name, tax_rate_priority FROM {$wpdb->prefix}woocommerce_tax_rates ORDER BY tax_rate_name" );
|
||||
|
||||
$tax_codes = array();
|
||||
|
||||
foreach( $rates as $rate ) {
|
||||
$code = array();
|
||||
|
||||
$code[] = $rate->tax_rate_country;
|
||||
$code[] = $rate->tax_rate_state;
|
||||
$code[] = $rate->tax_rate_name ? sanitize_title( $rate->tax_rate_name ) : 'TAX';
|
||||
$code[] = absint( $rate->tax_rate_priority );
|
||||
|
||||
$tax_codes[ $rate->tax_rate_id ] = strtoupper( implode( '-', array_filter( $code ) ) );
|
||||
}
|
||||
|
||||
foreach ( $order->get_taxes() as $item_id => $item ) {
|
||||
include( 'order-tax-html.php' );
|
||||
}
|
||||
|
@ -573,16 +639,16 @@ function woocommerce_order_totals_meta_box( $post ) {
|
|||
|
||||
<li class="left">
|
||||
<label><?php _e( 'Sales Tax:', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Total tax for line items + fees.', 'woocommerce' ); ?>" href="#">[?]</a></label>
|
||||
<input type="text" id="_order_tax" name="_order_tax" placeholder="0.00" value="<?php
|
||||
if ( isset( $data['_order_tax'][0] ) )
|
||||
<input type="number" step="any" min="0" id="_order_tax" name="_order_tax" placeholder="0.00" value="<?php
|
||||
if ( isset( $data['_order_tax'][0] ) )
|
||||
echo esc_attr( $data['_order_tax'][0] );
|
||||
?>" class="calculated" />
|
||||
</li>
|
||||
|
||||
<li class="right">
|
||||
<label><?php _e( 'Shipping Tax:', 'woocommerce' ); ?></label>
|
||||
<input type="text" id="_order_shipping_tax" name="_order_shipping_tax" placeholder="0.00" value="<?php
|
||||
if ( isset( $data['_order_shipping_tax'][0] ) )
|
||||
<input type="number" step="any" min="0" id="_order_shipping_tax" name="_order_shipping_tax" placeholder="0.00" value="<?php
|
||||
if ( isset( $data['_order_shipping_tax'][0] ) )
|
||||
echo esc_attr( $data['_order_shipping_tax'][0] );
|
||||
?>" />
|
||||
</li>
|
||||
|
@ -591,18 +657,26 @@ function woocommerce_order_totals_meta_box( $post ) {
|
|||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="totals_group">
|
||||
<h4><?php _e( 'Total', 'woocommerce' ); ?></h4>
|
||||
<h4><?php _e( 'Order Totals', 'woocommerce' ); ?></h4>
|
||||
<ul class="totals">
|
||||
|
||||
<li class="left">
|
||||
<label><?php _e( 'Order Total:', 'woocommerce' ); ?></label>
|
||||
<input type="text" id="_order_total" name="_order_total" placeholder="0.00" value="<?php
|
||||
if ( isset( $data['_order_total'][0] ) )
|
||||
<input type="number" step="any" min="0" id="_order_total" name="_order_total" placeholder="0.00" value="<?php
|
||||
if ( isset( $data['_order_total'][0] ) )
|
||||
echo esc_attr( $data['_order_total'][0] );
|
||||
?>" class="calculated" />
|
||||
</li>
|
||||
|
||||
<li class="right">
|
||||
<label><?php _e( 'Refund Total:', 'woocommerce' ); ?></label>
|
||||
<input type="number" step="any" min="0" id="_order_refund_total" name="_order_refund_total" placeholder="0.00" value="<?php
|
||||
if ( isset( $data['_refund_total'][0] ) )
|
||||
echo esc_attr( $data['_refund_total'][0] );
|
||||
?>" />
|
||||
</li>
|
||||
|
||||
<li class="wide">
|
||||
<label><?php _e( 'Payment Method:', 'woocommerce' ); ?></label>
|
||||
<select name="_payment_method" id="_payment_method" class="first">
|
||||
<option value=""><?php _e( 'N/A', 'woocommerce' ); ?></option>
|
||||
|
@ -679,6 +753,7 @@ function woocommerce_process_shop_order_meta( $post_id, $post ) {
|
|||
update_post_meta( $post_id, '_cart_discount', woocommerce_clean( $_POST['_cart_discount'] ) );
|
||||
update_post_meta( $post_id, '_order_discount', woocommerce_clean( $_POST['_order_discount'] ) );
|
||||
update_post_meta( $post_id, '_order_total', woocommerce_clean( $_POST['_order_total'] ) );
|
||||
update_post_meta( $post_id, '_refund_total', woocommerce_clean( $_POST['_order_refund_total'] ) );
|
||||
update_post_meta( $post_id, '_customer_user', absint( $_POST['customer_user'] ) );
|
||||
update_post_meta( $post_id, '_order_tax', woocommerce_clean( $_POST['_order_tax'] ) );
|
||||
update_post_meta( $post_id, '_order_shipping_tax', woocommerce_clean( $_POST['_order_shipping_tax'] ) );
|
||||
|
@ -733,95 +808,110 @@ function woocommerce_process_shop_order_meta( $post_id, $post ) {
|
|||
|
||||
// Tax rows
|
||||
if ( isset( $_POST['order_taxes_id'] ) ) {
|
||||
|
||||
$get_values = array( 'order_taxes_id', 'order_taxes_label', 'order_taxes_compound', 'order_taxes_amount', 'order_taxes_shipping_amount' );
|
||||
|
||||
$get_values = array( 'order_taxes_id', 'order_taxes_rate_id', 'order_taxes_amount', 'order_taxes_shipping_amount' );
|
||||
|
||||
foreach( $get_values as $value )
|
||||
$$value = isset( $_POST[ $value ] ) ? $_POST[ $value ] : array();
|
||||
|
||||
foreach( $order_taxes_id as $item_id ) {
|
||||
|
||||
$item_id = absint( $item_id );
|
||||
|
||||
if ( ! $order_taxes_label[ $item_id ] )
|
||||
$order_taxes_label[ $item_id ] = $woocommerce->countries->tax_or_vat();
|
||||
$item_id = absint( $item_id );
|
||||
$rate_id = absint( $order_taxes_rate_id[ $item_id ] );
|
||||
|
||||
if ( $rate_id ) {
|
||||
$rate = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $rate_id ) );
|
||||
$label = $rate->tax_rate_name ? $rate->tax_rate_name : $woocommerce->countries->tax_or_vat();
|
||||
$compound = $rate->tax_rate_compound ? 1 : 0;
|
||||
|
||||
$code = array();
|
||||
|
||||
$code[] = $rate->tax_rate_country;
|
||||
$code[] = $rate->tax_rate_state;
|
||||
$code[] = $rate->tax_rate_name ? $rate->tax_rate_name : 'TAX';
|
||||
$code[] = absint( $rate->tax_rate_priority );
|
||||
$code = strtoupper( implode( '-', array_filter( $code ) ) );
|
||||
} else {
|
||||
$code = '';
|
||||
$label = $woocommerce->countries->tax_or_vat();
|
||||
}
|
||||
|
||||
$wpdb->update(
|
||||
$wpdb->prefix . "woocommerce_order_items",
|
||||
array( 'order_item_name' => woocommerce_clean( $code ) ),
|
||||
array( 'order_item_id' => $item_id ),
|
||||
array( '%s' ),
|
||||
array( '%d' )
|
||||
);
|
||||
|
||||
woocommerce_update_order_item_meta( $item_id, 'rate_id', $rate_id );
|
||||
woocommerce_update_order_item_meta( $item_id, 'label', $label );
|
||||
woocommerce_update_order_item_meta( $item_id, 'compound', $compound );
|
||||
|
||||
if ( isset( $order_taxes_label[ $item_id ] ) )
|
||||
$wpdb->update(
|
||||
$wpdb->prefix . "woocommerce_order_items",
|
||||
array( 'order_item_name' => woocommerce_clean( $order_taxes_label[ $item_id ] ) ),
|
||||
array( 'order_item_id' => $item_id ),
|
||||
array( '%s' ),
|
||||
array( '%d' )
|
||||
);
|
||||
|
||||
if ( isset( $order_taxes_compound[ $item_id ] ) )
|
||||
woocommerce_update_order_item_meta( $item_id, 'compound', isset( $order_taxes_compound[ $item_id ] ) ? 1 : 0 );
|
||||
|
||||
if ( isset( $order_taxes_amount[ $item_id ] ) )
|
||||
woocommerce_update_order_item_meta( $item_id, 'tax_amount', woocommerce_clean( $order_taxes_amount[ $item_id ] ) );
|
||||
|
||||
|
||||
if ( isset( $order_taxes_shipping_amount[ $item_id ] ) )
|
||||
woocommerce_update_order_item_meta( $item_id, 'shipping_tax_amount', woocommerce_clean( $order_taxes_shipping_amount[ $item_id ] ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Order items + fees
|
||||
if ( isset( $_POST['order_item_id'] ) ) {
|
||||
|
||||
|
||||
$get_values = array( 'order_item_id', 'order_item_name', 'order_item_qty', 'line_subtotal', 'line_subtotal_tax', 'line_total', 'line_tax', 'order_item_tax_class' );
|
||||
|
||||
|
||||
foreach( $get_values as $value )
|
||||
$$value = isset( $_POST[ $value ] ) ? $_POST[ $value ] : array();
|
||||
|
||||
foreach ( $order_item_id as $item_id ) {
|
||||
|
||||
|
||||
$item_id = absint( $item_id );
|
||||
|
||||
|
||||
if ( isset( $order_item_name[ $item_id ] ) )
|
||||
$wpdb->update(
|
||||
$wpdb->prefix . "woocommerce_order_items",
|
||||
array( 'order_item_name' => woocommerce_clean( $order_item_name[ $item_id ] ) ),
|
||||
array( 'order_item_id' => $item_id ),
|
||||
array( '%s' ),
|
||||
array( '%d' )
|
||||
$wpdb->update(
|
||||
$wpdb->prefix . "woocommerce_order_items",
|
||||
array( 'order_item_name' => woocommerce_clean( $order_item_name[ $item_id ] ) ),
|
||||
array( 'order_item_id' => $item_id ),
|
||||
array( '%s' ),
|
||||
array( '%d' )
|
||||
);
|
||||
|
||||
|
||||
if ( isset( $order_item_qty[ $item_id ] ) )
|
||||
woocommerce_update_order_item_meta( $item_id, '_qty', absint( $order_item_qty[ $item_id ] ) );
|
||||
|
||||
woocommerce_update_order_item_meta( $item_id, '_qty', apply_filters( 'woocommerce_stock_amount', $order_item_qty[ $item_id ] ) );
|
||||
|
||||
if ( isset( $item_tax_class[ $item_id ] ) )
|
||||
woocommerce_update_order_item_meta( $item_id, '_tax_class', woocommerce_clean( $item_tax_class[ $item_id ] ) );
|
||||
|
||||
|
||||
if ( isset( $line_subtotal[ $item_id ] ) )
|
||||
woocommerce_update_order_item_meta( $item_id, '_line_subtotal', woocommerce_clean( $line_subtotal[ $item_id ] ) );
|
||||
|
||||
|
||||
if ( isset( $line_subtotal_tax[ $item_id ] ) )
|
||||
woocommerce_update_order_item_meta( $item_id, '_line_subtotal_tax', woocommerce_clean( $line_subtotal_tax[ $item_id ] ) );
|
||||
|
||||
|
||||
if ( isset( $line_total[ $item_id ] ) )
|
||||
woocommerce_update_order_item_meta( $item_id, '_line_total', woocommerce_clean( $line_total[ $item_id ] ) );
|
||||
|
||||
|
||||
if ( isset( $line_tax[ $item_id ] ) )
|
||||
woocommerce_update_order_item_meta( $item_id, '_line_tax', woocommerce_clean( $line_tax[ $item_id ] ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Save meta
|
||||
$meta_keys = isset( $_POST['meta_key'] ) ? $_POST['meta_key'] : '';
|
||||
$meta_values = isset( $_POST['meta_value'] ) ? $_POST['meta_value'] : '';
|
||||
|
||||
$meta_keys = isset( $_POST['meta_key'] ) ? $_POST['meta_key'] : array();
|
||||
$meta_values = isset( $_POST['meta_value'] ) ? $_POST['meta_value'] : array();
|
||||
|
||||
foreach ( $meta_keys as $id => $value ) {
|
||||
$wpdb->update(
|
||||
$wpdb->prefix . "woocommerce_order_itemmeta",
|
||||
array(
|
||||
$wpdb->update(
|
||||
$wpdb->prefix . "woocommerce_order_itemmeta",
|
||||
array(
|
||||
'meta_key' => $value,
|
||||
'meta_value' => empty( $meta_values[ $id ] ) ? '' : $meta_values[ $id ]
|
||||
),
|
||||
array( 'meta_id' => $id ),
|
||||
array( '%s', '%s' ),
|
||||
array( '%d' )
|
||||
),
|
||||
array( 'meta_id' => $id ),
|
||||
array( '%s', '%s' ),
|
||||
array( '%d' )
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -830,28 +920,45 @@ function woocommerce_process_shop_order_meta( $post_id, $post ) {
|
|||
|
||||
// Order status
|
||||
$order->update_status( $_POST['order_status'] );
|
||||
|
||||
|
||||
// Handle button actions
|
||||
if ( ! empty( $_POST['order_email'] ) ) {
|
||||
if ( ! empty( $_POST['wc_order_action'] ) ) {
|
||||
|
||||
do_action( 'woocommerce_before_resend_order_emails', $order );
|
||||
$action = woocommerce_clean( $_POST['wc_order_action'] );
|
||||
|
||||
$mailer = $woocommerce->mailer();
|
||||
if ( strstr( $action, 'send_email_' ) ) {
|
||||
|
||||
$available_emails = apply_filters( 'woocommerce_resend_order_emails_available', array( 'new_order', 'customer_processing_order', 'customer_completed_order', 'customer_invoice' ) );
|
||||
$resend_emails = array_intersect( $available_emails, $_POST['order_email'] );
|
||||
$mails = $mailer->get_emails();
|
||||
do_action( 'woocommerce_before_resend_order_emails', $order );
|
||||
|
||||
if ( ! empty( $mails ) ) {
|
||||
foreach ( $mails as $mail ) {
|
||||
if ( in_array( $mail->id, $resend_emails ) ) {
|
||||
$mail->trigger( $order->id );
|
||||
$mailer = $woocommerce->mailer();
|
||||
|
||||
$email_to_send = str_replace( 'send_email_', '', $action );
|
||||
|
||||
$mails = $mailer->get_emails();
|
||||
|
||||
if ( ! empty( $mails ) ) {
|
||||
foreach ( $mails as $mail ) {
|
||||
if ( $mail->id == $email_to_send ) {
|
||||
$mail->trigger( $order->id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_after_resend_order_emails', $order, $resend_emails );
|
||||
|
||||
} elseif ( $action == 'refund_order' ) {
|
||||
|
||||
$order->refund_order( true );
|
||||
|
||||
} elseif ( $action == 'manual_refund_order' ) {
|
||||
|
||||
$order->refund_order( false );
|
||||
|
||||
} else {
|
||||
|
||||
do_action( 'woocommerce_order_action_' . sanitize_title( $action ), $order );
|
||||
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_after_resend_order_emails', $order, $resend_emails );
|
||||
|
||||
}
|
||||
|
||||
delete_transient( 'woocommerce_processing_order_count' );
|
||||
|
|
|
@ -29,25 +29,25 @@ function woocommerce_order_downloads_meta_box() {
|
|||
<?php
|
||||
$download_permissions = $wpdb->get_results( $wpdb->prepare( "
|
||||
SELECT * FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions
|
||||
WHERE order_id = $post->ID ORDER BY product_id
|
||||
" ) );
|
||||
WHERE order_id = %d ORDER BY product_id
|
||||
", $post->ID ) );
|
||||
|
||||
$product = null;
|
||||
if ( $download_permissions && sizeof( $download_permissions ) > 0 ) foreach ( $download_permissions as $download ) {
|
||||
|
||||
if ( ! $product || $product->id != $download->product_id ) {
|
||||
$product = new WC_Product( absint( $download->product_id ) );
|
||||
$product = get_product( absint( $download->product_id ) );
|
||||
$file_count = $loop = 0;
|
||||
}
|
||||
|
||||
// don't show permissions to files that have since been removed
|
||||
if ( ! $product->exists() || ! $product->has_file( $download->download_id ) )
|
||||
if ( ! $product->exists() || ! $product->has_file( $download->download_id ) )
|
||||
continue;
|
||||
|
||||
|
||||
include( 'order-download-permission-html.php' );
|
||||
|
||||
$loop++;
|
||||
$file_count++;
|
||||
|
||||
include( 'order-download-permission-html.php' );
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
@ -77,7 +77,7 @@ function woocommerce_order_downloads_meta_box() {
|
|||
|
||||
$sku = get_post_meta( $product->ID, '_sku', true );
|
||||
|
||||
if ( $sku )
|
||||
if ( $sku )
|
||||
$sku = ' SKU: ' . $sku;
|
||||
|
||||
echo '<option value="' . esc_attr( $product->ID ) . '">' . esc_html( $product->post_title . ' (#' . $product->ID . '' . $sku . ')' ) . '</option>';
|
||||
|
@ -123,9 +123,9 @@ function woocommerce_order_downloads_meta_box() {
|
|||
jQuery('.order_download_permissions .wc-metaboxes').append( response );
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
alert('<?php _e( 'Could not grant access - the user may already have permission for this file.', 'woocommerce' ); ?>');
|
||||
|
||||
|
||||
}
|
||||
|
||||
jQuery( ".date-picker" ).datepicker({
|
||||
|
@ -215,7 +215,7 @@ function woocommerce_order_downloads_save( $post_id, $post ) {
|
|||
$customer_email = get_post_meta( $post->ID, '_billing_email', true );
|
||||
$customer_user = get_post_meta( $post->ID, '_customer_user', true );
|
||||
$product_ids_count = sizeof( $product_ids );
|
||||
|
||||
|
||||
for ( $i = 0; $i < $product_ids_count; $i ++ ) {
|
||||
|
||||
$data = array(
|
||||
|
@ -239,8 +239,8 @@ function woocommerce_order_downloads_save( $post_id, $post ) {
|
|||
'order_id' => $post_id,
|
||||
'product_id' => absint( $product_ids[$i] ),
|
||||
'download_id' => woocommerce_clean( $download_ids[$i] )
|
||||
),
|
||||
$format, array( '%d', '%d', '%s' )
|
||||
),
|
||||
$format, array( '%d', '%d', '%s' )
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/WritePanels
|
||||
* @version 1.7.0
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -34,7 +34,7 @@ function woocommerce_order_notes_meta_box() {
|
|||
if ( $notes ) {
|
||||
foreach( $notes as $note ) {
|
||||
$note_classes = get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? array( 'customer-note', 'note' ) : array( 'note' );
|
||||
|
||||
|
||||
?>
|
||||
<li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo implode( ' ', $note_classes ); ?>">
|
||||
<div class="note_content">
|
||||
|
@ -53,7 +53,7 @@ function woocommerce_order_notes_meta_box() {
|
|||
echo '</ul>';
|
||||
?>
|
||||
<div class="add_note">
|
||||
<h4><?php _e( 'Add note', 'woocommerce' ); ?> <img class="help_tip" data-tip='<?php esc_attr_e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'woocommerce' ); ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" /></h4>
|
||||
<h4><?php _e( 'Add note', 'woocommerce' ); ?> <img class="help_tip" data-tip='<?php esc_attr_e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'woocommerce' ); ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" height="16" width="16" /></h4>
|
||||
<p>
|
||||
<textarea type="text" name="order_note" id="add_order_note" class="input-text" cols="20" rows="5"></textarea>
|
||||
</p>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/WritePanels
|
||||
* @version 1.7.0
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -52,11 +52,11 @@ function variable_product_type_options() {
|
|||
$tax_class_options = array();
|
||||
$tax_class_options['parent'] = __( 'Same as parent', 'woocommerce' );
|
||||
$tax_class_options[''] = __( 'Standard', 'woocommerce' );
|
||||
if ( $tax_classes )
|
||||
if ( $tax_classes )
|
||||
foreach ( $tax_classes as $class )
|
||||
$tax_class_options[ sanitize_title( $class ) ] = esc_attr( $class );
|
||||
?>
|
||||
<div id="variable_product_options" class="panel wc-metaboxes-wrapper">
|
||||
<div id="variable_product_options" class="panel wc-metaboxes-wrapper"><div id="variable_product_options_inner">
|
||||
|
||||
<?php if ( ! $variation_attribute_found ) : ?>
|
||||
|
||||
|
@ -74,7 +74,7 @@ function variable_product_type_options() {
|
|||
<a href="#" class="close_all"><?php _e( 'Close all', 'woocommerce' ); ?></a><a href="#" class="expand_all"><?php _e( 'Expand all', 'woocommerce' ); ?></a>
|
||||
<strong><?php _e( 'Bulk edit:', 'woocommerce' ); ?></strong>
|
||||
<select id="field_to_edit">
|
||||
<option value="variable_price"><?php _e( 'Prices', 'woocommerce' ); ?></option>
|
||||
<option value="variable_regular_price"><?php _e( 'Prices', 'woocommerce' ); ?></option>
|
||||
<option value="variable_sale_price"><?php _e( 'Sale prices', 'woocommerce' ); ?></option>
|
||||
<option value="variable_stock"><?php _e( 'Stock', 'woocommerce' ); ?></option>
|
||||
<option value="variable_weight"><?php _e( 'Weight', 'woocommerce' ); ?></option>
|
||||
|
@ -103,19 +103,19 @@ function variable_product_type_options() {
|
|||
'height' => get_post_meta( $post->ID, '_height', true ),
|
||||
'tax_class' => get_post_meta( $post->ID, '_tax_class', true )
|
||||
);
|
||||
|
||||
|
||||
if ( ! $parent_data['weight'] )
|
||||
$parent_data['weight'] = '0.00';
|
||||
|
||||
|
||||
if ( ! $parent_data['length'] )
|
||||
$parent_data['length'] = '0';
|
||||
|
||||
|
||||
if ( ! $parent_data['width'] )
|
||||
$parent_data['width'] = '0';
|
||||
|
||||
|
||||
if ( ! $parent_data['height'] )
|
||||
$parent_data['height'] = '0';
|
||||
|
||||
|
||||
// Get variations
|
||||
$args = array(
|
||||
'post_type' => 'product_variation',
|
||||
|
@ -128,19 +128,19 @@ function variable_product_type_options() {
|
|||
$variations = get_posts( $args );
|
||||
$loop = 0;
|
||||
if ( $variations ) foreach ( $variations as $variation ) {
|
||||
|
||||
|
||||
$variation_id = absint( $variation->ID );
|
||||
$variation_post_status = esc_attr( $variation->post_status );
|
||||
$variation_data = get_post_custom( $variation_id );
|
||||
$variation_data['variation_post_id'] = $variation_id;
|
||||
|
||||
|
||||
// Grab shipping classes
|
||||
$shipping_classes = get_the_terms( $variation_id, 'product_shipping_class' );
|
||||
$shipping_class = ( $shipping_classes && ! is_wp_error( $shipping_classes ) ) ? current( $shipping_classes )->term_id : '';
|
||||
|
||||
$variation_fields = array(
|
||||
|
||||
$variation_fields = array(
|
||||
'_sku',
|
||||
'_stock',
|
||||
'_stock',
|
||||
'_price',
|
||||
'_regular_price',
|
||||
'_sale_price',
|
||||
|
@ -158,28 +158,28 @@ function variable_product_type_options() {
|
|||
'_sale_price_dates_from',
|
||||
'_sale_price_dates_to'
|
||||
);
|
||||
|
||||
|
||||
foreach ( $variation_fields as $field )
|
||||
$$field = isset( $variation_data[ $field ][0] ) ? $variation_data[ $field ][0] : '';
|
||||
|
||||
|
||||
// Price backwards compat
|
||||
if ( $_regular_price == '' && $_price )
|
||||
$_regular_price = $_price;
|
||||
|
||||
|
||||
// Get image
|
||||
$image = '';
|
||||
$image_id = absint( $_thumbnail_id );
|
||||
if ( $image_id )
|
||||
$image = wp_get_attachment_url( $image_id );
|
||||
|
||||
|
||||
// Format file paths
|
||||
$_file_paths = maybe_unserialize( $_file_paths );
|
||||
if ( is_array( $_file_paths ) )
|
||||
if ( is_array( $_file_paths ) )
|
||||
$_file_paths = implode( "\n", $_file_paths );
|
||||
|
||||
|
||||
include( 'variation-admin-html.php' );
|
||||
|
||||
$loop++;
|
||||
|
||||
$loop++;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
@ -196,7 +196,7 @@ function variable_product_type_options() {
|
|||
foreach ( $attributes as $attribute ) {
|
||||
|
||||
// Only deal with attributes that are variations
|
||||
if ( ! $attribute['is_variation'] )
|
||||
if ( ! $attribute['is_variation'] )
|
||||
continue;
|
||||
|
||||
// Get current value for variation (if set)
|
||||
|
@ -222,9 +222,7 @@ function variable_product_type_options() {
|
|||
</p>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div></div>
|
||||
<?php
|
||||
/**
|
||||
* Product Type Javascript
|
||||
|
@ -233,25 +231,13 @@ function variable_product_type_options() {
|
|||
?>
|
||||
jQuery(function(){
|
||||
|
||||
<?php if ( ! $attributes || ( is_array( $attributes ) && sizeof( $attributes ) == 0 ) ) : ?>
|
||||
|
||||
jQuery('#variable_product_options').on('click', 'button.link_all_variations, button.add_variation', function(){
|
||||
|
||||
alert('<?php _e( 'You must add some attributes via the "Product Data" panel and save before adding a new variation.', 'woocommerce' ); ?>');
|
||||
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
// Add a variation
|
||||
jQuery('#variable_product_options').on('click', 'button.add_variation', function(){
|
||||
|
||||
jQuery('.woocommerce_variations').block({ message: null, overlayCSS: { background: '#fff url(<?php echo $woocommerce->plugin_url(); ?>/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
|
||||
|
||||
|
||||
var loop = jQuery('.woocommerce_variation').size();
|
||||
|
||||
|
||||
var data = {
|
||||
action: 'woocommerce_add_variation',
|
||||
post_id: <?php echo $post->ID; ?>,
|
||||
|
@ -262,7 +248,7 @@ function variable_product_type_options() {
|
|||
jQuery.post('<?php echo admin_url('admin-ajax.php'); ?>', data, function(response) {
|
||||
|
||||
jQuery('.woocommerce_variations').append( response );
|
||||
|
||||
|
||||
jQuery(".tips").tipTip({
|
||||
'attribute' : 'data-tip',
|
||||
'fadeIn' : 50,
|
||||
|
@ -297,10 +283,6 @@ function variable_product_type_options() {
|
|||
|
||||
var count = parseInt( response );
|
||||
|
||||
if (count>0) {
|
||||
jQuery('.woocommerce_variations').load( window.location + ' .woocommerce_variations > *' );
|
||||
}
|
||||
|
||||
if (count==1) {
|
||||
alert( count + ' <?php _e( "variation added", 'woocommerce' ); ?>');
|
||||
} else if (count==0 || count>1) {
|
||||
|
@ -309,7 +291,17 @@ function variable_product_type_options() {
|
|||
alert('<?php _e( "No variations added", 'woocommerce' ); ?>');
|
||||
}
|
||||
|
||||
jQuery('#variable_product_options').unblock();
|
||||
if (count>0) {
|
||||
var this_page = window.location.toString();
|
||||
|
||||
this_page = this_page.replace( 'post-new.php?', 'post.php?post=<?php echo $post->ID; ?>&action=edit&' );
|
||||
|
||||
$('#variable_product_options').load( this_page + ' #variable_product_options_inner', function() {
|
||||
$('#variable_product_options').unblock();
|
||||
} );
|
||||
} else {
|
||||
$('#variable_product_options').unblock();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -393,7 +385,7 @@ function variable_product_type_options() {
|
|||
jQuery('a.bulk_edit').click(function() {
|
||||
var field_to_edit = jQuery('select#field_to_edit').val();
|
||||
var input_tag = jQuery('select#field_to_edit :selected').attr('rel') ? jQuery('select#field_to_edit :selected').attr('rel') : 'input';
|
||||
|
||||
|
||||
var value = prompt("<?php _e( 'Enter a value', 'woocommerce' ); ?>");
|
||||
jQuery(input_tag + '[name^="' + field_to_edit + '"]').val( value );
|
||||
return false;
|
||||
|
@ -467,8 +459,6 @@ function variable_product_type_options() {
|
|||
});
|
||||
};
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
var current_field_wrapper;
|
||||
|
||||
window.send_to_editor_default = window.send_to_editor;
|
||||
|
@ -588,7 +578,7 @@ function process_product_meta_variable( $post_id ) {
|
|||
|
||||
for ( $i = 0; $i <= $max_loop; $i ++ ) {
|
||||
|
||||
if ( ! isset( $variable_post_id[ $i ] ) )
|
||||
if ( ! isset( $variable_post_id[ $i ] ) )
|
||||
continue;
|
||||
|
||||
$variation_id = absint( $variable_post_id[ $i ] );
|
||||
|
@ -615,12 +605,17 @@ function process_product_meta_variable( $post_id ) {
|
|||
'post_type' => 'product_variation',
|
||||
'menu_order' => $variable_menu_order[ $i ]
|
||||
);
|
||||
|
||||
$variation_id = wp_insert_post( $variation );
|
||||
|
||||
do_action( 'woocommerce_create_product_variation', $variation_id );
|
||||
|
||||
} else {
|
||||
|
||||
$wpdb->update( $wpdb->posts, array( 'post_status' => $post_status, 'post_title' => $variation_post_title, 'menu_order' => $variable_menu_order[ $i ] ), array( 'ID' => $variation_id ) );
|
||||
|
||||
do_action( 'woocommerce_update_product_variation', $variation_id );
|
||||
|
||||
}
|
||||
|
||||
// Update post meta
|
||||
|
@ -636,22 +631,22 @@ function process_product_meta_variable( $post_id ) {
|
|||
|
||||
update_post_meta( $variation_id, '_virtual', woocommerce_clean( $is_virtual ) );
|
||||
update_post_meta( $variation_id, '_downloadable', woocommerce_clean( $is_downloadable ) );
|
||||
|
||||
|
||||
// Price handling
|
||||
$regular_price = woocommerce_clean( $variable_regular_price[ $i ] );
|
||||
$sale_price = woocommerce_clean( $variable_sale_price[ $i ] );
|
||||
$date_from = woocommerce_clean( $variable_sale_price_dates_from[ $i ] );
|
||||
$date_to = woocommerce_clean( $variable_sale_price_dates_to[ $i ] );
|
||||
|
||||
|
||||
update_post_meta( $variation_id, '_regular_price', $regular_price );
|
||||
update_post_meta( $variation_id, '_sale_price', $sale_price );
|
||||
|
||||
|
||||
// Save Dates
|
||||
if ( $date_from )
|
||||
update_post_meta( $variation_id, '_sale_price_dates_from', strtotime( $date_from ) );
|
||||
else
|
||||
update_post_meta( $variation_id, '_sale_price_dates_from', '' );
|
||||
|
||||
|
||||
if ( $date_to )
|
||||
update_post_meta( $variation_id, '_sale_price_dates_to', strtotime( $date_to ) );
|
||||
else
|
||||
|
@ -668,13 +663,13 @@ function process_product_meta_variable( $post_id ) {
|
|||
|
||||
if ( $date_from && strtotime( $date_from ) < strtotime( 'NOW', current_time( 'timestamp' ) ) )
|
||||
update_post_meta( $variation_id, '_price', $sale_price );
|
||||
|
||||
|
||||
if ( $date_to && strtotime( $date_to ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ) {
|
||||
update_post_meta( $variation_id, '_price', $regular_price );
|
||||
update_post_meta( $variation_id, '_sale_price_dates_from', '' );
|
||||
update_post_meta( $variation_id, '_sale_price_dates_to', '' );
|
||||
}
|
||||
|
||||
|
||||
if ( $variable_tax_class[ $i ] !== 'parent' )
|
||||
update_post_meta( $variation_id, '_tax_class', woocommerce_clean( $variable_tax_class[ $i ] ) );
|
||||
else
|
||||
|
@ -683,13 +678,13 @@ function process_product_meta_variable( $post_id ) {
|
|||
if ( $is_downloadable == 'yes' ) {
|
||||
update_post_meta( $variation_id, '_download_limit', woocommerce_clean( $variable_download_limit[ $i ] ) );
|
||||
update_post_meta( $variation_id, '_download_expiry', woocommerce_clean( $variable_download_expiry[ $i ] ) );
|
||||
|
||||
|
||||
$_file_paths = array();
|
||||
$file_paths = str_replace( "\r\n", "\n", $variable_file_paths[ $i ] );
|
||||
$file_paths = trim( preg_replace( "/\n+/", "\n", $file_paths ) );
|
||||
if ( $file_paths ) {
|
||||
$file_paths = explode( "\n", $file_paths );
|
||||
|
||||
|
||||
foreach ( $file_paths as $file_path ) {
|
||||
$file_path = woocommerce_clean( $file_path );
|
||||
$_file_paths[ md5( $file_path ) ] = $file_path;
|
||||
|
@ -711,7 +706,7 @@ function process_product_meta_variable( $post_id ) {
|
|||
wp_set_object_terms( $variation_id, $variable_shipping_class[ $i ], 'product_shipping_class');
|
||||
|
||||
// Remove old taxonomies attributes so data is kept up to date
|
||||
if ( $variation_id )
|
||||
if ( $variation_id )
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key LIKE %s AND post_id = %d;", 'attribute_%', $variation_id ) );
|
||||
|
||||
// Update taxonomies
|
||||
|
@ -726,6 +721,8 @@ function process_product_meta_variable( $post_id ) {
|
|||
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_save_product_variation', $variation_id );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -749,20 +746,20 @@ function process_product_meta_variable( $post_id ) {
|
|||
$child_price = get_post_meta( $child, '_price', true );
|
||||
$child_regular_price = get_post_meta( $child, '_regular_price', true );
|
||||
$child_sale_price = get_post_meta( $child, '_sale_price', true );
|
||||
|
||||
|
||||
// Regular prices
|
||||
if ( ! is_numeric( $lowest_regular_price ) || $child_regular_price < $lowest_regular_price )
|
||||
if ( ! is_numeric( $lowest_regular_price ) || $child_regular_price < $lowest_regular_price )
|
||||
$lowest_regular_price = $child_regular_price;
|
||||
|
||||
if ( ! is_numeric( $highest_regular_price ) || $child_regular_price > $highest_regular_price )
|
||||
|
||||
if ( ! is_numeric( $highest_regular_price ) || $child_regular_price > $highest_regular_price )
|
||||
$highest_regular_price = $child_regular_price;
|
||||
|
||||
|
||||
// Sale prices
|
||||
if ( $child_price == $child_sale_price ) {
|
||||
if ( $child_sale_price !== '' && ( ! is_numeric( $lowest_sale_price ) || $child_sale_price < $lowest_sale_price ) )
|
||||
if ( $child_sale_price !== '' && ( ! is_numeric( $lowest_sale_price ) || $child_sale_price < $lowest_sale_price ) )
|
||||
$lowest_sale_price = $child_sale_price;
|
||||
|
||||
if ( $child_sale_price !== '' && ( ! is_numeric( $highest_sale_price ) || $child_sale_price > $highest_sale_price ) )
|
||||
|
||||
if ( $child_sale_price !== '' && ( ! is_numeric( $highest_sale_price ) || $child_sale_price > $highest_sale_price ) )
|
||||
$highest_sale_price = $child_sale_price;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/WritePanels
|
||||
* @version 1.7.0
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/** Variable products */
|
||||
|
@ -70,17 +70,17 @@ function woocommerce_product_data_box() {
|
|||
|
||||
<span class="type_box"> — <?php echo $type_box; ?></span>
|
||||
|
||||
<div class="wc-tabs-back"></div>
|
||||
|
||||
<ul class="product_data_tabs wc-tabs" style="display:none;">
|
||||
|
||||
<li class="active general_options hide_if_grouped"><a href="#general_product_data"><?php _e( 'General', 'woocommerce' ); ?></a></li>
|
||||
|
||||
<li class="tax_tab show_if_simple show_if_variable tax_options"><a href="#tax_product_data"><?php _e( 'Taxes', 'woocommerce' ); ?></a></li>
|
||||
|
||||
<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="shipping_tab hide_if_virtual shipping_options hide_if_grouped hide_if_external"><a href="#shipping_product_data"><?php _e( 'Shipping', 'woocommerce' ); ?></a></li>
|
||||
|
||||
<li class="related_product_tab related_product_options"><a href="#related_product_data"><?php _e( 'Related Products', 'woocommerce' ); ?></a></li>
|
||||
<li class="linked_product_tab linked_product_options"><a href="#linked_product_data"><?php _e( 'Linked Products', 'woocommerce' ); ?></a></li>
|
||||
|
||||
<li class="attributes_tab attribute_options"><a href="#woocommerce_attributes"><?php _e( 'Attributes', 'woocommerce' ); ?></a></li>
|
||||
|
||||
|
@ -91,7 +91,7 @@ function woocommerce_product_data_box() {
|
|||
</ul>
|
||||
<div id="general_product_data" class="panel woocommerce_options_panel"><?php
|
||||
|
||||
echo '<div class="options_group show_if_simple show_if_variable show_if_external">';
|
||||
echo '<div class="options_group hide_if_grouped">';
|
||||
|
||||
// SKU
|
||||
if( get_option('woocommerce_enable_sku', true) !== 'no' )
|
||||
|
@ -116,10 +116,16 @@ function woocommerce_product_data_box() {
|
|||
echo '<div class="options_group pricing show_if_simple show_if_external">';
|
||||
|
||||
// Price
|
||||
woocommerce_wp_text_input( array( 'id' => '_regular_price', 'class' => 'wc_input_price short', 'label' => __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol().')' ) );
|
||||
woocommerce_wp_text_input( array( 'id' => '_regular_price', 'class' => 'wc_input_price short', 'label' => __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol().')', 'type' => 'number', 'custom_attributes' => array(
|
||||
'step' => 'any',
|
||||
'min' => '0'
|
||||
) ) );
|
||||
|
||||
// Special Price
|
||||
woocommerce_wp_text_input( array( 'id' => '_sale_price', 'class' => 'wc_input_price short', 'label' => __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol().')', 'description' => '<a href="#" class="sale_schedule">' . __( 'Schedule', 'woocommerce' ) . '</a>' ) );
|
||||
woocommerce_wp_text_input( array( 'id' => '_sale_price', 'class' => 'wc_input_price short', 'label' => __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol().')', 'description' => '<a href="#" class="sale_schedule">' . __( 'Schedule', 'woocommerce' ) . '</a>', 'type' => 'number', 'custom_attributes' => array(
|
||||
'step' => 'any',
|
||||
'min' => '0'
|
||||
) ) );
|
||||
|
||||
// Special Price date range
|
||||
$sale_price_dates_from = ( $date = get_post_meta( $thepostid, '_sale_price_dates_from', true ) ) ? date_i18n( 'Y-m-d', $date ) : '';
|
||||
|
@ -127,8 +133,8 @@ function woocommerce_product_data_box() {
|
|||
|
||||
echo ' <p class="form-field sale_price_dates_fields">
|
||||
<label for="_sale_price_dates_from">' . __( 'Sale Price Dates', 'woocommerce' ) . '</label>
|
||||
<input type="text" class="short" name="_sale_price_dates_from" id="_sale_price_dates_from" value="' . $sale_price_dates_from . '" placeholder="' . _x( 'From…', 'placeholder', 'woocommerce' ) . '" maxlength="10" />
|
||||
<input type="text" class="short" name="_sale_price_dates_to" id="_sale_price_dates_to" value="' . $sale_price_dates_to . '" placeholder="' . _x( 'To…', 'placeholder', 'woocommerce' ) . '" maxlength="10" />
|
||||
<input type="text" class="short" name="_sale_price_dates_from" id="_sale_price_dates_from" value="' . $sale_price_dates_from . '" placeholder="' . _x( 'From…', 'placeholder', 'woocommerce' ) . ' YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
|
||||
<input type="text" class="short" name="_sale_price_dates_to" id="_sale_price_dates_to" value="' . $sale_price_dates_to . '" placeholder="' . _x( 'To…', 'placeholder', 'woocommerce' ) . ' YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
|
||||
<a href="#" class="cancel_sale_schedule">'. __( 'Cancel', 'woocommerce' ) .'</a>
|
||||
</p>';
|
||||
|
||||
|
@ -140,54 +146,62 @@ function woocommerce_product_data_box() {
|
|||
|
||||
// File URL
|
||||
$file_paths = get_post_meta( $post->ID, '_file_paths', true );
|
||||
if ( is_array( $file_paths ) )
|
||||
if ( is_array( $file_paths ) )
|
||||
$file_paths = implode( "\n", $file_paths );
|
||||
|
||||
|
||||
echo '<p class="form-field"><label for="_file_paths">' . __( 'File paths (one per line)', 'woocommerce' ) . ':</label>
|
||||
<textarea style="float:left;height:5em;" id="_file_paths" class="short file_paths" cols="20" rows="3" placeholder="' . __( 'File paths/URLs, one per line', 'woocommerce' ) . '" name="_file_paths" wrap="off">' . esc_textarea( $file_paths ) . '</textarea>
|
||||
<input type="button" class="upload_file_button button" value="' . __( 'Upload a file', 'woocommerce' ) . '" />
|
||||
</p>';
|
||||
|
||||
// Download Limit
|
||||
woocommerce_wp_text_input( array( 'id' => '_download_limit', 'label' => __( 'Download Limit', 'woocommerce' ), 'placeholder' => __( 'Unlimited', 'woocommerce' ), 'description' => __( 'Leave blank for unlimited re-downloads.', 'woocommerce' ) ) );
|
||||
woocommerce_wp_text_input( array( 'id' => '_download_limit', 'label' => __( 'Download Limit', 'woocommerce' ), 'placeholder' => __( 'Unlimited', 'woocommerce' ), 'description' => __( 'Leave blank for unlimited re-downloads.', 'woocommerce' ), 'type' => 'number', 'custom_attributes' => array(
|
||||
'step' => '1',
|
||||
'min' => '0'
|
||||
) ) );
|
||||
|
||||
// Expirey
|
||||
woocommerce_wp_text_input( array( 'id' => '_download_expiry', 'label' => __( 'Download Expiry', 'woocommerce' ), 'placeholder' => __( 'Never', 'woocommerce' ), 'description' => __( 'Enter the number of days before a download link expires, or leave blank.', 'woocommerce' ) ) );
|
||||
woocommerce_wp_text_input( array( 'id' => '_download_expiry', 'label' => __( 'Download Expiry', 'woocommerce' ), 'placeholder' => __( 'Never', 'woocommerce' ), 'description' => __( 'Enter the number of days before a download link expires, or leave blank.', 'woocommerce' ), 'type' => 'number', 'custom_attributes' => array(
|
||||
'step' => '1',
|
||||
'min' => '0'
|
||||
) ) );
|
||||
|
||||
do_action( 'woocommerce_product_options_downloads' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="options_group show_if_simple show_if_external show_if_variable">';
|
||||
|
||||
// Tax
|
||||
woocommerce_wp_select( array( 'id' => '_tax_status', 'label' => __( 'Tax Status', 'woocommerce' ), 'options' => array(
|
||||
'taxable' => __( 'Taxable', 'woocommerce' ),
|
||||
'shipping' => __( 'Shipping only', 'woocommerce' ),
|
||||
'none' => __( 'None', 'woocommerce' )
|
||||
) ) );
|
||||
|
||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option( 'woocommerce_tax_classes' ) ) ) );
|
||||
$classes_options = array();
|
||||
$classes_options[''] = __( 'Standard', 'woocommerce' );
|
||||
if ( $tax_classes )
|
||||
foreach ( $tax_classes as $class )
|
||||
$classes_options[ sanitize_title( $class ) ] = esc_html( $class );
|
||||
|
||||
woocommerce_wp_select( array( 'id' => '_tax_class', 'label' => __( 'Tax Class', 'woocommerce' ), 'options' => $classes_options ) );
|
||||
|
||||
do_action( 'woocommerce_product_options_tax' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
do_action( 'woocommerce_product_options_general_product_data' );
|
||||
?>
|
||||
</div>
|
||||
<div id="tax_product_data" class="panel woocommerce_options_panel">
|
||||
<?php
|
||||
|
||||
// Tax
|
||||
woocommerce_wp_select( array( 'id' => '_tax_status', 'label' => __( 'Tax Status', 'woocommerce' ), 'options' => array(
|
||||
'taxable' => __( 'Taxable', 'woocommerce' ),
|
||||
'shipping' => __( 'Shipping only', 'woocommerce' ),
|
||||
'none' => __( 'None', 'woocommerce' )
|
||||
) ) );
|
||||
|
||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option( 'woocommerce_tax_classes' ) ) ) );
|
||||
$classes_options = array();
|
||||
$classes_options[''] = __( 'Standard', 'woocommerce' );
|
||||
if ( $tax_classes )
|
||||
foreach ( $tax_classes as $class )
|
||||
$classes_options[ sanitize_title( $class ) ] = esc_html( $class );
|
||||
|
||||
woocommerce_wp_select( array( 'id' => '_tax_class', 'label' => __( 'Tax Class', 'woocommerce' ), 'options' => $classes_options ) );
|
||||
|
||||
do_action( 'woocommerce_product_options_tax' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div id="inventory_product_data" class="panel woocommerce_options_panel">
|
||||
|
||||
<?php
|
||||
|
||||
echo '<div class="options_group">';
|
||||
|
||||
if (get_option('woocommerce_manage_stock')=='yes') {
|
||||
|
||||
// manage stock
|
||||
|
@ -198,7 +212,9 @@ function woocommerce_product_data_box() {
|
|||
echo '<div class="stock_fields show_if_simple show_if_variable">';
|
||||
|
||||
// Stock
|
||||
woocommerce_wp_text_input( array( 'id' => '_stock', 'label' => __( 'Stock Qty', 'woocommerce' ), 'desc_tip' => true, 'description' => __( 'Stock quantity. If this is a variable product this value will be used to control stock for all variations, unless you define stock at variation level.', 'woocommerce' ) ) );
|
||||
woocommerce_wp_text_input( array( 'id' => '_stock', 'label' => __( 'Stock Qty', 'woocommerce' ), 'desc_tip' => true, 'description' => __( 'Stock quantity. If this is a variable product this value will be used to control stock for all variations, unless you define stock at variation level.', 'woocommerce' ), 'type' => 'number', 'custom_attributes' => array(
|
||||
'step' => 'any'
|
||||
) ) );
|
||||
|
||||
do_action('woocommerce_product_options_stock_fields');
|
||||
|
||||
|
@ -227,19 +243,33 @@ function woocommerce_product_data_box() {
|
|||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="options_group show_if_simple show_if_variable">';
|
||||
|
||||
// Individual product
|
||||
woocommerce_wp_checkbox( array( 'id' => '_sold_individually', 'wrapper_class' => 'show_if_simple show_if_variable', 'label' => __('Sold Individually', 'woocommerce'), 'description' => __('Enable this to only allow one of this item to be bought in a single order', 'woocommerce') ) );
|
||||
|
||||
do_action('woocommerce_product_options_sold_individually');
|
||||
|
||||
echo '</div>';
|
||||
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="shipping_product_data" class="panel woocommerce_options_panel">
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
echo '<div class="options_group">';
|
||||
|
||||
|
||||
// Weight
|
||||
if( get_option('woocommerce_enable_weight', true) !== 'no' ) :
|
||||
woocommerce_wp_text_input( array( 'id' => '_weight', 'label' => __( 'Weight', 'woocommerce' ) . ' ('.get_option('woocommerce_weight_unit').')', 'placeholder' => '0.00', 'description' => __( 'Weight in decimal form', 'woocommerce' ) ) );
|
||||
woocommerce_wp_text_input( array( 'id' => '_weight', 'label' => __( 'Weight', 'woocommerce' ) . ' ('.get_option('woocommerce_weight_unit').')', 'placeholder' => '0.00', 'description' => __( 'Weight in decimal form', 'woocommerce' ), 'type' => 'number', 'custom_attributes' => array(
|
||||
'step' => 'any',
|
||||
'min' => '0'
|
||||
) ) );
|
||||
else:
|
||||
echo '<input type="hidden" name="_weight" value="' . esc_attr( get_post_meta( $thepostid, '_weight', true ) ) . '" />';
|
||||
endif;
|
||||
|
@ -249,9 +279,9 @@ function woocommerce_product_data_box() {
|
|||
?><p class="form-field dimensions_field">
|
||||
<label for"product_length"><?php echo __( 'Dimensions', 'woocommerce' ) . ' (' . get_option( 'woocommerce_dimension_unit' ) . ')'; ?></label>
|
||||
<span class="wrap">
|
||||
<input id="product_length" placeholder="<?php _e( 'Length', 'woocommerce' ); ?>" class="input-text" size="6" type="text" name="_length" value="<?php echo esc_attr( get_post_meta( $thepostid, '_length', true ) ); ?>" />
|
||||
<input placeholder="<?php _e( 'Width', 'woocommerce' ); ?>" class="input-text" size="6" type="text" name="_width" value="<?php echo esc_attr( get_post_meta( $thepostid, '_width', true ) ); ?>" />
|
||||
<input placeholder="<?php _e( 'Height', 'woocommerce' ); ?>" class="input-text last" size="6" type="text" name="_height" value="<?php echo esc_attr( get_post_meta( $thepostid, '_height', true ) ); ?>" />
|
||||
<input id="product_length" placeholder="<?php _e( 'Length', 'woocommerce' ); ?>" class="input-text" size="6" type="number" name="_length" value="<?php echo esc_attr( get_post_meta( $thepostid, '_length', true ) ); ?>" step="any" min="0" />
|
||||
<input placeholder="<?php _e( 'Width', 'woocommerce' ); ?>" class="input-text" size="6" type="number" name="_width" value="<?php echo esc_attr( get_post_meta( $thepostid, '_width', true ) ); ?>" step="any" min="0" />
|
||||
<input placeholder="<?php _e( 'Height', 'woocommerce' ); ?>" class="input-text last" size="6" type="number" name="_height" value="<?php echo esc_attr( get_post_meta( $thepostid, '_height', true ) ); ?>" step="any" min="0" />
|
||||
</span>
|
||||
<span class="description"><?php _e( 'LxWxH in decimal form', 'woocommerce' ); ?></span>
|
||||
</p><?php
|
||||
|
@ -264,7 +294,7 @@ function woocommerce_product_data_box() {
|
|||
do_action( 'woocommerce_product_options_dimensions' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
|
||||
echo '<div class="options_group">';
|
||||
|
||||
// Shipping Class
|
||||
|
@ -283,7 +313,7 @@ function woocommerce_product_data_box() {
|
|||
?><p class="form-field dimensions_field"><label for="product_shipping_class"><?php _e( 'Shipping class', 'woocommerce' ); ?></label> <?php wp_dropdown_categories( $args ); ?> <span class="description"><?php _e( 'Shipping classes are used by certain shipping methods to group similar products.', 'woocommerce' ); ?></span></p><?php
|
||||
|
||||
do_action( 'woocommerce_product_options_shipping' );
|
||||
|
||||
|
||||
echo '</div>';
|
||||
?>
|
||||
|
||||
|
@ -314,7 +344,7 @@ function woocommerce_product_data_box() {
|
|||
if ( ! taxonomy_exists( $attribute_taxonomy_name ) ) continue;
|
||||
|
||||
// Get product data values for current taxonomy - this contains ordering and visibility data
|
||||
if ( isset( $attributes[ $attribute_taxonomy_name ] ) )
|
||||
if ( isset( $attributes[ $attribute_taxonomy_name ] ) )
|
||||
$attribute = $attributes[ $attribute_taxonomy_name ];
|
||||
|
||||
$position = empty( $attribute['position'] ) ? 0 : absint( $attribute['position'] );
|
||||
|
@ -457,10 +487,13 @@ function woocommerce_product_data_box() {
|
|||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
<button type="button" class="button save_attributes"><?php _e( 'Save attributes', 'woocommerce' ); ?></button>
|
||||
</p>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div id="related_product_data" class="panel woocommerce_options_panel">
|
||||
<div id="linked_product_data" class="panel woocommerce_options_panel">
|
||||
|
||||
<div class="options_group">
|
||||
|
||||
<p class="form-field"><label for="upsell_ids"><?php _e( 'Up-Sells', 'woocommerce' ); ?></label>
|
||||
<select id="upsell_ids" name="upsell_ids[]" class="ajax_chosen_select_products" multiple="multiple" data-placeholder="<?php _e( 'Search for a product…', 'woocommerce' ); ?>">
|
||||
|
@ -470,18 +503,18 @@ function woocommerce_product_data_box() {
|
|||
foreach ( $product_ids as $product_id ) {
|
||||
$title = get_the_title( $product_id );
|
||||
$sku = get_post_meta( $product_id, '_sku', true );
|
||||
|
||||
if ( ! $title )
|
||||
|
||||
if ( ! $title )
|
||||
continue;
|
||||
|
||||
if ( ! empty( $sku ) )
|
||||
|
||||
if ( ! empty( $sku ) )
|
||||
$sku = ' (SKU: ' . $sku . ')';
|
||||
|
||||
echo '<option value="' . esc_attr( $product_id ) . '" selected="selected">' . esc_html( $title . $sku ) . '</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select> <img class="help_tip" data-tip='<?php _e( 'Up-sells are products which you recommend instead of the currently viewed product, for example, products that are more profitable or better quality or more expensive.', 'woocommerce' ) ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" /></p>
|
||||
</select> <img class="help_tip" data-tip='<?php _e( 'Up-sells are products which you recommend instead of the currently viewed product, for example, products that are more profitable or better quality or more expensive.', 'woocommerce' ) ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" height="16" width="16" /></p>
|
||||
|
||||
<p class="form-field"><label for="crosssell_ids"><?php _e( 'Cross-Sells', 'woocommerce' ); ?></label>
|
||||
<select id="crosssell_ids" name="crosssell_ids[]" class="ajax_chosen_select_products" multiple="multiple" data-placeholder="<?php _e( 'Search for a product…', 'woocommerce' ); ?>">
|
||||
|
@ -491,41 +524,23 @@ function woocommerce_product_data_box() {
|
|||
foreach ( $product_ids as $product_id ) {
|
||||
$title = get_the_title( $product_id );
|
||||
$sku = get_post_meta( $product_id, '_sku', true );
|
||||
|
||||
if ( ! $title )
|
||||
|
||||
if ( ! $title )
|
||||
continue;
|
||||
|
||||
if ( ! empty( $sku ) )
|
||||
|
||||
if ( ! empty( $sku ) )
|
||||
$sku = ' (SKU: ' . $sku . ')';
|
||||
|
||||
echo '<option value="' . esc_attr( $product_id ) . '" selected="selected">' . esc_html( $title . $sku ) . '</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select> <img class="help_tip" data-tip='<?php _e( 'Cross-sells are products which you promote in the cart, based on the current product.', 'woocommerce' ) ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" /></p>
|
||||
</select> <img class="help_tip" data-tip='<?php _e( 'Cross-sells are products which you promote in the cart, based on the current product.', 'woocommerce' ) ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" height="16" width="16" /></p>
|
||||
|
||||
<?php do_action( 'woocommerce_product_options_related' ); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="advanced_product_data" class="panel woocommerce_options_panel">
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
echo '<div class="options_group hide_if_external">';
|
||||
|
||||
// Purchase note
|
||||
woocommerce_wp_textarea_input( array( 'id' => '_purchase_note', 'label' => __( 'Purchase Note', 'woocommerce' ), 'description' => __( 'Enter an optional note to send the customer after purchase.', 'woocommerce' ) ) );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="options_group">';
|
||||
|
||||
// menu_order
|
||||
woocommerce_wp_text_input( array( 'id' => 'menu_order', 'label' => __( 'Menu order', 'woocommerce' ), 'description' => __( 'Custom ordering position.', 'woocommerce' ), 'value' => intval( $post->menu_order ) ) );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="options_group grouping show_if_simple show_if_external">';
|
||||
|
||||
// List Grouped products
|
||||
|
@ -548,7 +563,7 @@ function woocommerce_product_data_box() {
|
|||
if ( $grouped_products ) {
|
||||
foreach ( $grouped_products as $product ) {
|
||||
|
||||
if ( $product->ID == $post->ID )
|
||||
if ( $product->ID == $post->ID )
|
||||
continue;
|
||||
|
||||
$post_parents[ $product->ID ] = $product->post_title;
|
||||
|
@ -556,20 +571,36 @@ function woocommerce_product_data_box() {
|
|||
}
|
||||
}
|
||||
|
||||
woocommerce_wp_select( array( 'id' => 'parent_id', 'label' => __( 'Grouping', 'woocommerce' ), 'value' => absint( $post->post_parent ), 'options' => $post_parents ) );
|
||||
|
||||
woocommerce_wp_select( array( 'id' => 'parent_id', 'label' => __( 'Grouping', 'woocommerce' ), 'value' => absint( $post->post_parent ), 'options' => $post_parents, 'desc_tip' => true, 'description' => __( 'Set this option to make this product part of a grouped product.', 'woocommerce' ) ) );
|
||||
|
||||
woocommerce_wp_hidden_input( array( 'id' => 'previous_parent_id', 'value' => absint( $post->post_parent ) ) );
|
||||
|
||||
do_action( 'woocommerce_product_options_grouping' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="options_group show_if_simple show_if_variable">';
|
||||
?>
|
||||
|
||||
// Individual product
|
||||
woocommerce_wp_checkbox( array( 'id' => '_sold_individually', 'wrapper_class' => 'show_if_simple show_if_variable', 'label' => __('Sold Individually', 'woocommerce'), 'description' => __('Enable this to only allow one of this item to be bought in a single order', 'woocommerce') ) );
|
||||
<?php do_action( 'woocommerce_product_options_related' ); ?>
|
||||
|
||||
do_action('woocommerce_product_options_sold_individually');
|
||||
</div>
|
||||
|
||||
<div id="advanced_product_data" class="panel woocommerce_options_panel">
|
||||
|
||||
<?php
|
||||
|
||||
echo '<div class="options_group hide_if_external">';
|
||||
|
||||
// Purchase note
|
||||
woocommerce_wp_textarea_input( array( 'id' => '_purchase_note', 'label' => __( 'Purchase Note', 'woocommerce' ), 'description' => __( 'Enter an optional note to send the customer after purchase.', 'woocommerce' ) ) );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="options_group">';
|
||||
|
||||
// menu_order
|
||||
woocommerce_wp_text_input( array( 'id' => 'menu_order', 'label' => __( 'Menu order', 'woocommerce' ), 'description' => __( 'Custom ordering position.', 'woocommerce' ), 'value' => intval( $post->menu_order ), 'type' => 'number', 'custom_attributes' => array(
|
||||
'step' => '1'
|
||||
) ) );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
|
@ -586,6 +617,8 @@ function woocommerce_product_data_box() {
|
|||
|
||||
<?php do_action( 'woocommerce_product_write_panels' ); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
@ -617,7 +650,7 @@ function woocommerce_process_product_meta( $post_id, $post ) {
|
|||
|
||||
// Set transient for product type
|
||||
set_transient( 'wc_product_type_' . $post_id, $product_type );
|
||||
|
||||
|
||||
// Update post meta
|
||||
update_post_meta( $post_id, '_regular_price', stripslashes( $_POST['_regular_price'] ) );
|
||||
update_post_meta( $post_id, '_sale_price', stripslashes( $_POST['_sale_price'] ) );
|
||||
|
@ -625,7 +658,7 @@ function woocommerce_process_product_meta( $post_id, $post ) {
|
|||
update_post_meta( $post_id, '_tax_class', stripslashes( $_POST['_tax_class'] ) );
|
||||
update_post_meta( $post_id, '_visibility', stripslashes( $_POST['_visibility'] ) );
|
||||
update_post_meta( $post_id, '_purchase_note', stripslashes( $_POST['_purchase_note'] ) );
|
||||
update_post_meta( $post_id, '_featured', isset( $_POST['_featured'] ) ? 'yes' : 'no' );
|
||||
update_post_meta( $post_id, '_featured', isset( $_POST['_featured'] ) ? 'yes' : 'no' );
|
||||
|
||||
// Dimensions
|
||||
if ( $is_virtual == 'no' ) {
|
||||
|
@ -676,20 +709,20 @@ function woocommerce_process_product_meta( $post_id, $post ) {
|
|||
if ( isset( $_POST['attribute_names'] ) ) {
|
||||
$attribute_names = $_POST['attribute_names'];
|
||||
$attribute_values = $_POST['attribute_values'];
|
||||
|
||||
if ( isset( $_POST['attribute_visibility'] ) )
|
||||
|
||||
if ( isset( $_POST['attribute_visibility'] ) )
|
||||
$attribute_visibility = $_POST['attribute_visibility'];
|
||||
|
||||
if ( isset( $_POST['attribute_variation'] ) )
|
||||
|
||||
if ( isset( $_POST['attribute_variation'] ) )
|
||||
$attribute_variation = $_POST['attribute_variation'];
|
||||
|
||||
|
||||
$attribute_is_taxonomy = $_POST['attribute_is_taxonomy'];
|
||||
$attribute_position = $_POST['attribute_position'];
|
||||
|
||||
$attribute_names_count = sizeof( $attribute_names );
|
||||
|
||||
for ( $i=0; $i < $attribute_names_count; $i++ ) {
|
||||
if ( ! $attribute_names[ $i ] )
|
||||
if ( ! $attribute_names[ $i ] )
|
||||
continue;
|
||||
|
||||
$is_visible = isset( $attribute_visibility[ $i ] ) ? 1 : 0;
|
||||
|
@ -767,17 +800,17 @@ function woocommerce_process_product_meta( $post_id, $post ) {
|
|||
update_post_meta( $post_id, '_product_attributes', $attributes );
|
||||
|
||||
// Sales and prices
|
||||
if ( in_array( $product_type, array( 'variable', 'grouped' ) ) ) {
|
||||
|
||||
if ( in_array( $product_type, array( 'variable', 'grouped' ) ) ) {
|
||||
|
||||
// Variable and grouped products have no prices
|
||||
update_post_meta( $post_id, '_regular_price', '' );
|
||||
update_post_meta( $post_id, '_sale_price', '' );
|
||||
update_post_meta( $post_id, '_sale_price_dates_from', '' );
|
||||
update_post_meta( $post_id, '_sale_price_dates_to', '' );
|
||||
update_post_meta( $post_id, '_price', '' );
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
$date_from = isset( $_POST['_sale_price_dates_from'] ) ? $_POST['_sale_price_dates_from'] : '';
|
||||
$date_to = isset( $_POST['_sale_price_dates_to'] ) ? $_POST['_sale_price_dates_to'] : '';
|
||||
|
||||
|
@ -801,7 +834,7 @@ function woocommerce_process_product_meta( $post_id, $post ) {
|
|||
else
|
||||
update_post_meta( $post_id, '_price', stripslashes( $_POST['_regular_price'] ) );
|
||||
|
||||
if ( $date_from && strtotime( $date_from ) < strtotime( 'NOW', current_time( 'timestamp' ) ) )
|
||||
if ( $_POST['_sale_price'] != '' && $date_from && strtotime( $date_from ) < strtotime( 'NOW', current_time( 'timestamp' ) ) )
|
||||
update_post_meta( $post_id, '_price', stripslashes($_POST['_sale_price']) );
|
||||
|
||||
if ( $date_to && strtotime( $date_to ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ) {
|
||||
|
@ -813,21 +846,21 @@ function woocommerce_process_product_meta( $post_id, $post ) {
|
|||
|
||||
// Update parent if grouped so price sorting works and stays in sync with the cheapest child
|
||||
if ( $post->post_parent > 0 || $product_type == 'grouped' || $_POST['previous_parent_id'] > 0 ) {
|
||||
|
||||
|
||||
$clear_parent_ids = array();
|
||||
|
||||
|
||||
if ( $post->post_parent > 0 )
|
||||
$clear_parent_ids[] = $post->post_parent;
|
||||
|
||||
|
||||
if ( $product_type == 'grouped' )
|
||||
$clear_parent_ids[] = $post_id;
|
||||
|
||||
|
||||
if ( $_POST['previous_parent_id'] > 0 )
|
||||
$clear_parent_ids[] = absint( $_POST['previous_parent_id'] );
|
||||
|
||||
if ( $clear_parent_ids ) {
|
||||
foreach( $clear_parent_ids as $clear_id ) {
|
||||
|
||||
|
||||
$children_by_price = get_posts( array(
|
||||
'post_parent' => $clear_id,
|
||||
'orderby' => 'meta_value_num',
|
||||
|
@ -843,7 +876,7 @@ function woocommerce_process_product_meta( $post_id, $post ) {
|
|||
update_post_meta( $clear_id, '_price', $child_price );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Clear cache/transients
|
||||
$woocommerce->clear_product_transients( $clear_id );
|
||||
}
|
||||
|
@ -856,7 +889,7 @@ function woocommerce_process_product_meta( $post_id, $post ) {
|
|||
} else {
|
||||
update_post_meta( $post_id, '_sold_individually', '' );
|
||||
}
|
||||
|
||||
|
||||
// Stock Data
|
||||
if ( get_option('woocommerce_manage_stock') == 'yes' ) {
|
||||
|
||||
|
@ -907,7 +940,7 @@ function woocommerce_process_product_meta( $post_id, $post ) {
|
|||
$upsells = array();
|
||||
$ids = $_POST['upsell_ids'];
|
||||
foreach ( $ids as $id )
|
||||
if ( $id && $id > 0 )
|
||||
if ( $id && $id > 0 )
|
||||
$upsells[] = $id;
|
||||
|
||||
update_post_meta( $post_id, '_upsell_ids', $upsells );
|
||||
|
@ -920,9 +953,9 @@ function woocommerce_process_product_meta( $post_id, $post ) {
|
|||
$crosssells = array();
|
||||
$ids = $_POST['crosssell_ids'];
|
||||
foreach ( $ids as $id )
|
||||
if ( $id && $id > 0 )
|
||||
if ( $id && $id > 0 )
|
||||
$crosssells[] = $id;
|
||||
|
||||
|
||||
update_post_meta( $post_id, '_crosssell_ids', $crosssells );
|
||||
} else {
|
||||
delete_post_meta( $post_id, '_crosssell_ids' );
|
||||
|
@ -932,11 +965,11 @@ function woocommerce_process_product_meta( $post_id, $post ) {
|
|||
if ( $is_downloadable == 'yes' ) {
|
||||
|
||||
$_download_limit = absint( $_POST['_download_limit'] );
|
||||
if ( ! $_download_limit )
|
||||
if ( ! $_download_limit )
|
||||
$_download_limit = ''; // 0 or blank = unlimited
|
||||
|
||||
$_download_expiry = absint( $_POST['_download_expiry'] );
|
||||
if ( ! $_download_expiry )
|
||||
if ( ! $_download_expiry )
|
||||
$_download_expiry = ''; // 0 or blank = unlimited
|
||||
|
||||
// file paths will be stored in an array keyed off md5(file path)
|
||||
|
@ -958,17 +991,17 @@ function woocommerce_process_product_meta( $post_id, $post ) {
|
|||
|
||||
update_post_meta( $post_id, '_file_paths', $_file_paths );
|
||||
}
|
||||
if ( isset( $_POST['_download_limit'] ) )
|
||||
if ( isset( $_POST['_download_limit'] ) )
|
||||
update_post_meta( $post_id, '_download_limit', esc_attr( $_download_limit ) );
|
||||
if ( isset( $_POST['_download_expiry'] ) )
|
||||
if ( isset( $_POST['_download_expiry'] ) )
|
||||
update_post_meta( $post_id, '_download_expiry', esc_attr( $_download_expiry ) );
|
||||
}
|
||||
|
||||
// Product url
|
||||
if ( $product_type == 'external' ) {
|
||||
if ( isset( $_POST['_product_url'] ) && $_POST['_product_url'] )
|
||||
if ( isset( $_POST['_product_url'] ) && $_POST['_product_url'] )
|
||||
update_post_meta( $post_id, '_product_url', esc_attr( $_POST['_product_url'] ) );
|
||||
if ( isset( $_POST['_button_text'] ) && $_POST['_button_text'] )
|
||||
if ( isset( $_POST['_button_text'] ) && $_POST['_button_text'] )
|
||||
update_post_meta( $post_id, '_button_text', esc_attr( $_POST['_button_text'] ) );
|
||||
}
|
||||
|
||||
|
@ -991,12 +1024,12 @@ add_action('woocommerce_process_product_meta', 'woocommerce_process_product_meta
|
|||
* @return void
|
||||
*/
|
||||
function woocommerce_change_insert_into_post( $translation, $original ) {
|
||||
if ( ! isset( $_REQUEST['from'] ) )
|
||||
if ( ! isset( $_REQUEST['from'] ) )
|
||||
return $translation;
|
||||
|
||||
$original = strtolower( $original );
|
||||
|
||||
if ( $_REQUEST['from'] == 'wc01' && ( $original == 'insert into post' || $original == 'use this image' ) )
|
||||
if ( $_REQUEST['from'] == 'wc01' && ( $original == 'insert into post' || $original == 'use this image' ) )
|
||||
return __( 'Use this file', 'woocommerce' );
|
||||
|
||||
return $translation;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/WritePanels
|
||||
* @version 1.7.0
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -23,30 +23,30 @@ function woocommerce_product_images_box() {
|
|||
?>
|
||||
<div id="product_images_container">
|
||||
<ul class="product_images">
|
||||
<?php
|
||||
<?php
|
||||
$thumbnail_id = get_post_thumbnail_id( $post->ID );
|
||||
|
||||
|
||||
if ( $thumbnail_id )
|
||||
echo '<li class="image" data-post_id="' . $thumbnail_id . '">
|
||||
' . wp_get_attachment_image( $thumbnail_id, 'full' ) . '
|
||||
<span class="loading"></span>
|
||||
<span class="loading"></span>
|
||||
<ul class="actions">
|
||||
<li><a href="#" class="delete">' . __( 'Delete', 'woocommerce' ) . '</a></li>
|
||||
<li><a href="' . admin_url( 'media-upload.php?post_id=' . $post->ID . '&attachment_id=' . $thumbnail_id . '&tab=library&width=640&height=553&TB_iframe=1' ) . '" class="view thickbox" onclick="return false;">' . __( 'View', 'woocommerce' ) . '</a></li>
|
||||
</ul>
|
||||
</li>';
|
||||
|
||||
$attachments =& get_children( 'post_parent=' . $post->ID . '&numberposts=-1&post_type=attachment&orderby=menu_order&order=ASC&post_mime_type=image' );
|
||||
|
||||
|
||||
$attachments =& get_children( 'post_parent=' . $post->ID . '&numberposts=-1&post_type=attachment&orderby=menu_order&order=ASC&post_mime_type=image' );
|
||||
|
||||
foreach ( $attachments as $attachment_id => $attachment ) {
|
||||
if ( $thumbnail_id == $attachment_id )
|
||||
continue;
|
||||
|
||||
|
||||
$exclude_class = get_post_meta( $attachment_id, '_woocommerce_exclude_image', true ) == 1 ? 'excluded' : '';
|
||||
|
||||
echo '<li class="image ' . $exclude_class . '" data-post_id="' . $attachment_id . '">
|
||||
' . wp_get_attachment_image( $attachment_id, 'full' ) . '
|
||||
<span class="loading"></span>
|
||||
<span class="loading"></span>
|
||||
<ul class="actions">
|
||||
<li><a href="#" class="delete">' . __( 'Delete', 'woocommerce' ) . '</a></li>
|
||||
<li><a href="' . admin_url( 'media-upload.php?post_id=' . $post->ID . '&attachment_id=' . $attachment_id . '&tab=library&width=640&height=553&TB_iframe=1' ) . '" class="view thickbox" onclick="return false;">' . __( 'View', 'woocommerce' ) . '</a></li>
|
||||
|
@ -56,14 +56,14 @@ function woocommerce_product_images_box() {
|
|||
?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Uploader section -->
|
||||
<div id="plupload-upload-ui" class="hide-if-no-js">
|
||||
<div id="drag-drop-area">
|
||||
<p class="drag-drop-info"><?php _e('Drop files here'); ?></p>
|
||||
<p><?php _ex('or', 'Uploader: Drop files here - or - Select Files'); ?></p>
|
||||
<p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e('Select Files'); ?>" class="button" /></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
// Drag and drop code adapted from Drag & Drop Featured Image by Jonathan Lundström
|
||||
|
@ -72,7 +72,7 @@ function woocommerce_product_images_box() {
|
|||
'browse_button' => 'plupload-browse-button',
|
||||
'container' => 'plupload-upload-ui',
|
||||
'drop_element' => 'drag-drop-area',
|
||||
'file_data_name' => 'async-upload',
|
||||
'file_data_name' => 'async-upload',
|
||||
'multiple_queues' => true,
|
||||
'max_file_size' => wp_max_upload_size() . 'b',
|
||||
'url' => admin_url('admin-ajax.php'),
|
||||
|
@ -89,11 +89,11 @@ function woocommerce_product_images_box() {
|
|||
);
|
||||
|
||||
// Apply filters to initiate plupload:
|
||||
$plupload_init = apply_filters( 'plupload_init', $plupload_init );
|
||||
$plupload_init = apply_filters( 'plupload_init', $plupload_init );
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
|
||||
|
||||
function product_images_container_init() {
|
||||
// Attribute ordering
|
||||
$('#product_images_container ul.product_images').sortable({
|
||||
|
@ -111,27 +111,27 @@ function woocommerce_product_images_box() {
|
|||
stop:function(event,ui){
|
||||
ui.item.removeAttr('style');
|
||||
},
|
||||
update: function(event, ui) {
|
||||
update: function(event, ui) {
|
||||
$('#product_images_container ul li.image').css('cursor','default');
|
||||
$('#product_images_container ul.product_images').sortable('disable');
|
||||
|
||||
|
||||
var post_id = <?php echo $post->ID; ?>;
|
||||
var attachment_id = ui.item.attr( 'data-post_id' );
|
||||
var prev_attachment_id = ui.item.prev().attr( 'data-post_id' );
|
||||
var next_attachment_id = ui.item.next().attr( 'data-post_id' );
|
||||
|
||||
var next_attachment_id = ui.item.next().attr( 'data-post_id' );
|
||||
|
||||
// show spinner
|
||||
ui.item.addClass('loading');
|
||||
|
||||
|
||||
// go do the sorting stuff via ajax
|
||||
jQuery.post( ajaxurl, {
|
||||
action: 'woocommerce_product_image_ordering',
|
||||
post_id: post_id,
|
||||
attachment_id: attachment_id,
|
||||
prev_attachment_id: prev_attachment_id,
|
||||
jQuery.post( ajaxurl, {
|
||||
action: 'woocommerce_product_image_ordering',
|
||||
post_id: post_id,
|
||||
attachment_id: attachment_id,
|
||||
prev_attachment_id: prev_attachment_id,
|
||||
next_attachment_id: next_attachment_id,
|
||||
_ajax_nonce: '<?php echo wp_create_nonce( 'product-image-ordering' ); ?>'
|
||||
}, function( response ) {
|
||||
}, function( response ) {
|
||||
ui.item.removeClass('loading');
|
||||
$('#product_images_container ul li.image').css('cursor','move');
|
||||
$('#product_images_container ul.product_images').sortable('enable');
|
||||
|
@ -140,51 +140,51 @@ function woocommerce_product_images_box() {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
product_images_container_init();
|
||||
|
||||
|
||||
// Delete images
|
||||
$('#product_images_container').on( 'click', 'a.delete', function() {
|
||||
|
||||
|
||||
$image = $(this).closest('li.image');
|
||||
|
||||
|
||||
var attachment_id = $image.attr('data-post_id');
|
||||
|
||||
|
||||
if ( attachment_id ) {
|
||||
|
||||
|
||||
$image.addClass('loading');
|
||||
|
||||
|
||||
var answer = confirm('<?php _e( 'Are you sure you want to remove this attachment?', 'woocommerce' ); ?>');
|
||||
|
||||
|
||||
if ( answer ) {
|
||||
jQuery.post( ajaxurl, {
|
||||
action: 'woocommerce_product_image_delete',
|
||||
jQuery.post( ajaxurl, {
|
||||
action: 'woocommerce_product_image_delete',
|
||||
post_id: <?php echo $post->ID; ?>,
|
||||
attachment_id: attachment_id,
|
||||
attachment_id: attachment_id,
|
||||
_ajax_nonce: '<?php echo wp_create_nonce( 'product-image-delete' ); ?>'
|
||||
}, function( response ) {
|
||||
}, function( response ) {
|
||||
$image.remove();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
|
||||
|
||||
$image.removeClass('loading');
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
||||
|
||||
|
||||
|
||||
// Drag and drop uploading of images
|
||||
var uploader = new plupload.Uploader(<?php echo json_encode( $plupload_init ); ?>);
|
||||
|
||||
// Check for drag'n'drop functionality:
|
||||
uploader.bind('Init', function(up){
|
||||
var uploaddiv = $('#plupload-upload-ui');
|
||||
|
||||
|
||||
// Add classes and bind actions:
|
||||
if(up.features.dragdrop){
|
||||
uploaddiv.addClass('drag-drop');
|
||||
|
@ -200,11 +200,11 @@ function woocommerce_product_images_box() {
|
|||
|
||||
// Initiate uploading script:
|
||||
uploader.init();
|
||||
|
||||
|
||||
// File queue handler
|
||||
uploader.bind('FilesAdded', function(up, files){
|
||||
var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10);
|
||||
|
||||
|
||||
// Loop through files:
|
||||
plupload.each(files, function(file){
|
||||
if ( max > hundredmb && file.size > hundredmb && up.runtime != 'html5' ) {
|
||||
|
@ -215,22 +215,22 @@ function woocommerce_product_images_box() {
|
|||
// Refresh and start:
|
||||
up.refresh();
|
||||
up.start();
|
||||
|
||||
|
||||
// Block the UI
|
||||
$('#product_images_container').block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_writepanel_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
|
||||
});
|
||||
|
||||
|
||||
// Handle new uploads
|
||||
uploader.bind( 'FileUploaded', function( up, file, response ) {
|
||||
|
||||
response = $.parseJSON( response.response );
|
||||
|
||||
if ( response.error ) {
|
||||
|
||||
|
||||
alert( response.error );
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
$('#product_images_container ul').append('<li class="image" data-post_id="' + response.post_id + '">\
|
||||
<img src="' + response.src + '" />\
|
||||
<span class="loading"></span>\
|
||||
|
@ -239,46 +239,46 @@ function woocommerce_product_images_box() {
|
|||
<li><a href="' + response.edit_url + '" class="view thickbox" onclick="return false;"><?php _e( 'View', 'woocommerce' ) ?></a></li>\
|
||||
</ul>\
|
||||
</li>');
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$('#product_images_container').unblock();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// Refresh images when a thickbox (images) closes
|
||||
var loading_product_images = false;
|
||||
|
||||
|
||||
jQuery(document).bind( 'tb_unload', function() {
|
||||
if ( loading_product_images )
|
||||
return;
|
||||
|
||||
|
||||
loading_product_images = true;
|
||||
|
||||
|
||||
// Block
|
||||
$('#product_images_container').block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_writepanel_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
|
||||
|
||||
|
||||
// Re-load images
|
||||
jQuery.post( ajaxurl, {
|
||||
action: 'woocommerce_product_image_refresh',
|
||||
post_id: <?php echo $post->ID; ?>,
|
||||
jQuery.post( ajaxurl, {
|
||||
action: 'woocommerce_product_image_refresh',
|
||||
post_id: <?php echo $post->ID; ?>,
|
||||
_ajax_nonce: '<?php echo wp_create_nonce( 'product-image-refresh' ); ?>'
|
||||
}, function( response ) {
|
||||
}, function( response ) {
|
||||
if ( response ) {
|
||||
$("#product_images_container").html(response);
|
||||
}
|
||||
|
||||
|
||||
// Re-init
|
||||
product_images_container_init();
|
||||
|
||||
|
||||
// Unblock
|
||||
$('#product_images_container').unblock();
|
||||
|
||||
|
||||
loading_product_images = false;
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/WritePanels
|
||||
* @version 1.7.0
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/** Product data writepanel */
|
||||
|
@ -49,7 +49,7 @@ function woocommerce_meta_boxes() {
|
|||
remove_meta_box( 'product_shipping_classdiv', 'product', 'side' );
|
||||
remove_meta_box( 'pageparentdiv', 'product', 'side' );
|
||||
remove_meta_box( 'postimagediv', 'product', 'side' );
|
||||
|
||||
|
||||
// Excerpt
|
||||
if ( function_exists('wp_editor') ) {
|
||||
remove_meta_box( 'postexcerpt', 'product', 'normal' );
|
||||
|
@ -133,6 +133,22 @@ function woocommerce_meta_boxes_save( $post_id, $post ) {
|
|||
add_action( 'save_post', 'woocommerce_meta_boxes_save', 1, 2 );
|
||||
|
||||
|
||||
/**
|
||||
* Some functions, like the term recount, require the visibility to be set prior. Lets save that here.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $post_id
|
||||
* @return void
|
||||
*/
|
||||
function woocommerce_pre_post_update( $post_id ) {
|
||||
if ( isset( $_POST['_visibility'] ) )
|
||||
update_post_meta( $post_id, '_visibility', stripslashes( $_POST['_visibility'] ) );
|
||||
if ( isset( $_POST['_stock_status'] ) )
|
||||
update_post_meta( $post_id, '_stock_status', stripslashes( $_POST['_stock_status'] ) );
|
||||
}
|
||||
add_action( 'pre_post_update', 'woocommerce_pre_post_update' );
|
||||
|
||||
|
||||
/**
|
||||
* Product Short Description.
|
||||
*
|
||||
|
@ -223,9 +239,9 @@ add_filter('wp_insert_post_data', 'woocommerce_order_data');
|
|||
|
||||
|
||||
/**
|
||||
* Grant downloadable file access to any newly added files on any existing
|
||||
* Grant downloadable file access to any newly added files on any existing
|
||||
* orders for this product that have previously been granted downloadable file access
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param int $product_id product identifier
|
||||
* @param int $variation_id optional product variation identifier
|
||||
|
@ -234,7 +250,7 @@ add_filter('wp_insert_post_data', 'woocommerce_order_data');
|
|||
function woocommerce_process_product_file_download_paths( $product_id, $variation_id, $file_paths ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( $variation_id )
|
||||
if ( $variation_id )
|
||||
$product_id = $variation_id;
|
||||
|
||||
// determine whether any new files have been added
|
||||
|
@ -248,10 +264,10 @@ function woocommerce_process_product_file_download_paths( $product_id, $variatio
|
|||
foreach ( $existing_permissions as $existing_permission ) {
|
||||
$order = new WC_Order( $existing_permission->order_id );
|
||||
|
||||
if ( $order->id ) {
|
||||
if ( $order->id ) {
|
||||
foreach ( $new_download_ids as $new_download_id ) {
|
||||
// grant permission if it doesn't already exist
|
||||
if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT true FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE order_id = %d AND product_id = %d AND download_id = %s", $order->id, $product_id, $new_download_id ) ) ) {
|
||||
if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT true FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE order_id = %d AND product_id = %d AND download_id = %s", $order->id, $product_id, $new_download_id ) ) ) {
|
||||
woocommerce_downloadable_file_permission( $new_download_id, $product_id, $order );
|
||||
}
|
||||
}
|
||||
|
@ -313,19 +329,28 @@ add_action( 'admin_notices', 'woocommerce_meta_boxes_show_errors' );
|
|||
*/
|
||||
function woocommerce_wp_text_input( $field ) {
|
||||
global $thepostid, $post, $woocommerce;
|
||||
|
||||
|
||||
$thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
|
||||
$field['placeholder'] = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
|
||||
$field['class'] = isset( $field['class'] ) ? $field['class'] : 'short';
|
||||
$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
|
||||
$field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
|
||||
$field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
|
||||
$field['type'] = isset( $field['type'] ) ? $field['type'] : 'text';
|
||||
|
||||
echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><input type="text" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['value'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" /> ';
|
||||
// Custom attribute handling
|
||||
$custom_attributes = array();
|
||||
|
||||
if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) )
|
||||
foreach ( $field['custom_attributes'] as $attribute => $value )
|
||||
$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
|
||||
|
||||
echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><input type="' . esc_attr( $field['type'] ) . '" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['value'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" ' . implode( ' ', $custom_attributes ) . ' /> ';
|
||||
|
||||
if ( ! empty( $field['description'] ) ) {
|
||||
|
||||
if ( isset( $field['desc_tip'] ) ) {
|
||||
echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" />';
|
||||
echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" height="16" width="16" />';
|
||||
} else {
|
||||
echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
|
||||
}
|
||||
|
@ -344,11 +369,11 @@ function woocommerce_wp_text_input( $field ) {
|
|||
*/
|
||||
function woocommerce_wp_hidden_input( $field ) {
|
||||
global $thepostid, $post;
|
||||
|
||||
|
||||
$thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
|
||||
$field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
|
||||
$field['class'] = isset( $field['class'] ) ? $field['class'] : '';
|
||||
|
||||
|
||||
echo '<input type="hidden" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['value'] ) . '" /> ';
|
||||
}
|
||||
|
||||
|
@ -366,14 +391,15 @@ function woocommerce_wp_textarea_input( $field ) {
|
|||
$thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
|
||||
$field['placeholder'] = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
|
||||
$field['class'] = isset( $field['class'] ) ? $field['class'] : 'short';
|
||||
$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
|
||||
$field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
|
||||
|
||||
echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><textarea class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" rows="2" cols="20">' . esc_textarea( $field['value'] ) . '</textarea> ';
|
||||
echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><textarea class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" rows="2" cols="20">' . esc_textarea( $field['value'] ) . '</textarea> ';
|
||||
|
||||
if ( ! empty( $field['description'] ) ) {
|
||||
|
||||
if ( isset( $field['desc_tip'] ) ) {
|
||||
echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" />';
|
||||
echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" height="16" width="16" />';
|
||||
} else {
|
||||
echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
|
||||
}
|
||||
|
@ -419,9 +445,10 @@ function woocommerce_wp_select( $field ) {
|
|||
|
||||
$thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
|
||||
$field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short';
|
||||
$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
|
||||
$field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
|
||||
|
||||
echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><select id="' . esc_attr( $field['id'] ) . '" name="' . esc_attr( $field['id'] ) . '" class="' . esc_attr( $field['class'] ) . '">';
|
||||
echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><select id="' . esc_attr( $field['id'] ) . '" name="' . esc_attr( $field['id'] ) . '" class="' . esc_attr( $field['class'] ) . '">';
|
||||
|
||||
foreach ( $field['options'] as $key => $value ) {
|
||||
|
||||
|
@ -434,11 +461,46 @@ function woocommerce_wp_select( $field ) {
|
|||
if ( ! empty( $field['description'] ) ) {
|
||||
|
||||
if ( isset( $field['desc_tip'] ) ) {
|
||||
echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" />';
|
||||
echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" height="16" width="16" />';
|
||||
} else {
|
||||
echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
|
||||
}
|
||||
|
||||
}
|
||||
echo '</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a radio input box.
|
||||
*
|
||||
* @access public
|
||||
* @param array $field
|
||||
* @return void
|
||||
*/
|
||||
function woocommerce_wp_radio( $field ) {
|
||||
global $thepostid, $post, $woocommerce;
|
||||
|
||||
$thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
|
||||
$field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short';
|
||||
$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
|
||||
$field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
|
||||
|
||||
echo '<fieldset class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><legend>' . wp_kses_post( $field['label'] ) . '</legend><ul>';
|
||||
|
||||
if ( ! empty( $field['description'] ) ) {
|
||||
echo '<li class="description">' . wp_kses_post( $field['description'] ) . '</li>';
|
||||
}
|
||||
|
||||
foreach ( $field['options'] as $key => $value ) {
|
||||
|
||||
echo '<li><label><input
|
||||
name="' . esc_attr( $field['id'] ) . '"
|
||||
value="' . esc_attr( $key ) . '"
|
||||
type="radio"
|
||||
class="' . esc_attr( $field['class'] ) . '"
|
||||
' . checked( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '
|
||||
/> ' . esc_html( $value ) . '</label>
|
||||
</li>';
|
||||
}
|
||||
echo '</ul></fieldset>';
|
||||
}
|
|
@ -82,7 +82,7 @@ add_action( 'woocommerce_admin_field_frontend_styles', 'woocommerce_frontend_sty
|
|||
function woocommerce_frontend_css_color_picker( $name, $id, $value, $desc = '' ) {
|
||||
global $woocommerce;
|
||||
|
||||
echo '<div class="color_box"><strong><img class="help_tip" data-tip="' . esc_attr( $desc ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" /> ' . esc_html( $name ) . '</strong>
|
||||
echo '<div class="color_box"><strong><img class="help_tip" data-tip="' . esc_attr( $desc ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" height="16" width="16" /> ' . esc_html( $name ) . '</strong>
|
||||
<input name="' . esc_attr( $id ). '" id="' . esc_attr( $id ) . '" type="text" value="' . esc_attr( $value ) . '" class="colorpick" /> <div id="colorPickerDiv_' . esc_attr( $id ) . '" class="colorpickdiv"></div>
|
||||
</div>';
|
||||
|
||||
|
|
|
@ -47,9 +47,9 @@ function woocommerce_payment_gateways_setting() {
|
|||
<td>';
|
||||
|
||||
if ( $gateway->enabled == 'yes' )
|
||||
echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/success.png" alt="yes" />';
|
||||
echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/success.png" width="16" height="14" alt="yes" />';
|
||||
else
|
||||
echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/success-off.png" alt="no" />';
|
||||
echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/success-off.png" width="16" height="14" alt="no" />';
|
||||
|
||||
echo '</td>
|
||||
</tr>';
|
||||
|
|
|
@ -21,227 +21,161 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
*/
|
||||
function woocommerce_update_options( $options ) {
|
||||
|
||||
if ( empty( $_POST ) )
|
||||
if ( empty( $_POST ) )
|
||||
return false;
|
||||
|
||||
// Options to update will be stored here
|
||||
$update_options = array();
|
||||
|
||||
// Loop options and get values to save
|
||||
foreach ( $options as $value ) {
|
||||
|
||||
|
||||
if ( ! isset( $value['id'] ) )
|
||||
continue;
|
||||
|
||||
|
||||
$type = isset( $value['type'] ) ? sanitize_title( $value['type'] ) : '';
|
||||
|
||||
|
||||
// Get the option name
|
||||
$option_value = null;
|
||||
|
||||
switch ( $type ) {
|
||||
|
||||
|
||||
// Standard types
|
||||
case "checkbox" :
|
||||
|
||||
|
||||
if ( isset( $_POST[$value['id']] ) ) {
|
||||
update_option( $value['id'], 'yes' );
|
||||
$option_value = 'yes';
|
||||
} else {
|
||||
update_option( $value['id'], 'no' );
|
||||
$option_value = 'no';
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case "textarea" :
|
||||
|
||||
|
||||
if ( isset( $_POST[$value['id']] ) ) {
|
||||
update_option( $value['id'], wp_kses_post( $_POST[ $value['id'] ] ) );
|
||||
$option_value = wp_kses_post( $_POST[ $value['id'] ] );
|
||||
} else {
|
||||
delete_option( $value['id'] );
|
||||
$option_value = '';
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case "text" :
|
||||
case 'email':
|
||||
case 'number':
|
||||
case "select" :
|
||||
case "color" :
|
||||
case "single_select_page" :
|
||||
case "single_select_country" :
|
||||
|
||||
case 'radio' :
|
||||
|
||||
if ( $value['id'] == 'woocommerce_price_thousand_sep' || $value['id'] == 'woocommerce_price_decimal_sep' ) {
|
||||
|
||||
// price separators get a special treatment as they should allow a spaces (don't trim)
|
||||
if ( isset( $_POST[ $value['id'] ] ) ) {
|
||||
update_option( $value['id'], esc_attr( $_POST[ $value['id'] ] ) );
|
||||
$option_value = esc_attr( $_POST[ $value['id'] ] );
|
||||
} else {
|
||||
delete_option( $value['id'] );
|
||||
$option_value = '';
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ( isset( $_POST[$value['id']] ) ) {
|
||||
update_option( $value['id'], woocommerce_clean( $_POST[ $value['id'] ] ) );
|
||||
} else {
|
||||
delete_option( $value['id'] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// Special types
|
||||
case "tax_rates" :
|
||||
|
||||
// Tax rates saving
|
||||
$tax_rates = array();
|
||||
$tax_classes = isset( $_POST['tax_class'] ) ? $_POST['tax_class'] : array();
|
||||
$tax_countries = isset( $_POST['tax_country'] ) ? $_POST['tax_country'] : array();
|
||||
$tax_rate = isset( $_POST['tax_rate'] ) ? $_POST['tax_rate'] : array();
|
||||
$tax_shipping = isset( $_POST['tax_shipping'] ) ? $_POST['tax_shipping'] : array();
|
||||
$tax_postcode = isset( $_POST['tax_postcode'] ) ? $_POST['tax_postcode'] : array();
|
||||
$tax_compound = isset( $_POST['tax_compound'] ) ? $_POST['tax_compound'] : array();
|
||||
$tax_label = isset( $_POST['tax_label'] ) ? $_POST['tax_label'] : array();
|
||||
$tax_classes_count = sizeof( $tax_classes );
|
||||
|
||||
for ( $i = 0; $i < $tax_classes_count; $i ++ ) {
|
||||
|
||||
if ( isset( $tax_classes[ $i ] ) && isset( $tax_countries[ $i ] ) && isset( $tax_rate[ $i ] ) && is_numeric( $tax_rate[ $i ] ) ) {
|
||||
|
||||
$rate = woocommerce_clean( $tax_rate[ $i ] );
|
||||
$rate = number_format( $rate, 4, '.', '' );
|
||||
|
||||
$class = woocommerce_clean( $tax_classes[ $i ] );
|
||||
|
||||
$shipping = empty( $tax_shipping[ $i ] ) ? 'no' : 'yes';
|
||||
$compound = empty( $tax_compound[ $i ] ) ? 'no' : 'yes';
|
||||
|
||||
// Handle countries
|
||||
$counties_array = array();
|
||||
$countries = $tax_countries[ $i ];
|
||||
if ( $countries ) foreach ( $countries as $country ) {
|
||||
|
||||
$country = woocommerce_clean( $country );
|
||||
$state = '*';
|
||||
|
||||
if ( strstr( $country, ':' ) ) {
|
||||
$cr = explode( ':', $country );
|
||||
$country = current( $cr );
|
||||
$state = end( $cr );
|
||||
}
|
||||
|
||||
$counties_array[ woocommerce_clean( $country ) ][] = woocommerce_clean( $state );
|
||||
}
|
||||
|
||||
$tax_rates[] = array(
|
||||
'countries' => $counties_array,
|
||||
'rate' => $rate,
|
||||
'shipping' => $shipping,
|
||||
'compound' => $compound,
|
||||
'class' => $class,
|
||||
'label' => woocommerce_clean( $tax_label[ $i ] )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'woocommerce_tax_rates', $tax_rates );
|
||||
|
||||
// Local tax rates saving
|
||||
$local_tax_rates = array();
|
||||
$tax_classes = isset( $_POST['local_tax_class'] ) ? $_POST['local_tax_class'] : array();
|
||||
$tax_countries = isset( $_POST['local_tax_country'] ) ? $_POST['local_tax_country'] : array();
|
||||
$tax_location_type = isset( $_POST['local_tax_location_type'] ) ? $_POST['local_tax_location_type'] : 'postcode';
|
||||
$tax_location = isset( $_POST['local_tax_location'] ) ? $_POST['local_tax_location'] : array();
|
||||
$tax_rate = isset( $_POST['local_tax_rate'] ) ? $_POST['local_tax_rate'] : array();
|
||||
$tax_shipping = isset( $_POST['local_tax_shipping'] ) ? $_POST['local_tax_shipping'] : array();
|
||||
$tax_postcode = isset( $_POST['local_tax_postcode'] ) ? $_POST['local_tax_postcode'] : array();
|
||||
$tax_compound = isset( $_POST['local_tax_compound'] ) ? $_POST['local_tax_compound'] : array();
|
||||
$tax_label = isset( $_POST['local_tax_label'] ) ? $_POST['local_tax_label'] : array();
|
||||
$tax_classes_count = sizeof( $tax_classes );
|
||||
for ( $i = 0; $i < $tax_classes_count; $i ++ ) {
|
||||
|
||||
if ( isset( $tax_classes[ $i ] ) && isset( $tax_countries[ $i ] ) && isset( $tax_rate[ $i ] ) && is_numeric( $tax_rate[ $i ] ) ) {
|
||||
|
||||
$rate = woocommerce_clean( $tax_rate[ $i ] );
|
||||
$rate = number_format( $rate, 4, '.', '' );
|
||||
|
||||
$class = woocommerce_clean( $tax_classes[ $i ] );
|
||||
|
||||
if ( ! empty( $tax_shipping[ $i ] ) ) $shipping = 'yes'; else $shipping = 'no';
|
||||
if ( ! empty( $tax_compound[ $i ] ) ) $compound = 'yes'; else $compound = 'no';
|
||||
|
||||
// Handle country
|
||||
$country = woocommerce_clean( $tax_countries[ $i ] );
|
||||
$state = '*';
|
||||
|
||||
if ( strstr( $country, ':' ) ) {
|
||||
$cr = explode( ':', $country );
|
||||
$country = current( $cr );
|
||||
$state = end( $cr );
|
||||
}
|
||||
|
||||
// Handle postcodes/cities
|
||||
$location_type = $tax_location_type[ $i ] == 'city' ? 'city' : 'postcode';
|
||||
$locations = explode( "\n", $tax_location[ $i ] );
|
||||
$locations = array_filter( array_map( 'woocommerce_clean', $locations ) );
|
||||
|
||||
if ( $location_type == 'city' ) {
|
||||
$locations = array_map( 'sanitize_title', $locations );
|
||||
}
|
||||
|
||||
$local_tax_rates[] = array(
|
||||
'country' => $country,
|
||||
'state' => $state,
|
||||
'location_type' => $location_type,
|
||||
'locations' => $locations,
|
||||
'rate' => $rate,
|
||||
'shipping' => $shipping,
|
||||
'compound' => $compound,
|
||||
'class' => $class,
|
||||
'label' => woocommerce_clean( $tax_label[ $i ] )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'woocommerce_local_tax_rates', $local_tax_rates );
|
||||
|
||||
} elseif ( $value['id'] == 'woocommerce_price_num_decimals' ) {
|
||||
|
||||
// price separators get a special treatment as they should allow a spaces (don't trim)
|
||||
if ( isset( $_POST[ $value['id'] ] ) ) {
|
||||
$option_value = absint( esc_attr( $_POST[ $value['id'] ] ) );
|
||||
} else {
|
||||
$option_value = 2;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ( isset( $_POST[$value['id']] ) ) {
|
||||
$option_value = woocommerce_clean( $_POST[ $value['id'] ] );
|
||||
} else {
|
||||
$option_value = '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
// Special types
|
||||
case "multi_select_countries" :
|
||||
|
||||
|
||||
// Get countries array
|
||||
if ( isset( $_POST[ $value['id'] ] ) )
|
||||
$selected_countries = array_map( 'woocommerce_clean', (array) $_POST[ $value['id'] ] );
|
||||
else
|
||||
if ( isset( $_POST[ $value['id'] ] ) )
|
||||
$selected_countries = array_map( 'woocommerce_clean', (array) $_POST[ $value['id'] ] );
|
||||
else
|
||||
$selected_countries = array();
|
||||
|
||||
update_option( $value['id'], $selected_countries );
|
||||
|
||||
|
||||
$option_value = $selected_countries;
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case "image_width" :
|
||||
|
||||
if ( isset( $_POST[$value['id'] . '_width'] ) ) {
|
||||
|
||||
update_option( $value['id'] . '_width', woocommerce_clean( $_POST[ $value['id'] . '_width'] ) );
|
||||
update_option( $value['id'] . '_height', woocommerce_clean( $_POST[ $value['id'] . '_height'] ) );
|
||||
|
||||
if ( isset( $_POST[ $value['id'] . '_crop'] ) )
|
||||
update_option( $value['id'] . '_crop', 1 );
|
||||
if ( isset( $_POST[$value['id'] ]['width'] ) ) {
|
||||
|
||||
$update_options[ $value['id'] ]['width'] = woocommerce_clean( $_POST[$value['id'] ]['width'] );
|
||||
$update_options[ $value['id'] ]['height'] = woocommerce_clean( $_POST[$value['id'] ]['height'] );
|
||||
|
||||
if ( isset( $_POST[ $value['id'] ]['crop'] ) )
|
||||
$update_options[ $value['id'] ]['crop'] = 1;
|
||||
else
|
||||
update_option( $value['id'].'_crop', 0 );
|
||||
|
||||
$update_options[ $value['id'] ]['crop'] = 0;
|
||||
|
||||
} else {
|
||||
update_option( $value['id'] . '_width', $value['std'] );
|
||||
update_option( $value['id'] . '_height', $value['std'] );
|
||||
update_option( $value['id'] . '_crop', 1 );
|
||||
$update_options[ $value['id'] ]['width'] = $value['default']['width'];
|
||||
$update_options[ $value['id'] ]['height'] = $value['default']['height'];
|
||||
$update_options[ $value['id'] ]['crop'] = $value['default']['crop'];
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
// Custom handling
|
||||
default :
|
||||
|
||||
|
||||
do_action( 'woocommerce_update_option_' . $type, $value );
|
||||
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ( ! is_null( $option_value ) ) {
|
||||
// Check if option is an array
|
||||
if ( strstr( $value['id'], '[' ) ) {
|
||||
|
||||
parse_str( $value['id'], $option_array );
|
||||
|
||||
// Option name is first key
|
||||
$option_name = current( array_keys( $option_array ) );
|
||||
|
||||
// Get old option value
|
||||
if ( ! isset( $update_options[ $option_name ] ) )
|
||||
$update_options[ $option_name ] = get_option( $option_name, array() );
|
||||
|
||||
if ( ! is_array( $update_options[ $option_name ] ) )
|
||||
$update_options[ $option_name ] = array();
|
||||
|
||||
// Set keys and value
|
||||
$key = key( $option_array[ $option_name ] );
|
||||
|
||||
$update_options[ $option_name ][ $key ] = $option_value;
|
||||
|
||||
// Single value
|
||||
} else {
|
||||
$update_options[ $value['id'] ] = $option_value;
|
||||
}
|
||||
}
|
||||
|
||||
// Custom handling
|
||||
do_action( 'woocommerce_update_option', $value );
|
||||
|
||||
}
|
||||
|
||||
// Now save the options
|
||||
foreach( $update_options as $name => $value )
|
||||
update_option( $name, $value, true );
|
||||
|
||||
return true;
|
||||
}
|
|
@ -48,9 +48,9 @@ function woocommerce_shipping_methods_setting() {
|
|||
<td>';
|
||||
|
||||
if ($method->enabled == 'yes')
|
||||
echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/success.png" alt="yes" />';
|
||||
echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/success.png" width="16 height="14" alt="yes" />';
|
||||
else
|
||||
echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/success-off.png" alt="no" />';
|
||||
echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/success-off.png" width="16" height="14" alt="no" />';
|
||||
|
||||
echo '</td>
|
||||
</tr>';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/Settings
|
||||
* @version 1.6.4
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -17,505 +17,492 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
* @return void
|
||||
*/
|
||||
function woocommerce_tax_rates_setting() {
|
||||
global $woocommerce;
|
||||
|
||||
woocommerce_export_tax_rates();
|
||||
global $woocommerce, $current_section, $wpdb;
|
||||
|
||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option( 'woocommerce_tax_classes' ) ) ) );
|
||||
$tax_rates = get_option( 'woocommerce_tax_rates' );
|
||||
$local_tax_rates = get_option( 'woocommerce_local_tax_rates' );
|
||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('woocommerce_tax_classes' ) ) ) );
|
||||
$current_class = '';
|
||||
|
||||
?><tr valign="top">
|
||||
<th scope="row" class="titledesc"><?php _e( 'Tax Rates', 'woocommerce' ) ?></th>
|
||||
<td class="forminp">
|
||||
|
||||
<a class="button export_rates" href="<?php echo add_query_arg( 'wc_export_tax_rates', 1 ); ?>"><?php _e( 'Export rates', 'woocommerce' ); ?></a>
|
||||
<a class="button import_rates" href="<?php echo admin_url( 'admin.php?import=woocommerce_tax_rate_csv' ); ?>"><?php _e( 'Import rates', 'woocommerce' ); ?></a>
|
||||
|
||||
<p style="margin-top:0;"><?php _e( 'Define tax rates for countries and states below. You can also export and import from CSV files.', 'woocommerce' ); ?></p>
|
||||
|
||||
<table class="taxrows widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="check-column"><input type="checkbox"></th>
|
||||
<th class="country"><?php _e( 'Countries/states', 'woocommerce' ); ?></th>
|
||||
<th><?php _e( 'Tax Class', 'woocommerce' ); ?></th>
|
||||
<th><?php _e( 'Label', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Optionally, enter a label for this rate - this will appear in the totals table', 'woocommerce' ); ?>">[?]</a></th>
|
||||
<th><?php _e( 'Rate', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Enter a tax rate (percentage) to 4 decimal places.', 'woocommerce' ); ?>">[?]</a></th>
|
||||
<th><?php _e( 'Compound', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Choose whether or not this is a compound rate. Compound tax rates are applied on top of other tax rates.', 'woocommerce' ); ?>">[?]</a></th>
|
||||
<th class="apply_to_shipping"><?php _e( 'Shipping', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Choose whether or not this tax rate also gets applied to shipping.', 'woocommerce' ); ?>">[?]</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="2">
|
||||
<a href="#" class="add_tax_rate button"><?php _e( '+ Add Tax Rate', 'woocommerce' ); ?></a>
|
||||
</th>
|
||||
<th colspan="6">
|
||||
<small><?php _e( 'All matching rates will be applied, and non-compound rates will be summed.', 'woocommerce' ); ?></small>
|
||||
|
||||
<a href="#" class="dupe button"><?php _e( 'Duplicate selected', 'woocommerce' ); ?></a>
|
||||
<a href="#" class="remove button"><?php _e( 'Delete selected', 'woocommerce' ); ?></a>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody id="tax_rates">
|
||||
foreach( $tax_classes as $class )
|
||||
if ( sanitize_title( $class ) == $current_section )
|
||||
$current_class = $class;
|
||||
?>
|
||||
<h3><?php printf( __( 'Tax Rates for the "%s" Class', 'woocommerce' ), $current_class ? esc_html( $current_class ) : __( 'Standard', 'woocommerce' ) ); ?></h3>
|
||||
<p><?php printf( __( 'Define tax rates for countries and states below. <a href="%s">See here</a> for available country/state codes.', 'woocommerce' ), 'http://wcdocs.woothemes.com/?p=2163' ); ?></p>
|
||||
<table class="wc_tax_rates widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="sort"> </th>
|
||||
|
||||
<?php $i = -1; if ($tax_rates && is_array($tax_rates)) foreach( $tax_rates as $rate ) : $i++; ?>
|
||||
<tr class="tax_rate">
|
||||
<td class="check-column"><input type="checkbox" name="select" /></td>
|
||||
<td class="country">
|
||||
<p class="edit"><button class="edit_options button"><?php _e( 'Edit', 'woocommerce' ) ?></button> <label><?php echo woocommerce_tax_row_label( $rate['countries'] ); ?></label></p>
|
||||
<div class="options" style="display:none">
|
||||
<select name="tax_country[<?php echo $i; ?>][]" data-placeholder="<?php _e( 'Select countries/states…', 'woocommerce' ); ?>" class="tax_chosen_select select" size="10" multiple="multiple">
|
||||
<?php echo $woocommerce->countries->country_multiselect_options( $rate['countries'] ); ?>
|
||||
</select>
|
||||
<?php echo '<p><button class="select_all button">'.__( 'All', 'woocommerce' ).'</button><button class="select_none button">'.__( 'None', 'woocommerce' ).'</button><button class="button select_us_states">'.__( 'US States', 'woocommerce' ).'</button><button class="button select_europe">'.__( 'EU States', 'woocommerce' ).'</button></p>'; ?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="tax_class">
|
||||
<select name="tax_class[<?php echo $i; ?>]" title="Tax Class" class="select">
|
||||
<option value=""><?php _e( 'Standard Rate', 'woocommerce' ); ?></option>
|
||||
<?php
|
||||
if ($tax_classes) foreach ($tax_classes as $class) :
|
||||
echo '<option value="'.sanitize_title($class).'"';
|
||||
selected($rate['class'], sanitize_title($class));
|
||||
echo '>'.$class.'</option>';
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td class="label">
|
||||
<input type="text" class="text" value="<?php if (isset($rate['label'])) echo esc_attr( $rate['label'] ); ?>" name="tax_label[<?php echo $i; ?>]" title="<?php _e( 'Label', 'woocommerce' ); ?>" size="16" />
|
||||
</td>
|
||||
<td class="rate">
|
||||
<input type="text" class="text" value="<?php echo esc_attr( $rate['rate'] ); ?>" name="tax_rate[<?php echo $i; ?>]" title="<?php _e( 'Rate', 'woocommerce' ); ?>" placeholder="<?php _e( 'Rate', 'woocommerce' ); ?>" maxlength="8" size="4" />%
|
||||
<th width="8%"><?php _e( 'Country Code', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e('A 2 digit country code, e.g. US. Leave blank to apply to all.', 'woocommerce'); ?>">[?]</span></th>
|
||||
|
||||
<th width="8%"><?php _e( 'State Code', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e('A 2 digit state code, e.g. AL. Leave blank to apply to all.', 'woocommerce'); ?>">[?]</span></th>
|
||||
|
||||
<th><?php _e( 'ZIP/Postcode', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e('Postcode for this rule. Semi-colon (;) separate multiple values. Leave blank to apply to all areas. Wildcards (*) can be used. Ranges for numeric postcodes (e.g. 12345-12350) will be expanded into individual postcodes.', 'woocommerce'); ?>">[?]</span></th>
|
||||
|
||||
<th><?php _e( 'City', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e('Cities for this rule. Semi-colon (;) separate multiple values. Leave blank to apply to all cities.', 'woocommerce'); ?>">[?]</span></th>
|
||||
|
||||
<th width="8%"><?php _e( 'Rate %', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e( 'Enter a tax rate (percentage) to 4 decimal places.', 'woocommerce' ); ?>">[?]</span></th>
|
||||
|
||||
<th width="8%"><?php _e( 'Tax Name', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e('Enter a name for this tax rate.', 'woocommerce'); ?>">[?]</span></th>
|
||||
|
||||
<th width="8%"><?php _e( 'Priority', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e('Choose a priority for this tax rate. Only 1 matching rate per priority will be used. To define multiple tax rates for a single area you need to specify a different priority per rate.', 'woocommerce'); ?>">[?]</span></th>
|
||||
|
||||
<th width="8%"><?php _e( 'Compound', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e('Choose whether or not this is a compound rate. Compound tax rates are applied on top of other tax rates.', 'woocommerce'); ?>">[?]</span></th>
|
||||
|
||||
<th width="8%"><?php _e( 'Shipping', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e('Choose whether or not this tax rate also gets applied to shipping.', 'woocommerce'); ?>">[?]</span></th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="10">
|
||||
<a href="#" class="button plus insert"><?php _e( 'Insert row', 'woocommerce' ); ?></a>
|
||||
<a href="#" class="button minus remove"><?php _e( 'Remove selected row(s)', 'woocommerce' ); ?></a>
|
||||
|
||||
<a href="#" download="tax_rates.csv" class="button export"><?php _e( 'Export CSV', 'woocommerce' ); ?></a>
|
||||
<a href="<?php echo admin_url( 'admin.php?import=woocommerce_tax_rate_csv' ); ?>" class="button import"><?php _e( 'Import CSV', 'woocommerce' ); ?></a>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody id="rates">
|
||||
<?php
|
||||
$rates = $wpdb->get_results( $wpdb->prepare(
|
||||
"SELECT * FROM {$wpdb->prefix}woocommerce_tax_rates
|
||||
WHERE tax_rate_class = %s
|
||||
ORDER BY tax_rate_order
|
||||
" , $current_class ) );
|
||||
|
||||
foreach ( $rates as $rate ) {
|
||||
?>
|
||||
<tr>
|
||||
<td class="sort"><input type="hidden" class="remove_tax_rate" name="remove_tax_rate[<?php echo $rate->tax_rate_id ?>]" value="0" /></td>
|
||||
|
||||
<td class="country" width="8%">
|
||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_country ) ?>" placeholder="*" name="tax_rate_country[<?php echo $rate->tax_rate_id ?>]" />
|
||||
</td>
|
||||
|
||||
<td class="state" width="8%">
|
||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_state ) ?>" placeholder="*" name="tax_rate_state[<?php echo $rate->tax_rate_id ?>]" />
|
||||
</td>
|
||||
|
||||
<td class="postcode">
|
||||
<input type="text" value="<?php
|
||||
$locations = $wpdb->get_col( $wpdb->prepare( "SELECT location_code FROM {$wpdb->prefix}woocommerce_tax_rate_locations WHERE location_type='postcode' AND tax_rate_id = %d ORDER BY location_code", $rate->tax_rate_id ) );
|
||||
|
||||
echo esc_attr( implode( '; ', $locations ) );
|
||||
?>" placeholder="*" data-name="tax_rate_postcode[<?php echo $rate->tax_rate_id ?>]" />
|
||||
</td>
|
||||
|
||||
<td class="city">
|
||||
<input type="text" value="<?php
|
||||
$locations = $wpdb->get_col( $wpdb->prepare( "SELECT location_code FROM {$wpdb->prefix}woocommerce_tax_rate_locations WHERE location_type='city' AND tax_rate_id = %d ORDER BY location_code", $rate->tax_rate_id ) );
|
||||
echo esc_attr( implode( '; ', $locations ) );
|
||||
?>" placeholder="*" data-name="tax_rate_city[<?php echo $rate->tax_rate_id ?>]" />
|
||||
</td>
|
||||
|
||||
<td class="rate" width="8%">
|
||||
<input type="number" step="any" min="0" value="<?php echo esc_attr( $rate->tax_rate ) ?>" placeholder="0" name="tax_rate[<?php echo $rate->tax_rate_id ?>]" />
|
||||
</td>
|
||||
|
||||
<td class="name" width="8%">
|
||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_name ) ?>" name="tax_rate_name[<?php echo $rate->tax_rate_id ?>]" />
|
||||
</td>
|
||||
|
||||
<td class="priority" width="8%">
|
||||
<input type="number" step="1" min="1" value="<?php echo esc_attr( $rate->tax_rate_priority ) ?>" name="tax_rate_priority[<?php echo $rate->tax_rate_id ?>]" />
|
||||
</td>
|
||||
|
||||
<td class="compound" width="8%">
|
||||
<input type="checkbox" class="checkbox" name="tax_rate_compound[<?php echo $rate->tax_rate_id ?>]" <?php checked( $rate->tax_rate_compound, '1' ); ?> />
|
||||
</td>
|
||||
<td class="compound">
|
||||
<input type="checkbox" class="checkbox" name="tax_compound[<?php echo $i; ?>]" <?php if (isset($rate['compound'])) checked($rate['compound'], 'yes'); ?> />
|
||||
|
||||
<td class="apply_to_shipping" width="8%">
|
||||
<input type="checkbox" class="checkbox" name="tax_rate_shipping[<?php echo $rate->tax_rate_id ?>]" <?php checked($rate->tax_rate_shipping, '1' ); ?> />
|
||||
</td>
|
||||
<td class="apply_to_shipping">
|
||||
<input type="checkbox" class="checkbox" name="tax_shipping[<?php echo $i; ?>]" <?php if (isset($rate['shipping'])) checked($rate['shipping'], 'yes'); ?> />
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php if ( empty( $local_tax_rates ) ) : ?>
|
||||
<p style="margin: 1em 0 0;"><a href="#" data-tip="<?php _e( 'Add local tax rates to define rules for specific zip codes and cities.', 'woocommerce' ); ?>" class="tips toggle_local_tax_rates">+ <?php _e( 'Local tax rates', 'woocommerce' ); ?></a></p>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" <?php if ( empty( $local_tax_rates ) ) : ?>style="display:none;"<?php endif; ?> class="local_tax_rates">
|
||||
<th scope="row" class="titledesc"><?php _e( 'Local tax rates', 'woocommerce' ); ?></th>
|
||||
<td class="forminp">
|
||||
<a class="button export_rates" href="<?php echo add_query_arg( 'wc_export_tax_rates', 2 ); ?>"><?php _e( 'Export rates', 'woocommerce' ); ?></a>
|
||||
<a class="button import_rates" href="<?php echo admin_url( 'admin.php?import=woocommerce_tax_rate_csv' ); ?>"><?php _e( 'Import rates', 'woocommerce' ); ?></a>
|
||||
|
||||
<p style="margin-top:0;"><?php _e( 'Define local tax rates for specific post/zip codes below. You can also export and import from CSV files.', 'woocommerce' ); ?></p>
|
||||
|
||||
<table class="taxrows widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="check-column"><input type="checkbox"></th>
|
||||
<th class="country"><?php _e( 'Locations', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'List (1 per line) postcodes/zips/cities this rate applies to. You may also enter ranges for numeric zip codes. e.g. 12345-12349;23456;', 'woocommerce' ); ?>">[?]</a></th>
|
||||
<th><?php _e( 'Tax Class', 'woocommerce' ); ?></th>
|
||||
<th><?php _e( 'Label', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Optionally, enter a label for this rate - this will appear in the totals table', 'woocommerce' ); ?>">[?]</a></th>
|
||||
<th><?php _e( 'Rate', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Enter a tax rate (percentage) to 4 decimal places.', 'woocommerce' ); ?>">[?]</a></th>
|
||||
<th><?php _e( 'Compound', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Choose whether or not this is a compound rate. Compound tax rates are applied on top of other tax rates.', 'woocommerce' ); ?>">[?]</a></th>
|
||||
<th class="apply_to_shipping"><?php _e( 'Shipping', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Choose whether or not this tax rate also gets applied to shipping.', 'woocommerce' ); ?>">[?]</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="2"><a href="#" class="add_local_tax_rate button"><?php _e( '+ Add Tax Rate', 'woocommerce' ); ?></a></th>
|
||||
<th colspan="5">
|
||||
<small><?php _e( 'All matching rates will be applied, and non-compound rates will be summed.', 'woocommerce' ); ?></small>
|
||||
<a href="#" class="dupe button"><?php _e( 'Duplicate selected rows', 'woocommerce' ); ?></a> <a href="#" class="remove button"><?php _e( 'Delete selected rows', 'woocommerce' ); ?></a>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody id="local_tax_rates">
|
||||
|
||||
<?php
|
||||
$i = -1;
|
||||
if ($local_tax_rates && is_array($local_tax_rates)) foreach( $local_tax_rates as $rate ) :
|
||||
$i++;
|
||||
$rate['locations'] = isset( $rate['locations'] ) ? $rate['locations'] : $rate['postcode']; // Backwards compat
|
||||
$rate['location_type'] = isset( $rate['location_type'] ) ? $rate['location_type'] : 'postcode';
|
||||
?>
|
||||
<tr class="tax_rate">
|
||||
<td class="check-column"><input type="checkbox" name="select" /></td>
|
||||
<td class="local_country">
|
||||
<select name="local_tax_country[<?php echo $i; ?>]" class="select">
|
||||
<option value=""><?php _e( 'Select a country/state…', 'woocommerce' ); ?></option>
|
||||
<?php echo $woocommerce->countries->country_dropdown_options( $rate['country'], $rate['state'] ); ?>
|
||||
</select>
|
||||
<select name="local_tax_location_type[<?php echo $i; ?>]" class="select type">
|
||||
<option value="postcode" <?php selected( $rate['location_type'], 'postcode' ); ?>><?php _e( 'Postcodes/zips', 'woocommerce' ); ?></option>
|
||||
<option value="city" <?php selected( $rate['location_type'], 'city' ); ?>><?php _e( 'Cities', 'woocommerce' ); ?></option>
|
||||
</select>
|
||||
<textarea type="text" placeholder="<?php _e( 'List 1 per line', 'woocommerce' ); ?>" class="text" name="local_tax_location[<?php echo $i; ?>]"><?php if ( isset( $rate['locations'] ) ) echo implode( "\n", $rate['locations'] ); ?></textarea>
|
||||
</td>
|
||||
<td class="tax_class">
|
||||
<select name="local_tax_class[<?php echo $i; ?>]" title="Tax Class" class="select">
|
||||
<option value=""><?php _e( 'Standard Rate', 'woocommerce' ); ?></option>
|
||||
<?php
|
||||
if ($tax_classes) foreach ($tax_classes as $class) :
|
||||
echo '<option value="'.sanitize_title($class).'"';
|
||||
selected($rate['class'], sanitize_title($class));
|
||||
echo '>'.$class.'</option>';
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td class="label">
|
||||
<input type="text" class="text" value="<?php if (isset($rate['label'])) echo esc_attr( $rate['label'] ); ?>" name="local_tax_label[<?php echo $i; ?>]" title="<?php _e( 'Label', 'woocommerce' ); ?>" size="16" />
|
||||
</td>
|
||||
<td class="rate">
|
||||
<input type="text" class="text" value="<?php echo esc_attr( $rate['rate'] ); ?>" name="local_tax_rate[<?php echo $i; ?>]" title="<?php _e( 'Rate', 'woocommerce' ); ?>" placeholder="<?php _e( 'Rate', 'woocommerce' ); ?>" maxlength="8" size="4" />%
|
||||
</td>
|
||||
<td class="compound">
|
||||
<input type="checkbox" class="checkbox" name="local_tax_compound[<?php echo $i; ?>]" <?php if (isset($rate['compound'])) checked($rate['compound'], 'yes'); ?> />
|
||||
</td>
|
||||
<td class="apply_to_shipping">
|
||||
<input type="checkbox" class="checkbox" name="local_tax_shipping[<?php echo $i; ?>]" <?php if (isset($rate['shipping'])) checked($rate['shipping'], 'yes'); ?> />
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<script type="text/javascript">
|
||||
jQuery(function() {
|
||||
jQuery( function() {
|
||||
jQuery('.wc_tax_rates tbody').sortable({
|
||||
items:'tr',
|
||||
cursor:'move',
|
||||
axis:'y',
|
||||
scrollSensitivity:40,
|
||||
forcePlaceholderSize: true,
|
||||
helper: 'clone',
|
||||
opacity: 0.65,
|
||||
placeholder: 'wc-metabox-sortable-placeholder',
|
||||
start:function(event,ui){
|
||||
ui.item.css('background-color','#f6f6f6');
|
||||
},
|
||||
stop:function(event,ui){
|
||||
ui.item.removeAttr('style');
|
||||
}
|
||||
});
|
||||
|
||||
jQuery('tr.tax_rate .edit_options').live('click', function(){
|
||||
jQuery(this).closest('td').find('.options').slideToggle();
|
||||
if (jQuery(this).text()=='<?php _e( 'Edit', 'woocommerce' ); ?>') {
|
||||
jQuery('.wc_tax_rates .remove').click(function() {
|
||||
var $tbody = jQuery('.wc_tax_rates').find('tbody');
|
||||
if ( $tbody.find('tr.current').size() > 0 ) {
|
||||
$current = $tbody.find('tr.current');
|
||||
$current.find('input').val('');
|
||||
$current.find('input.remove_tax_rate').val('1');
|
||||
|
||||
jQuery(this).closest('tr').find("select.tax_chosen_select").chosen();
|
||||
$current.each(function(){
|
||||
|
||||
jQuery(this).text('<?php _e( 'Done', 'woocommerce' ); ?>');
|
||||
|
||||
} else {
|
||||
jQuery(this).text('<?php _e( 'Edit', 'woocommerce' ); ?>');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
jQuery('tr.tax_rate .select_all').live('click', function(){
|
||||
jQuery(this).closest('td').find('select option').attr("selected","selected");
|
||||
jQuery(this).closest('td').find('select.tax_chosen_select').trigger("change");
|
||||
return false;
|
||||
});
|
||||
|
||||
jQuery('tr.tax_rate .select_none').live('click', function(){
|
||||
jQuery(this).closest('td').find('select option').removeAttr("selected");
|
||||
jQuery(this).closest('td').find('select.tax_chosen_select').trigger("change");
|
||||
return false;
|
||||
});
|
||||
|
||||
jQuery('tr.tax_rate .select_us_states').live('click', function(){
|
||||
jQuery(this).closest('td').find('option[value=\"US:AK\"], option[value=\"US:AL\"], option[value=\"US:AZ\"], option[value=\"US:AR\"], option[value=\"US:CA\"], option[value=\"US:CO\"], option[value=\"US:CT\"], option[value=\"US:DE\"], option[value=\"US:DC\"], option[value=\"US:FL\"], option[value=\"US:GA\"], option[value=\"US:HI\"], option[value=\"US:ID\"], option[value=\"US:IL\"], option[value=\"US:IN\"], option[value=\"US:IA\"], option[value=\"US:KS\"], option[value=\"US:KY\"], option[value=\"US:LA\"], option[value=\"US:ME\"], option[value=\"US:MD\"], option[value=\"US:MA\"], option[value=\"US:MI\"], option[value=\"US:MN\"], option[value=\"US:MS\"], option[value=\"US:MO\"], option[value=\"US:MT\"], option[value=\"US:NE\"], option[value=\"US:NV\"], option[value=\"US:NH\"], option[value=\"US:NJ\"], option[value=\"US:NM\"], option[value=\"US:NY\"], option[value=\"US:NC\"], option[value=\"US:ND\"], option[value=\"US:OH\"], option[value=\"US:OK\"], option[value=\"US:OR\"], option[value=\"US:PA\"], option[value=\"US:RI\"], option[value=\"US:SC\"], option[value=\"US:SD\"], option[value=\"US:TN\"], option[value=\"US:TX\"], option[value=\"US:UT\"], option[value=\"US:VT\"], option[value=\"US:VA\"], option[value=\"US:WA\"], option[value=\"US:WV\"], option[value=\"US:WI\"], option[value=\"US:WY\"]').attr( "selected", "selected");
|
||||
jQuery(this).closest('td').find('select.tax_chosen_select').trigger('liszt:updated');
|
||||
return false;
|
||||
});
|
||||
|
||||
jQuery('tr.tax_rate .options select').live('change', function(){
|
||||
jQuery(this).trigger("liszt:updated");
|
||||
jQuery(this).closest('td').find('label').text( jQuery(":selected", this).length + ' ' + '<?php _e( 'countries/states selected', 'woocommerce' ) ?>' );
|
||||
});
|
||||
|
||||
jQuery('tr.tax_rate .select_europe').live('click', function(){
|
||||
jQuery(this).closest('td').find('option[value="BE"],option[value="FR"],option[value="DE"],option[value="IT"],option[value="LU"],option[value="NL"],option[value="DK"],option[value="IE"],option[value="GR"],option[value="PT"],option[value="ES"],option[value="AT"],option[value="FI"],option[value="SE"],option[value="CY"],option[value="CZ"],option[value="EE"],option[value="HU"],option[value="LV"],option[value="LT"],option[value="MT"],option[value="PL"],option[value="SK"],option[value="SI"],option[value="RO"],option[value="BG"],option[value="IM"],option[value="GB"]').attr("selected","selected");
|
||||
jQuery(this).closest('td').find('select.tax_chosen_select').trigger("change");
|
||||
return false;
|
||||
});
|
||||
|
||||
jQuery('.taxrows a.add_tax_rate').live('click', function(){
|
||||
var size = jQuery('#tax_rates tr').size();
|
||||
|
||||
// Add the row
|
||||
jQuery('<tr class="tax_rate new_rate">\
|
||||
<td class="check-column"><input type="checkbox" name="select" /></td>\
|
||||
<td class="country">\
|
||||
<p class="edit"><button class="edit_options button"><?php _e( 'Edit', 'woocommerce' ) ?></button> <label><?php _e( 'No countries selected', 'woocommerce' ); ?></label></p>\
|
||||
<div class="options" style="display:none">\
|
||||
<select name="tax_country[' + size + '][]" data-placeholder="<?php _e( 'Select countries/states…', 'woocommerce' ); ?>" class="tax_chosen_select select" size="10" multiple="multiple">\
|
||||
<?php echo $woocommerce->countries->country_multiselect_options(); ?>\
|
||||
</select>\
|
||||
<?php echo '<p><button class="select_all button">'.__( 'All', 'woocommerce' ).'</button><button class="select_none button">'.__( 'None', 'woocommerce' ).'</button><button class="button select_us_states">'.__( 'US States', 'woocommerce' ).'</button><button class="button select_europe">'.__( 'EU States', 'woocommerce' ).'</button></p>'; ?>\
|
||||
</div>\
|
||||
</td>\
|
||||
<td class="tax_class">\
|
||||
<select name="tax_class[' + size + ']" title="Tax Class" class="select">\
|
||||
<option value=""><?php _e( 'Standard Rate', 'woocommerce' ); ?></option>\
|
||||
<?php
|
||||
if ($tax_classes) foreach ($tax_classes as $class) :
|
||||
echo '<option value="'.sanitize_title($class).'">'.$class.'</option>';
|
||||
endforeach;
|
||||
?>
|
||||
</select>\
|
||||
</td>\
|
||||
<td class="label">\
|
||||
<input type="text" class="text" name="tax_label[' + size + ']" title="<?php _e( 'Label', 'woocommerce' ); ?>" size="16" />\
|
||||
</td>\
|
||||
<td class="rate">\
|
||||
<input type="text" class="text" name="tax_rate[' + size + ']" title="<?php _e( 'Rate', 'woocommerce' ); ?>" placeholder="<?php _e( 'Rate', 'woocommerce' ); ?>" maxlength="8" size="4" />%\
|
||||
</td>\
|
||||
<td class="compound">\
|
||||
<input type="checkbox" class="checkbox" name="tax_compound[' + size + ']" />\
|
||||
</td>\
|
||||
<td class="apply_to_shipping">\
|
||||
<input type="checkbox" class="checkbox" name="tax_shipping[' + size + ']" />\
|
||||
</td>\
|
||||
</tr>').appendTo('#tax_rates');
|
||||
|
||||
jQuery(".new_rate select.tax_chosen_select").chosen();
|
||||
jQuery(".new_rate").removeClass('new_rate');
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
jQuery('.taxrows a.add_local_tax_rate').live('click', function(){
|
||||
var size = jQuery('#local_tax_rates tr').size();
|
||||
|
||||
// Add the row
|
||||
jQuery('<tr class="tax_rate new_rate">\
|
||||
<td class="check-column"><input type="checkbox" name="select" /></td>\
|
||||
<td class="local_country">\
|
||||
<select name="local_tax_country[' + size + ']" class="select">\
|
||||
<option value=""><?php _e( 'Select a country/state…', 'woocommerce' ); ?></option>\
|
||||
<?php echo $woocommerce->countries->country_dropdown_options( '', '', true ); ?>\
|
||||
</select>\
|
||||
<select name="local_tax_location_type[' + size + ']" class="select type">\
|
||||
<option value="postcode"><?php _e( 'Postcodes/zips', 'woocommerce' ); ?></option>\
|
||||
<option value="city"><?php _e( 'Cities', 'woocommerce' ); ?></option>\
|
||||
</select>\
|
||||
<textarea type="text" placeholder="<?php _e( 'List 1 per line', 'woocommerce' ); ?>" class="text" name="local_tax_location[' + size + ']"></textarea>\
|
||||
</td>\
|
||||
<td class="tax_class">\
|
||||
<select name="local_tax_class[' + size + ']" title="Tax Class" class="select">\
|
||||
<option value=""><?php _e( 'Standard Rate', 'woocommerce' ); ?></option>\
|
||||
<?php
|
||||
if ($tax_classes) foreach ($tax_classes as $class) :
|
||||
echo '<option value="'.sanitize_title($class).'">'.$class.'</option>';
|
||||
endforeach;
|
||||
?>
|
||||
</select>\
|
||||
</td>\
|
||||
<td class="label">\
|
||||
<input type="text" class="text" name="local_tax_label[' + size + ']" title="<?php _e( 'Label', 'woocommerce' ); ?>" size="16" />\
|
||||
</td>\
|
||||
<td class="rate">\
|
||||
<input type="text" class="text" name="local_tax_rate[' + size + ']" title="<?php _e( 'Rate', 'woocommerce' ); ?>" placeholder="<?php _e( 'Rate', 'woocommerce' ); ?>" maxlength="8" size="4" />%\
|
||||
</td>\
|
||||
<td class="compound">\
|
||||
<input type="checkbox" class="checkbox" name="local_tax_compound[' + size + ']" />\
|
||||
</td>\
|
||||
<td class="apply_to_shipping">\
|
||||
<input type="checkbox" class="checkbox" name="local_tax_shipping[' + size + ']" />\
|
||||
</td>\
|
||||
</tr>').appendTo('#local_tax_rates');
|
||||
|
||||
jQuery(".new_rate").removeClass('new_rate');
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// Remove row
|
||||
jQuery('.taxrows a.remove').live('click', function(){
|
||||
var answer = confirm("<?php _e( 'Delete the selected rates?', 'woocommerce' ); ?>")
|
||||
if (answer) {
|
||||
var $rates = jQuery(this).closest('.taxrows').find('tbody');
|
||||
|
||||
$rates.find('tr td.check-column input:checked').each(function(i, el){
|
||||
jQuery(el).closest('tr').find('input.text, input.checkbox, select.select').val('');
|
||||
jQuery(el).closest('tr').hide();
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// Dupe row
|
||||
jQuery('.taxrows a.dupe').live('click', function(){
|
||||
var answer = confirm("<?php _e( 'Duplicate the selected rates?', 'woocommerce' ); ?>")
|
||||
if (answer) {
|
||||
|
||||
var $rates = jQuery(this).closest('.taxrows').find('tbody');
|
||||
|
||||
$rates.find('tr td.check-column input:checked').each(function(i, el){
|
||||
var dupe = jQuery(el).closest('tr').clone()
|
||||
|
||||
// Remove chosen selector
|
||||
dupe.find('.chzn-done').removeClass('chzn-done').removeAttr('id').removeAttr('style');
|
||||
dupe.find('.chzn-container').remove();
|
||||
|
||||
// Append
|
||||
$rates.append( dupe );
|
||||
});
|
||||
|
||||
// Re-index keys
|
||||
var loop = 0;
|
||||
$rates.find('tr.tax_rate').each(function( index, row ){
|
||||
jQuery('input.text, input.checkbox, select.select', row).each(function( i, el ){
|
||||
|
||||
var t = jQuery(el);
|
||||
t.attr('name', t.attr('name').replace(/\[([^[]*)\]/, "[" + loop + "]"));
|
||||
if ( jQuery(this).is('.new') )
|
||||
jQuery(this).remove();
|
||||
else
|
||||
jQuery(this).hide();
|
||||
|
||||
});
|
||||
loop++;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// Show local rates
|
||||
jQuery( 'a.toggle_local_tax_rates' ).click(function(){
|
||||
jQuery(this).closest('p').hide();
|
||||
jQuery('tr.local_tax_rates').slideDown();
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
alert('<?php _e( 'No row(s) selected', 'woocommerce' ); ?>');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
var shifted = false;
|
||||
|
||||
jQuery(document).bind('keyup keydown', function(e){shifted = e.shiftKey} );
|
||||
|
||||
jQuery('.wc_tax_rates input').live( 'click focus', function( e ) {
|
||||
if ( ! shifted ) {
|
||||
jQuery('.wc_tax_rates tr').removeClass('current');
|
||||
}
|
||||
|
||||
jQuery(this).closest('tr').addClass('current');
|
||||
});
|
||||
|
||||
jQuery('.wc_tax_rates .export').click(function() {
|
||||
|
||||
var csv_data = "data:application/csv;charset=utf-8,<?php _e( 'Country Code', 'woocommerce' ); ?>,<?php _e( 'State Code', 'woocommerce' ); ?>,<?php _e( 'ZIP/Postcode', 'woocommerce' ); ?>,<?php _e( 'City', 'woocommerce' ); ?>,<?php _e( 'Rate %', 'woocommerce' ); ?>,<?php _e( 'Tax Name', 'woocommerce' ); ?>,<?php _e( 'Priority', 'woocommerce' ); ?>,<?php _e( 'Compound', 'woocommerce' ); ?>,<?php _e( 'Shipping', 'woocommerce' ); ?>,<?php _e( 'Tax Class', 'woocommerce' ); ?>\n";
|
||||
|
||||
jQuery('#rates tr:visible').each(function() {
|
||||
var row = '';
|
||||
jQuery(this).find('td:not(.sort) input').each(function() {
|
||||
|
||||
if ( jQuery(this).is('.checkbox') ) {
|
||||
|
||||
if ( jQuery(this).is(':checked') ) {
|
||||
val = 1;
|
||||
} else {
|
||||
val = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
var val = jQuery(this).val();
|
||||
|
||||
if ( ! val )
|
||||
val = jQuery(this).attr('placeholder');
|
||||
}
|
||||
|
||||
row = row + val + ',';
|
||||
});
|
||||
row = row + '<?php echo $current_class; ?>';
|
||||
//row.substring( 0, row.length - 1 );
|
||||
csv_data = csv_data + row + "\n";
|
||||
});
|
||||
|
||||
jQuery(this).attr( 'href', encodeURI( csv_data ) );
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
jQuery('.wc_tax_rates .insert').click(function() {
|
||||
var $tbody = jQuery('.wc_tax_rates').find('tbody');
|
||||
var size = $tbody.find('tr').size();
|
||||
var code = '<tr class="new">\
|
||||
<td class="sort"> </td>\
|
||||
<td class="country" width="8%">\
|
||||
<input type="text" placeholder="*" name="tax_rate_country[new][' + size + ']" />\
|
||||
</td>\
|
||||
<td class="state" width="8%">\
|
||||
<input type="text" placeholder="*" name="tax_rate_state[new][' + size + ']" />\
|
||||
</td>\
|
||||
<td class="postcode">\
|
||||
<input type="text" placeholder="*" name="tax_rate_postcode[new][' + size + ']" />\
|
||||
</td>\
|
||||
<td class="city">\
|
||||
<input type="text" placeholder="*" name="tax_rate_city[new][' + size + ']" />\
|
||||
</td>\
|
||||
<td class="rate" width="8%">\
|
||||
<input type="number" step="any" min="0" placeholder="0" name="tax_rate[new][' + size + ']" />\
|
||||
</td>\
|
||||
<td class="name" width="8%">\
|
||||
<input type="text" name="tax_rate_name[new][' + size + ']" />\
|
||||
</td>\
|
||||
<td class="priority" width="8%">\
|
||||
<input type="number" step="1" min="1" value="1" name="tax_rate_priority[new][' + size + ']" />\
|
||||
</td>\
|
||||
<td class="compound" width="8%">\
|
||||
<input type="checkbox" class="checkbox" name="tax_rate_compound[new][' + size + ']" />\
|
||||
</td>\
|
||||
<td class="apply_to_shipping" width="8%">\
|
||||
<input type="checkbox" class="checkbox" name="tax_rate_shipping[new][' + size + ']" checked="checked" />\
|
||||
</td>\
|
||||
</tr>';
|
||||
|
||||
if ( $tbody.find('tr.current').size() > 0 ) {
|
||||
$tbody.find('tr.current').after( code );
|
||||
} else {
|
||||
$tbody.append( code );
|
||||
}
|
||||
|
||||
jQuery( "td.country input" ).autocomplete({
|
||||
source: availableCountries,
|
||||
minLength: 3
|
||||
});
|
||||
|
||||
jQuery( "td.state input" ).autocomplete({
|
||||
source: availableStates,
|
||||
minLength: 3
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
jQuery('.wc_tax_rates td.postcode, .wc_tax_rates td.city').find('input').change(function() {
|
||||
jQuery(this).attr( 'name', jQuery(this).attr( 'data-name' ) );
|
||||
});
|
||||
|
||||
var availableCountries = [<?php
|
||||
$countries = array();
|
||||
foreach ( $woocommerce->countries->get_allowed_countries() as $value => $label )
|
||||
$countries[] = '{ label: "' . $label . '", value: "' . $value . '" }';
|
||||
echo implode( ', ', $countries );
|
||||
?>];
|
||||
|
||||
var availableStates = [<?php
|
||||
$countries = array();
|
||||
foreach ( $woocommerce->countries->get_allowed_country_states() as $value => $label )
|
||||
foreach ( $label as $code => $state )
|
||||
$countries[] = '{ label: "' . $state . '", value: "' . $code . '" }';
|
||||
echo implode( ', ', $countries );
|
||||
?>];
|
||||
|
||||
jQuery( "td.country input" ).autocomplete({
|
||||
source: availableCountries,
|
||||
minLength: 3
|
||||
});
|
||||
|
||||
jQuery( "td.state input" ).autocomplete({
|
||||
source: availableStates,
|
||||
minLength: 3
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action( 'woocommerce_admin_field_tax_rates', 'woocommerce_tax_rates_setting' );
|
||||
|
||||
|
||||
/**
|
||||
* Show a tax label based on user selections.
|
||||
* woocommerce_tax_rates_setting_save function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $selected
|
||||
* @return void
|
||||
*/
|
||||
function woocommerce_tax_row_label( $selected ) {
|
||||
global $woocommerce;
|
||||
function woocommerce_tax_rates_setting_save() {
|
||||
global $wpdb, $current_section;
|
||||
|
||||
$return = '';
|
||||
// Get class
|
||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('woocommerce_tax_classes' ) ) ) );
|
||||
$current_class = '';
|
||||
|
||||
// Get counts/countries
|
||||
$counties_array = array();
|
||||
$states_count = 0;
|
||||
foreach( $tax_classes as $class )
|
||||
if ( sanitize_title( $class ) == $current_section )
|
||||
$current_class = $class;
|
||||
|
||||
if ($selected) foreach ( $selected as $country => $value ) :
|
||||
// Get POST data
|
||||
$tax_rate_country = isset( $_POST['tax_rate_country'] ) ? $_POST['tax_rate_country'] : array();
|
||||
$tax_rate_state = isset( $_POST['tax_rate_state'] ) ? $_POST['tax_rate_state'] : array();
|
||||
$tax_rate_postcode = isset( $_POST['tax_rate_postcode'] ) ? $_POST['tax_rate_postcode'] : array();
|
||||
$tax_rate_city = isset( $_POST['tax_rate_city'] ) ? $_POST['tax_rate_city'] : array();
|
||||
$tax_rate = isset( $_POST['tax_rate'] ) ? $_POST['tax_rate'] : array();
|
||||
$tax_rate_name = isset( $_POST['tax_rate_name'] ) ? $_POST['tax_rate_name'] : array();
|
||||
$tax_rate_priority = isset( $_POST['tax_rate_priority'] ) ? $_POST['tax_rate_priority'] : array();
|
||||
$tax_rate_compound = isset( $_POST['tax_rate_compound'] ) ? $_POST['tax_rate_compound'] : array();
|
||||
$tax_rate_shipping = isset( $_POST['tax_rate_shipping'] ) ? $_POST['tax_rate_shipping'] : array();
|
||||
|
||||
$country = woocommerce_clean($country);
|
||||
$i = 0;
|
||||
|
||||
if (sizeof($value)>0 && $value[0]!=='*') :
|
||||
$states_count+=sizeof($value);
|
||||
endif;
|
||||
// Loop posted fields
|
||||
foreach ( $tax_rate_country as $key => $value ) {
|
||||
|
||||
if ( ! in_array( $country, $counties_array ) )
|
||||
$counties_array[] = esc_html( $woocommerce->countries->countries[ $country ] );
|
||||
// new keys are inserted...
|
||||
if ( $key == 'new' ) {
|
||||
|
||||
endforeach;
|
||||
foreach ( $value as $new_key => $new_value ) {
|
||||
|
||||
$states_text = '';
|
||||
$countries_text = implode(', ', $counties_array);
|
||||
// Sanitize + format
|
||||
$country = strtoupper( woocommerce_clean( $tax_rate_country[ $key ][ $new_key ] ) );
|
||||
$state = strtoupper( woocommerce_clean( $tax_rate_state[ $key ][ $new_key ] ) );
|
||||
$postcode = woocommerce_clean( $tax_rate_postcode[ $key ][ $new_key ] );
|
||||
$city = woocommerce_clean( $tax_rate_city[ $key ][ $new_key ] );
|
||||
$rate = number_format( woocommerce_clean( $tax_rate[ $key ][ $new_key ] ), 4, '.', '' );
|
||||
$name = woocommerce_clean( $tax_rate_name[ $key ][ $new_key ] );
|
||||
$priority = absint( woocommerce_clean( $tax_rate_priority[ $key ][ $new_key ] ) );
|
||||
$compound = isset( $tax_rate_compound[ $key ][ $new_key ] ) ? 1 : 0;
|
||||
$shipping = isset( $tax_rate_shipping[ $key ][ $new_key ] ) ? 1 : 0;
|
||||
|
||||
// Show label
|
||||
if (sizeof($counties_array)==0) :
|
||||
if ( ! $name )
|
||||
$name = __( 'Tax', 'woocommerce' );
|
||||
|
||||
$return .= __( 'No countries selected', 'woocommerce' );
|
||||
if ( $country == '*' )
|
||||
$country = '';
|
||||
|
||||
elseif ( sizeof($counties_array) < 6 ) :
|
||||
if ( $state == '*' )
|
||||
$state = '';
|
||||
|
||||
if ($states_count>0) $states_text = sprintf(_n('(1 state)', '(%s states)', $states_count, 'woocommerce'), $states_count);
|
||||
$wpdb->insert(
|
||||
$wpdb->prefix . "woocommerce_tax_rates",
|
||||
array(
|
||||
'tax_rate_country' => $country,
|
||||
'tax_rate_state' => $state,
|
||||
'tax_rate' => $rate,
|
||||
'tax_rate_name' => $name,
|
||||
'tax_rate_priority' => $priority,
|
||||
'tax_rate_compound' => $compound,
|
||||
'tax_rate_shipping' => $shipping,
|
||||
'tax_rate_order' => $i,
|
||||
'tax_rate_class' => $current_class
|
||||
)
|
||||
);
|
||||
|
||||
$return .= $countries_text . ' ' . $states_text;
|
||||
$tax_rate_id = $wpdb->insert_id;
|
||||
|
||||
else :
|
||||
|
||||
if ($states_count>0) $states_text = sprintf(_n('and 1 state', 'and %s states', $states_count, 'woocommerce'), $states_count);
|
||||
|
||||
$return .= sprintf(_n('1 country', '%1$s countries', sizeof($counties_array), 'woocommerce'), sizeof($counties_array)) . ' ' . $states_text;
|
||||
|
||||
endif;
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* woocommerce_export_tax_rates function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function woocommerce_export_tax_rates() {
|
||||
|
||||
if ( empty( $_GET['wc_export_tax_rates'] ) )
|
||||
return;
|
||||
|
||||
global $woocommerce;
|
||||
|
||||
if ( ! class_exists('WC_CSV_Exporter') )
|
||||
include( $woocommerce->plugin_path() . '/admin/includes/class-wc-csv-exporter.php' );
|
||||
|
||||
$export = absint( $_GET['wc_export_tax_rates'] );
|
||||
|
||||
if ( $export == 1 ) {
|
||||
|
||||
$tax_rates = get_option('woocommerce_tax_rates');
|
||||
|
||||
$csv = new WC_CSV_Exporter( array( 'countries', 'class', 'label', 'rate', 'compound', 'shipping' ), true, 'tax_rates.csv' );
|
||||
|
||||
if ( $tax_rates )
|
||||
foreach( $tax_rates as $rate ) {
|
||||
|
||||
$countries = array();
|
||||
|
||||
foreach ( $rate['countries'] as $country => $states ) {
|
||||
foreach( $states as $state ) {
|
||||
if ( $state == '*' ) {
|
||||
$countries[] = $country;
|
||||
} else {
|
||||
$countries[] = $country . ':' . $state;
|
||||
}
|
||||
if ( ! empty( $postcode ) ) {
|
||||
$postcodes = explode( ';', $postcode );
|
||||
$postcodes = array_map( 'strtoupper', array_map( 'woocommerce_clean', $postcodes ) );
|
||||
foreach( $postcodes as $postcode ) {
|
||||
$wpdb->insert(
|
||||
$wpdb->prefix . "woocommerce_tax_rate_locations",
|
||||
array(
|
||||
'location_code' => $postcode,
|
||||
'tax_rate_id' => $tax_rate_id,
|
||||
'location_type' => 'postcode',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$csv->add_row( array(
|
||||
implode( ' | ', $countries ),
|
||||
$rate['class'],
|
||||
$rate['label'],
|
||||
$rate['rate'],
|
||||
$rate['compound'] == 'yes' ? 1 : 0,
|
||||
$rate['shipping'] == 'yes' ? 1 : 0
|
||||
) );
|
||||
}
|
||||
|
||||
$csv->end();
|
||||
|
||||
} else {
|
||||
|
||||
$tax_rates = get_option('woocommerce_local_tax_rates');
|
||||
|
||||
$csv = new WC_CSV_Exporter( array( 'country', 'state', 'postcode', 'class', 'label', 'rate', 'compound', 'shipping' ), true, 'local_tax_rates.csv' );
|
||||
|
||||
if ( $tax_rates )
|
||||
foreach( $tax_rates as $rate ) {
|
||||
$csv->add_row( array(
|
||||
$rate['country'],
|
||||
$rate['state'],
|
||||
implode( ' | ', $rate['postcode'] ),
|
||||
$rate['class'],
|
||||
$rate['label'],
|
||||
$rate['rate'],
|
||||
$rate['compound'] == 'yes' ? 1 : 0,
|
||||
$rate['shipping'] == 'yes' ? 1 : 0
|
||||
) );
|
||||
if ( ! empty( $city ) ) {
|
||||
$cities = explode( ';', $city );
|
||||
$cities = array_map( 'strtoupper', array_map( 'woocommerce_clean', $cities ) );
|
||||
foreach( $cities as $city ) {
|
||||
$wpdb->insert(
|
||||
$wpdb->prefix . "woocommerce_tax_rate_locations",
|
||||
array(
|
||||
'location_code' => $city,
|
||||
'tax_rate_id' => $tax_rate_id,
|
||||
'location_type' => 'city',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$csv->end();
|
||||
|
||||
|
||||
// ...whereas the others are updated
|
||||
} else {
|
||||
|
||||
$tax_rate_id = absint( $key );
|
||||
|
||||
if ( $_POST['remove_tax_rate'][ $key ] == 1 ) {
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rate_locations WHERE tax_rate_id = %d;", $tax_rate_id ) );
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d;", $tax_rate_id ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
// Sanitize + format
|
||||
$country = strtoupper( woocommerce_clean( $tax_rate_country[ $key ] ) );
|
||||
$state = strtoupper( woocommerce_clean( $tax_rate_state[ $key ] ) );
|
||||
$rate = number_format( woocommerce_clean( $tax_rate[ $key ] ), 4, '.', '' );
|
||||
$name = woocommerce_clean( $tax_rate_name[ $key ] );
|
||||
$priority = absint( woocommerce_clean( $tax_rate_priority[ $key ] ) );
|
||||
$compound = isset( $tax_rate_compound[ $key ] ) ? 1 : 0;
|
||||
$shipping = isset( $tax_rate_shipping[ $key ] ) ? 1 : 0;
|
||||
|
||||
if ( ! $name )
|
||||
$name = __( 'Tax', 'woocommerce' );
|
||||
|
||||
if ( $country == '*' )
|
||||
$country = '';
|
||||
|
||||
if ( $state == '*' )
|
||||
$state = '';
|
||||
|
||||
$wpdb->update(
|
||||
$wpdb->prefix . "woocommerce_tax_rates",
|
||||
array(
|
||||
'tax_rate_country' => $country,
|
||||
'tax_rate_state' => $state,
|
||||
'tax_rate' => $rate,
|
||||
'tax_rate_name' => $name,
|
||||
'tax_rate_priority' => $priority,
|
||||
'tax_rate_compound' => $compound,
|
||||
'tax_rate_shipping' => $shipping,
|
||||
'tax_rate_order' => $i,
|
||||
'tax_rate_class' => $current_class
|
||||
),
|
||||
array(
|
||||
'tax_rate_id' => $tax_rate_id
|
||||
)
|
||||
);
|
||||
|
||||
if ( isset( $tax_rate_postcode[ $key ] ) ) {
|
||||
// Delete old
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rate_locations WHERE tax_rate_id = %d AND location_type = 'postcode';", $tax_rate_id ) );
|
||||
|
||||
// Add changed
|
||||
$postcode = woocommerce_clean( $tax_rate_postcode[ $key ] );
|
||||
$postcodes = explode( ';', $postcode );
|
||||
$postcodes = array_map( 'strtoupper', array_map( 'woocommerce_clean', $postcodes ) );
|
||||
|
||||
$postcode_query = array();
|
||||
|
||||
foreach( $postcodes as $postcode )
|
||||
if ( strstr( $postcode, '-' ) ) {
|
||||
$postcode_parts = explode( '-', $postcode );
|
||||
|
||||
if ( is_numeric( $postcode_parts[0] ) && is_numeric( $postcode_parts[1] ) && $postcode_parts[1] > $postcode_parts[0] ) {
|
||||
for ( $i = $postcode_parts[0]; $i <= $postcode_parts[1]; $i ++ ) {
|
||||
$postcode_query[] = "( '$i', $tax_rate_id, 'postcode' )";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$postcode_query[] = "( '$postcode', $tax_rate_id, 'postcode' )";
|
||||
}
|
||||
|
||||
$wpdb->query( "INSERT INTO {$wpdb->prefix}woocommerce_tax_rate_locations ( location_code, tax_rate_id, location_type ) VALUES " . implode( ',', $postcode_query ) );
|
||||
|
||||
}
|
||||
|
||||
if ( isset( $tax_rate_city[ $key ] ) ) {
|
||||
// Delete old
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rate_locations WHERE tax_rate_id = %d AND location_type = 'city';", $tax_rate_id ) );
|
||||
|
||||
// Add changed
|
||||
$city = woocommerce_clean( $tax_rate_city[ $key ] );
|
||||
$cities = explode( ';', $city );
|
||||
$cities = array_map( 'strtoupper', array_map( 'woocommerce_clean', $cities ) );
|
||||
foreach( $cities as $city ) {
|
||||
$wpdb->insert(
|
||||
$wpdb->prefix . "woocommerce_tax_rate_locations",
|
||||
array(
|
||||
'location_code' => $city,
|
||||
'tax_rate_id' => $tax_rate_id,
|
||||
'location_type' => 'city',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ function woocommerce_attributes() {
|
|||
|
||||
check_admin_referer( 'woocommerce-add-new_attribute' );
|
||||
|
||||
$attribute_name = sanitize_title( esc_attr( $_POST['attribute_name'] ) );
|
||||
$attribute_name = woocommerce_sanitize_taxonomy_name( stripslashes( $_POST['attribute_name'] ) );
|
||||
$attribute_type = esc_attr( $_POST['attribute_type'] );
|
||||
$attribute_label = esc_attr( $_POST['attribute_label'] );
|
||||
$attribute_orderby = esc_attr( $_POST['attribute_orderby'] );
|
||||
|
@ -39,6 +39,9 @@ function woocommerce_attributes() {
|
|||
if ( ! $attribute_name )
|
||||
$attribute_name = sanitize_title( $attribute_label );
|
||||
|
||||
if ( strlen( $attribute_name ) >= 30 )
|
||||
echo '<div id="woocommerce_errors" class="error fade"><p>' . sprintf( __( 'Slug %s is too long', 'woocommerce' ), sanitize_title( $attribute_name ) ) . '</p></div>';
|
||||
|
||||
if ( $attribute_name && strlen( $attribute_name ) < 30 && $attribute_type && ! taxonomy_exists( $woocommerce->attribute_taxonomy_name( $attribute_name ) ) ) {
|
||||
|
||||
$wpdb->insert(
|
||||
|
@ -60,7 +63,7 @@ function woocommerce_attributes() {
|
|||
$edit = absint( $_GET['edit'] );
|
||||
check_admin_referer( 'woocommerce-save-attribute_' . $edit );
|
||||
|
||||
$attribute_name = sanitize_title( esc_attr( $_POST['attribute_name'] ) );
|
||||
$attribute_name = woocommerce_sanitize_taxonomy_name( stripslashes( $_POST['attribute_name'] ) );
|
||||
$attribute_type = esc_attr( $_POST['attribute_type'] );
|
||||
$attribute_label = esc_attr( $_POST['attribute_label'] );
|
||||
$attribute_orderby = esc_attr( $_POST['attribute_orderby'] );
|
||||
|
@ -71,7 +74,7 @@ function woocommerce_attributes() {
|
|||
if ( ! $attribute_name )
|
||||
$attribute_name = sanitize_title( $attribute_label );
|
||||
|
||||
$old_attribute_name = sanitize_title( $wpdb->get_var( "SELECT attribute_name FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_id = $edit" ) );
|
||||
$old_attribute_name = woocommerce_sanitize_taxonomy_name( $wpdb->get_var( "SELECT attribute_name FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_id = $edit" ) );
|
||||
|
||||
if ( $old_attribute_name != $attribute_name && taxonomy_exists( $woocommerce->attribute_taxonomy_name( $attribute_name ) ) ) {
|
||||
|
||||
|
@ -130,10 +133,10 @@ function woocommerce_attributes() {
|
|||
$wpdb->update(
|
||||
$wpdb->postmeta,
|
||||
array(
|
||||
'meta_key' => 'attribute_' . sanitize_title( $attribute_name )
|
||||
'meta_key' => 'attribute_pa_' . sanitize_title( $attribute_name )
|
||||
),
|
||||
array(
|
||||
'meta_key' => 'attribute_' . sanitize_title( $old_attribute_name )
|
||||
'meta_key' => 'attribute_pa_' . sanitize_title( $old_attribute_name )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -298,7 +301,7 @@ function woocommerce_add_attribute() {
|
|||
</td>
|
||||
<td><?php echo esc_html( $tax->attribute_name ); ?></td>
|
||||
<td><?php echo esc_html( ucwords( $tax->attribute_type ) ); ?></td>
|
||||
<td><?php
|
||||
<td><?php
|
||||
switch ( $tax->attribute_orderby ) {
|
||||
case 'name' :
|
||||
_e( 'Name', 'woocommerce' );
|
||||
|
@ -306,7 +309,7 @@ function woocommerce_add_attribute() {
|
|||
case 'id' :
|
||||
_e( 'Term ID', 'woocommerce' );
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
_e( 'Custom ordering', 'woocommerce' );
|
||||
break;
|
||||
}
|
||||
|
@ -364,7 +367,7 @@ function woocommerce_add_attribute() {
|
|||
</select>
|
||||
<p class="description"><?php _e( 'Determines how you select attributes for products. <strong>Text</strong> allows manual entry via the product page, whereas <strong>select</strong> attribute terms can be defined from this section. If you plan on using an attribute for variations use <strong>select</strong>.', 'woocommerce' ); ?></p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-field">
|
||||
<label for="attribute_orderby"><?php _e( 'Default sort order', 'woocommerce' ); ?></label>
|
||||
<select name="attribute_orderby" id="attribute_orderby">
|
||||
|
|
|
@ -44,7 +44,7 @@ function woocommerce_init_dashboard_widgets() {
|
|||
wp_add_dashboard_widget( 'woocommerce_dashboard_recent_orders', __( 'WooCommerce Recent Orders', 'woocommerce' ), 'woocommerce_dashboard_recent_orders');
|
||||
wp_add_dashboard_widget( 'woocommerce_dashboard_recent_reviews', __( 'WooCommerce Recent Reviews', 'woocommerce' ), 'woocommerce_dashboard_recent_reviews' );
|
||||
}
|
||||
|
||||
|
||||
if ( current_user_can( 'view_woocommerce_reports' ) || current_user_can( 'publish_shop_orders' ) ) {
|
||||
wp_add_dashboard_widget( 'woocommerce_dashboard_sales', $sales_heading, 'woocommerce_dashboard_sales' );
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ function woocommerce_dashboard_recent_orders() {
|
|||
*/
|
||||
function woocommerce_dashboard_recent_reviews() {
|
||||
global $wpdb;
|
||||
$comments = $wpdb->get_results( $wpdb->prepare( "SELECT *, SUBSTRING(comment_content,1,100) AS comment_excerpt
|
||||
$comments = $wpdb->get_results( "SELECT *, SUBSTRING(comment_content,1,100) AS comment_excerpt
|
||||
FROM $wpdb->comments
|
||||
LEFT JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID)
|
||||
WHERE comment_approved = '1'
|
||||
|
@ -263,7 +263,7 @@ function woocommerce_dashboard_recent_reviews() {
|
|||
AND post_password = ''
|
||||
AND post_type = 'product'
|
||||
ORDER BY comment_date_gmt DESC
|
||||
LIMIT 5" ) );
|
||||
LIMIT 5" );
|
||||
|
||||
if ( $comments ) {
|
||||
echo '<ul>';
|
||||
|
|
|
@ -83,30 +83,87 @@ function woocommerce_ms_protect_download_rewite_rules( $rewrite ) {
|
|||
* @return void
|
||||
*/
|
||||
function woocommerce_delete_post( $id ) {
|
||||
global $woocommerce, $wpdb;
|
||||
|
||||
if ( ! current_user_can( 'delete_posts' ) ) return;
|
||||
|
||||
if ( $id > 0 ) :
|
||||
if ( $id > 0 ) {
|
||||
|
||||
if ( $children_products =& get_children( 'post_parent='.$id.'&post_type=product_variation' ) ) :
|
||||
$post_type = get_post_type( $id );
|
||||
|
||||
if ($children_products) :
|
||||
switch( $post_type ) {
|
||||
case 'product' :
|
||||
|
||||
foreach ($children_products as $child) :
|
||||
if ( $children_products =& get_children( 'post_parent=' . $id . '&post_type=product_variation' ) )
|
||||
if ( $children_products )
|
||||
foreach ( $children_products as $child )
|
||||
wp_delete_post( $child->ID, true );
|
||||
|
||||
wp_delete_post( $child->ID, true );
|
||||
$woocommerce->clear_product_transients();
|
||||
|
||||
endforeach;
|
||||
break;
|
||||
case 'product_variation' :
|
||||
|
||||
endif;
|
||||
$woocommerce->clear_product_transients();
|
||||
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
delete_transient( 'woocommerce_processing_order_count' );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* woocommerce_trash_post function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $id
|
||||
* @return void
|
||||
*/
|
||||
function woocommerce_trash_post( $id ) {
|
||||
if ( $id > 0 ) {
|
||||
|
||||
$post_type = get_post_type( $id );
|
||||
|
||||
if ( 'shop_order' == $post_type ) {
|
||||
|
||||
// Delete count - meta doesn't work on trashed posts
|
||||
$user_id = get_post_meta( $id, '_customer_user', true );
|
||||
|
||||
if ( $user_id > 0 ) {
|
||||
delete_user_meta( $user_id, '_order_count' );
|
||||
}
|
||||
|
||||
delete_transient( 'woocommerce_processing_order_count' );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* woocommerce_untrash_post function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $id
|
||||
* @return void
|
||||
*/
|
||||
function woocommerce_untrash_post( $id ) {
|
||||
if ( $id > 0 ) {
|
||||
|
||||
$post_type = get_post_type( $id );
|
||||
|
||||
if ( 'shop_order' == $post_type ) {
|
||||
|
||||
// Delete count - meta doesn't work on trashed posts
|
||||
$user_id = get_post_meta( $id, '_customer_user', true );
|
||||
|
||||
if ( $user_id > 0 ) {
|
||||
delete_user_meta( $user_id, '_order_count' );
|
||||
}
|
||||
|
||||
delete_transient( 'woocommerce_processing_order_count' );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview Emails in WP admin
|
||||
|
@ -263,7 +320,7 @@ function woocommerce_add_shortcode_button() {
|
|||
|
||||
/**
|
||||
* woocommerce_add_tinymce_lang function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $arr
|
||||
* @return void
|
||||
|
@ -328,9 +385,9 @@ function woocommerce_refresh_mce( $ver ) {
|
|||
*/
|
||||
function woocommerce_create_term( $term_id, $tt_id = '', $taxonomy = '' ) {
|
||||
|
||||
if ( ! $taxonomy == 'product_cat' && ! strstr( $taxonomy, 'pa_' ) )
|
||||
if ( ! $taxonomy == 'product_cat' && ! strstr( $taxonomy, 'pa_' ) )
|
||||
return;
|
||||
|
||||
|
||||
$meta_name = strstr( $taxonomy, 'pa_' ) ? 'order_' . esc_attr( $taxonomy ) : 'order';
|
||||
|
||||
update_woocommerce_term_meta( $term_id, $meta_name, 0 );
|
||||
|
@ -348,7 +405,7 @@ function woocommerce_delete_term( $term_id ) {
|
|||
|
||||
$term_id = (int) $term_id;
|
||||
|
||||
if ( ! $term_id )
|
||||
if ( ! $term_id )
|
||||
return;
|
||||
|
||||
global $wpdb;
|
||||
|
|
|
@ -16,12 +16,16 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
* Events
|
||||
*
|
||||
* @see woocommerce_delete_post()
|
||||
* @see woocommerce_trash_post()
|
||||
* @see woocommerce_untrash_post()
|
||||
* @see woocommerce_preview_emails()
|
||||
* @see woocommerce_prevent_admin_access()
|
||||
* @see woocomerce_check_download_folder_protection()
|
||||
* @see woocommerce_ms_protect_download_rewite_rules()
|
||||
*/
|
||||
add_action('delete_post', 'woocommerce_delete_post');
|
||||
add_action('wp_trash_post', 'woocommerce_trash_post');
|
||||
add_action('untrash_post', 'woocommerce_untrash_post');
|
||||
add_action('admin_init', 'woocommerce_preview_emails');
|
||||
add_action('admin_init', 'woocommerce_prevent_admin_access');
|
||||
add_action('woocommerce_settings_saved', 'woocomerce_check_download_folder_protection');
|
||||
|
|
|
@ -141,7 +141,7 @@ add_action( 'admin_head', 'woocommerce_admin_menu_highlight' );
|
|||
|
||||
/**
|
||||
* woocommerce_admin_notices_styles function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -151,7 +151,7 @@ function woocommerce_admin_notices_styles() {
|
|||
wp_enqueue_style( 'woocommerce-activation', plugins_url( '/assets/css/activation.css', dirname( __FILE__ ) ) );
|
||||
add_action( 'admin_notices', 'woocommerce_admin_install_notices' );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
add_action( 'admin_print_styles', 'woocommerce_admin_notices_styles' );
|
||||
|
@ -159,38 +159,38 @@ add_action( 'admin_print_styles', 'woocommerce_admin_notices_styles' );
|
|||
|
||||
/**
|
||||
* woocommerce_admin_install_notices function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function woocommerce_admin_install_notices() {
|
||||
global $woocommerce;
|
||||
|
||||
|
||||
if ( get_option( 'woocommerce_needs_update' ) == 1 ) {
|
||||
|
||||
|
||||
include( 'includes/notice-update.php' );
|
||||
|
||||
|
||||
} elseif ( get_option( 'woocommerce_updated' ) == 1 ) {
|
||||
|
||||
|
||||
include( 'includes/notice-updated.php' );
|
||||
|
||||
|
||||
update_option( 'woocommerce_updated', 0 );
|
||||
update_option( 'woocommerce_installed', 0 );
|
||||
|
||||
|
||||
} elseif ( get_option( 'woocommerce_installed' ) == 1 ) {
|
||||
|
||||
|
||||
if ( get_option( 'skip_install_woocommerce_pages' ) != 1 && woocommerce_get_page_id( 'shop' ) < 1 && ! isset( $_GET['install_woocommerce_pages'] ) && !isset( $_GET['skip_install_woocommerce_pages'] ) ) {
|
||||
|
||||
|
||||
include( 'includes/notice-install.php' );
|
||||
|
||||
} elseif ( ! isset( $_GET['page'] ) || $_GET['page'] != 'woocommerce' ) {
|
||||
|
||||
|
||||
} elseif ( ! isset( $_GET['page'] ) || $_GET['page'] != 'woocommerce_settings' ) {
|
||||
|
||||
include( 'includes/notice-installed.php' );
|
||||
|
||||
|
||||
update_option( 'woocommerce_installed', 0 );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ function woocommerce_admin_init() {
|
|||
include_once( 'woocommerce-admin-users.php' );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Register importers
|
||||
if ( defined( 'WP_LOAD_IMPORTERS' ) ) {
|
||||
include_once( 'importers/importers-init.php' );
|
||||
|
@ -287,33 +287,9 @@ function woocommerce_status_page() {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* On activation, include the installer and run it.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function activate_woocommerce() {
|
||||
include_once( 'woocommerce-admin-install.php' );
|
||||
update_option( 'skip_install_woocommerce_pages', 0 );
|
||||
update_option( 'woocommerce_installed', 1 );
|
||||
do_install_woocommerce();
|
||||
}
|
||||
|
||||
/**
|
||||
* Include the installer and run it.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function install_woocommerce() {
|
||||
include_once( 'woocommerce-admin-install.php' );
|
||||
do_install_woocommerce();
|
||||
}
|
||||
|
||||
/**
|
||||
* update_woocommerce function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -354,19 +330,19 @@ function woocommerce_admin_scripts() {
|
|||
|
||||
// Register scripts
|
||||
wp_register_script( 'woocommerce_admin', $woocommerce->plugin_url() . '/assets/js/admin/woocommerce_admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui', 'jquery-placeholder', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip' ), $woocommerce->version );
|
||||
|
||||
|
||||
wp_register_script( 'jquery-blockui', $woocommerce->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), $woocommerce->version, true );
|
||||
|
||||
|
||||
wp_register_script( 'jquery-placeholder', $woocommerce->plugin_url() . '/assets/js/jquery-placeholder/jquery.placeholder' . $suffix . '.js', array( 'jquery' ), $woocommerce->version, true );
|
||||
|
||||
|
||||
wp_register_script( 'jquery-tiptip', $woocommerce->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), $woocommerce->version, true );
|
||||
|
||||
|
||||
wp_register_script( 'jquery-ui-datepicker', $woocommerce->plugin_url() . '/assets/js/admin/ui-datepicker.js', array('jquery','jquery-ui-core'), $woocommerce->version );
|
||||
|
||||
|
||||
wp_register_script( 'woocommerce_writepanel', $woocommerce->plugin_url() . '/assets/js/admin/write-panels'.$suffix.'.js', array('jquery', 'jquery-ui-datepicker'), $woocommerce->version );
|
||||
|
||||
|
||||
wp_register_script( 'ajax-chosen', $woocommerce->plugin_url() . '/assets/js/chosen/ajax-chosen.jquery'.$suffix.'.js', array('jquery', 'chosen'), $woocommerce->version );
|
||||
|
||||
|
||||
wp_register_script( 'chosen', $woocommerce->plugin_url() . '/assets/js/chosen/chosen.jquery'.$suffix.'.js', array('jquery'), $woocommerce->version );
|
||||
|
||||
// Get admin screen id
|
||||
|
@ -380,6 +356,7 @@ function woocommerce_admin_scripts() {
|
|||
wp_enqueue_script( 'ajax-chosen' );
|
||||
wp_enqueue_script( 'chosen' );
|
||||
wp_enqueue_script( 'jquery-ui-sortable' );
|
||||
wp_enqueue_script( 'jquery-ui-autocomplete' );
|
||||
|
||||
endif;
|
||||
|
||||
|
@ -428,11 +405,12 @@ function woocommerce_admin_scripts() {
|
|||
'ajax_url' => admin_url('admin-ajax.php'),
|
||||
'order_item_nonce' => wp_create_nonce("order-item"),
|
||||
'add_attribute_nonce' => wp_create_nonce("add-attribute"),
|
||||
'save_attributes_nonce' => wp_create_nonce("save-attributes"),
|
||||
'calc_totals_nonce' => wp_create_nonce("calc-totals"),
|
||||
'get_customer_details_nonce' => wp_create_nonce("get-customer-details"),
|
||||
'search_products_nonce' => wp_create_nonce("search-products"),
|
||||
'calendar_image' => $woocommerce->plugin_url().'/assets/images/calendar.png',
|
||||
'post_id' => $post->ID,
|
||||
'post_id' => $post->ID,
|
||||
'currency_format_num_decimals' => absint( get_option( 'woocommerce_price_num_decimals' ) ),
|
||||
'currency_format_symbol' => get_woocommerce_currency_symbol(),
|
||||
'currency_format_decimal_sep' => esc_attr( stripslashes( get_option( 'woocommerce_price_decimal_sep' ) ) ),
|
||||
|
@ -617,7 +595,7 @@ function woocommerce_exclude_image_from_product_page_field( $fields, $object ) {
|
|||
|
||||
$parent = get_post( $object->post_parent );
|
||||
|
||||
if ( $parent->post_type !== 'product' )
|
||||
if ( $parent->post_type !== 'product' )
|
||||
return $fields;
|
||||
|
||||
$exclude_image = get_post_meta( absint( $object->ID ), '_woocommerce_exclude_image', true );
|
||||
|
@ -768,7 +746,7 @@ add_filter( 'admin_comment_types_dropdown', 'woocommerce_admin_comment_types_dro
|
|||
|
||||
/**
|
||||
* woocommerce_permalink_settings function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -778,12 +756,12 @@ function woocommerce_permalink_settings() {
|
|||
|
||||
$permalinks = get_option( 'woocommerce_permalinks' );
|
||||
$product_permalink = $permalinks['product_base'];
|
||||
|
||||
|
||||
// Get shop page
|
||||
$shop_page_id = woocommerce_get_page_id( 'shop' );
|
||||
$base_slug = ( $shop_page_id > 0 && get_page( $shop_page_id ) ) ? get_page_uri( $shop_page_id ) : _x( 'shop', 'default-slug', 'woocommerce' );
|
||||
$product_base = _x( 'product', 'default-slug', 'woocommerce' );
|
||||
|
||||
|
||||
$structures = array(
|
||||
0 => '',
|
||||
1 => '/' . trailingslashit( $product_base ),
|
||||
|
@ -825,7 +803,7 @@ function woocommerce_permalink_settings() {
|
|||
jQuery('input.wctog').change(function() {
|
||||
jQuery('#woocommerce_permalink_structure').val( jQuery(this).val() );
|
||||
});
|
||||
|
||||
|
||||
jQuery('#woocommerce_permalink_structure').focus(function(){
|
||||
jQuery('#woocommerce_custom_selection').click();
|
||||
});
|
||||
|
@ -836,7 +814,7 @@ function woocommerce_permalink_settings() {
|
|||
|
||||
/**
|
||||
* woocommerce_permalink_settings_init function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -844,7 +822,7 @@ function woocommerce_permalink_settings_init() {
|
|||
|
||||
// Add a section to the permalinks page
|
||||
add_settings_section( 'woocommerce-permalink', __( 'Product permalink base', 'woocommerce' ), 'woocommerce_permalink_settings', 'permalink' );
|
||||
|
||||
|
||||
// Add our settings
|
||||
add_settings_field(
|
||||
'woocommerce_product_category_slug', // id
|
||||
|
@ -873,40 +851,40 @@ add_action( 'admin_init', 'woocommerce_permalink_settings_init' );
|
|||
|
||||
/**
|
||||
* woocommerce_permalink_settings_save function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function woocommerce_permalink_settings_save() {
|
||||
if ( ! is_admin() )
|
||||
return;
|
||||
|
||||
|
||||
// We need to save the options ourselves; settings api does not trigger save for the permalinks page
|
||||
if ( isset( $_POST['permalink_structure'] ) || isset( $_POST['category_base'] ) ) {
|
||||
// Cat and tag bases
|
||||
$woocommerce_product_category_slug = woocommerce_clean( $_POST['woocommerce_product_category_slug'] );
|
||||
$woocommerce_product_tag_slug = woocommerce_clean( $_POST['woocommerce_product_tag_slug'] );
|
||||
$woocommerce_product_attribute_slug = woocommerce_clean( $_POST['woocommerce_product_attribute_slug'] );
|
||||
|
||||
|
||||
$permalinks = get_option( 'woocommerce_permalinks' );
|
||||
if ( ! $permalinks )
|
||||
if ( ! $permalinks )
|
||||
$permalinks = array();
|
||||
|
||||
|
||||
$permalinks['category_base'] = untrailingslashit( $woocommerce_product_category_slug );
|
||||
$permalinks['tag_base'] = untrailingslashit( $woocommerce_product_tag_slug );
|
||||
$permalinks['attribute_base'] = untrailingslashit( $woocommerce_product_attribute_slug );
|
||||
|
||||
|
||||
// Product base
|
||||
$product_permalink = woocommerce_clean( $_POST['product_permalink'] );
|
||||
|
||||
|
||||
if ( $product_permalink == 'custom' ) {
|
||||
$product_permalink = woocommerce_clean( $_POST['product_permalink_structure'] );
|
||||
} elseif ( empty( $product_permalink ) ) {
|
||||
$product_permalink = false;
|
||||
}
|
||||
|
||||
|
||||
$permalinks['product_base'] = untrailingslashit( $product_permalink );
|
||||
|
||||
|
||||
update_option( 'woocommerce_permalinks', $permalinks );
|
||||
}
|
||||
}
|
||||
|
@ -915,7 +893,7 @@ add_action( 'before_woocommerce_init', 'woocommerce_permalink_settings_save' );
|
|||
|
||||
/**
|
||||
* woocommerce_product_category_slug_input function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -928,7 +906,7 @@ function woocommerce_product_category_slug_input() {
|
|||
|
||||
/**
|
||||
* woocommerce_product_tag_slug_input function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -941,7 +919,7 @@ function woocommerce_product_tag_slug_input() {
|
|||
|
||||
/**
|
||||
* woocommerce_product_attribute_slug_input function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/Install
|
||||
* @version 1.7.0
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -20,21 +20,25 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
*/
|
||||
function do_install_woocommerce() {
|
||||
global $woocommerce_settings, $woocommerce;
|
||||
|
||||
|
||||
// Do install
|
||||
woocommerce_default_options();
|
||||
woocommerce_tables_install();
|
||||
woocommerce_init_roles();
|
||||
|
||||
|
||||
// Register post types
|
||||
$woocommerce->init_taxonomy();
|
||||
|
||||
// Add default taxonomies
|
||||
woocommerce_default_taxonomies();
|
||||
|
||||
// Cron jobs
|
||||
wp_clear_scheduled_hook( 'woocommerce_scheduled_sales' );
|
||||
wp_schedule_event( strtotime( 'tomorrow' ), 'daily', 'woocommerce_scheduled_sales');
|
||||
|
||||
// Install files and folders for uploading files and prevent hotlinking
|
||||
$upload_dir = wp_upload_dir();
|
||||
|
||||
|
||||
$files = array(
|
||||
array(
|
||||
'base' => $upload_dir['basedir'] . '/woocommerce_uploads',
|
||||
|
@ -57,7 +61,7 @@ function do_install_woocommerce() {
|
|||
'content' => ''
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
foreach ( $files as $file ) {
|
||||
if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) {
|
||||
if ( $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ) ) {
|
||||
|
@ -77,19 +81,19 @@ function do_install_woocommerce() {
|
|||
|
||||
if ( ( ! empty( $colors['primary'] ) && ! empty( $colors['secondary'] ) && ! empty( $colors['highlight'] ) && ! empty( $colors['content_bg'] ) && ! empty( $colors['subtext'] ) ) && ( $colors['primary'] != '#ad74a2' || $colors['secondary'] != '#f7f6f7' || $colors['highlight'] != '#85ad74' || $colors['content_bg'] != '#ffffff' || $colors['subtext'] != '#777777' ) )
|
||||
woocommerce_compile_less_styles();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Queue upgrades
|
||||
$current_version = get_option( 'woocommerce_version', null );
|
||||
$current_db_version = get_option( 'woocommerce_db_version', null );
|
||||
|
||||
if ( version_compare( $current_db_version, '1.7', '<' ) && null !== $current_version ) {
|
||||
|
||||
if ( version_compare( $current_db_version, '2.0', '<' ) && null !== $current_version ) {
|
||||
update_option( 'woocommerce_needs_update', 1 );
|
||||
} else {
|
||||
update_option( 'woocommerce_db_version', $woocommerce->version );
|
||||
}
|
||||
|
||||
|
||||
// Update version
|
||||
update_option( 'woocommerce_version', $woocommerce->version );
|
||||
}
|
||||
|
@ -111,13 +115,8 @@ function woocommerce_default_options() {
|
|||
|
||||
foreach ( $woocommerce_settings as $section ) {
|
||||
foreach ( $section as $value ) {
|
||||
if ( isset( $value['std'] ) && isset( $value['id'] ) ) {
|
||||
if ( $value['type'] == 'image_width' ) {
|
||||
add_option( $value['id'] . '_width', $value['std'] );
|
||||
add_option( $value['id'] . '_height', $value['std'] );
|
||||
} else {
|
||||
add_option( $value['id'], $value['std'] );
|
||||
}
|
||||
if ( isset( $value['default'] ) && isset( $value['id'] ) ) {
|
||||
add_option( $value['id'], $value['default'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -222,9 +221,9 @@ function woocommerce_tables_install() {
|
|||
|
||||
$collate = '';
|
||||
if ( $wpdb->has_cap( 'collation' ) ) {
|
||||
if( ! empty($wpdb->charset ) )
|
||||
if( ! empty($wpdb->charset ) )
|
||||
$collate .= "DEFAULT CHARACTER SET $wpdb->charset";
|
||||
if( ! empty($wpdb->collate ) )
|
||||
if( ! empty($wpdb->collate ) )
|
||||
$collate .= " COLLATE $wpdb->collate";
|
||||
}
|
||||
|
||||
|
@ -254,7 +253,7 @@ CREATE TABLE ". $wpdb->prefix . "woocommerce_termmeta (
|
|||
) $collate;
|
||||
";
|
||||
dbDelta( $sql );
|
||||
|
||||
|
||||
// Table for storing user and guest download permissions
|
||||
// KEY(order_id, product_id, download_id) used for organizing downloads on the My Account page
|
||||
$sql = "
|
||||
|
@ -274,19 +273,19 @@ CREATE TABLE ". $wpdb->prefix . "woocommerce_downloadable_product_permissions (
|
|||
) $collate;
|
||||
";
|
||||
dbDelta( $sql );
|
||||
|
||||
|
||||
// Order line items are stored in a table to make them easily queryable for reports
|
||||
$sql = "
|
||||
CREATE TABLE ". $wpdb->prefix . "woocommerce_order_items (
|
||||
order_item_id bigint(20) NOT NULL auto_increment,
|
||||
order_item_name longtext NOT NULL DEFAULT '',
|
||||
order_item_type varchar(200) NOT NULL DEFAULT '',
|
||||
order_id bigint(20) NOT NULL,
|
||||
order_id bigint(20) NOT NULL,
|
||||
PRIMARY KEY (order_item_id)
|
||||
) $collate;
|
||||
";
|
||||
dbDelta( $sql );
|
||||
|
||||
|
||||
// Order line item meta is stored in a table for storing extra data.
|
||||
$sql = "
|
||||
CREATE TABLE ". $wpdb->prefix . "woocommerce_order_itemmeta (
|
||||
|
@ -296,6 +295,36 @@ CREATE TABLE ". $wpdb->prefix . "woocommerce_order_itemmeta (
|
|||
meta_value longtext NULL,
|
||||
PRIMARY KEY (meta_id)
|
||||
) $collate;
|
||||
";
|
||||
dbDelta( $sql );
|
||||
|
||||
// Tax Rates are stored inside 2 tables making tax queries simple and efficient.
|
||||
$sql = "
|
||||
CREATE TABLE ". $wpdb->prefix . "woocommerce_tax_rates (
|
||||
tax_rate_id bigint(20) NOT NULL auto_increment,
|
||||
tax_rate_country varchar(200) NOT NULL DEFAULT '',
|
||||
tax_rate_state varchar(200) NOT NULL DEFAULT '',
|
||||
tax_rate varchar(200) NOT NULL DEFAULT '',
|
||||
tax_rate_name varchar(200) NOT NULL DEFAULT '',
|
||||
tax_rate_priority bigint(20) NOT NULL,
|
||||
tax_rate_compound int(1) NOT NULL DEFAULT 0,
|
||||
tax_rate_shipping int(1) NOT NULL DEFAULT 1,
|
||||
tax_rate_order bigint(20) NOT NULL,
|
||||
tax_rate_class varchar(200) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (tax_rate_id)
|
||||
) $collate;
|
||||
";
|
||||
dbDelta( $sql );
|
||||
|
||||
// Each rate can be applied to more than one postcode/city hence the second table.
|
||||
$sql = "
|
||||
CREATE TABLE ". $wpdb->prefix . "woocommerce_tax_rate_locations (
|
||||
location_id bigint(20) NOT NULL auto_increment,
|
||||
location_code varchar(255) NOT NULL,
|
||||
tax_rate_id bigint(20) NOT NULL,
|
||||
location_type varchar(40) NOT NULL,
|
||||
PRIMARY KEY (location_id)
|
||||
) $collate;
|
||||
";
|
||||
dbDelta( $sql );
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ if ( ! function_exists( 'woocommerce_settings' ) ) {
|
|||
* @return void
|
||||
*/
|
||||
function woocommerce_settings() {
|
||||
global $woocommerce, $woocommerce_settings;
|
||||
|
||||
global $woocommerce, $woocommerce_settings, $current_section, $current_tab;
|
||||
|
||||
do_action( 'woocommerce_settings_start' );
|
||||
|
||||
// Get current tab/section
|
||||
|
@ -56,10 +56,11 @@ if ( ! function_exists( 'woocommerce_settings' ) ) {
|
|||
case "pages" :
|
||||
case "catalog" :
|
||||
case "inventory" :
|
||||
case "payment" :
|
||||
case "shipping" :
|
||||
case "tax" :
|
||||
case "email" :
|
||||
woocommerce_update_options( $woocommerce_settings[$current_tab] );
|
||||
woocommerce_update_options( $woocommerce_settings[ $current_tab ] );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -95,23 +96,30 @@ if ( ! function_exists( 'woocommerce_settings' ) ) {
|
|||
|
||||
// If saving a shipping methods options, load 'er up
|
||||
if ( $current_tab == 'shipping' && class_exists( $current_section ) ) {
|
||||
|
||||
|
||||
$current_section_class = new $current_section();
|
||||
do_action( 'woocommerce_update_options_' . $current_tab . '_' . $current_section_class->id );
|
||||
|
||||
|
||||
// If saving an email's options, load theme
|
||||
} elseif ( $current_tab == 'email' ) {
|
||||
|
||||
|
||||
// Load mailer
|
||||
$mailer = $woocommerce->mailer();
|
||||
|
||||
|
||||
if ( class_exists( $current_section ) ) {
|
||||
$current_section_class = new $current_section();
|
||||
do_action( 'woocommerce_update_options_' . $current_tab . '_' . $current_section_class->id );
|
||||
} else {
|
||||
do_action( 'woocommerce_update_options_' . $current_tab . '_' . $current_section );
|
||||
}
|
||||
|
||||
|
||||
// Save tax
|
||||
} elseif ( $current_tab == 'tax' ) {
|
||||
|
||||
include_once('settings/settings-tax-rates.php');
|
||||
|
||||
woocommerce_tax_rates_setting_save();
|
||||
|
||||
} else {
|
||||
|
||||
// Save section only
|
||||
|
@ -237,8 +245,31 @@ if ( ! function_exists( 'woocommerce_settings' ) ) {
|
|||
woocommerce_admin_fields( $woocommerce_settings[$current_tab] );
|
||||
break;
|
||||
case "tax" :
|
||||
include('settings/settings-tax-rates.php');
|
||||
woocommerce_admin_fields( $woocommerce_settings[$current_tab] );
|
||||
|
||||
$links = array(
|
||||
'<a href="' . admin_url( 'admin.php?page=woocommerce_settings&tab=tax' ) . '" class="' . ( $current_section == '' ? 'current' : '' ) . '">' . __( 'Tax Options', 'woocommerce' ) . '</a>'
|
||||
);
|
||||
|
||||
// Get tax classes and display as links
|
||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('woocommerce_tax_classes' ) ) ) );
|
||||
|
||||
$links[] = __( 'Tax Rates', 'woocommerce' ) . ': <a href="' . admin_url( 'admin.php?page=woocommerce_settings&tab=tax§ion=standard' ) . '" class="' . ( $current_section == 'standard' ? 'current' : '' ) . '">' . __( 'Standard', 'woocommerce' ) . '</a>';
|
||||
|
||||
if ( $tax_classes )
|
||||
foreach ( $tax_classes as $class )
|
||||
$links[] = '<a href="' . admin_url( 'admin.php?page=woocommerce_settings&tab=tax§ion=' . sanitize_title( $class ) ) . '" class="' . ( $current_section == sanitize_title( $class ) ? 'current' : '' ) . '">' . $class . '</a>';
|
||||
|
||||
echo '<ul class="subsubsub"><li>' . implode( ' | </li><li>', $links ) . '</li></ul><br class="clear" />';
|
||||
|
||||
if ( $current_section == 'standard' || in_array( $current_section, array_map( 'sanitize_title', $tax_classes ) ) ) {
|
||||
|
||||
include_once('settings/settings-tax-rates.php');
|
||||
|
||||
woocommerce_tax_rates_setting();
|
||||
|
||||
} else {
|
||||
woocommerce_admin_fields( $woocommerce_settings[ $current_tab ] );
|
||||
}
|
||||
break;
|
||||
case "pages" :
|
||||
case "catalog" :
|
||||
|
@ -246,7 +277,7 @@ if ( ! function_exists( 'woocommerce_settings' ) ) {
|
|||
woocommerce_admin_fields( $woocommerce_settings[$current_tab] );
|
||||
break;
|
||||
case "email" :
|
||||
|
||||
|
||||
$current = $current_section ? '' : 'class="current"';
|
||||
|
||||
$links = array( '<a href="' . admin_url( 'admin.php?page=woocommerce_settings&tab=email' ) . '" ' . $current . '>' . __( 'Email Options', 'woocommerce' ) . '</a>' );
|
||||
|
@ -266,7 +297,7 @@ if ( ! function_exists( 'woocommerce_settings' ) ) {
|
|||
}
|
||||
|
||||
echo '<ul class="subsubsub"><li>' . implode( ' | </li><li>', $links ) . '</li></ul><br class="clear" />';
|
||||
|
||||
|
||||
// Specific email options
|
||||
if ( $current_section ) {
|
||||
foreach ( $email_templates as $email ) {
|
||||
|
@ -373,7 +404,9 @@ if ( ! function_exists( 'woocommerce_settings' ) ) {
|
|||
endswitch;
|
||||
?>
|
||||
<p class="submit">
|
||||
<input name="save" class="button-primary" type="submit" value="<?php _e( 'Save changes', 'woocommerce' ); ?>" />
|
||||
<?php if ( ! isset( $GLOBALS['hide_save_button'] ) ) : ?>
|
||||
<input name="save" class="button-primary" type="submit" value="<?php _e( 'Save changes', 'woocommerce' ); ?>" />
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="subtab" id="last_tab" />
|
||||
</p>
|
||||
</form>
|
||||
|
@ -487,6 +520,45 @@ if ( ! function_exists( 'woocommerce_settings' ) ) {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a setting from the settings API.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $option
|
||||
* @return void
|
||||
*/
|
||||
function woocommerce_settings_get_option( $option_name, $default = '' ) {
|
||||
// Array value
|
||||
if ( strstr( $option_name, '[' ) ) {
|
||||
|
||||
parse_str( $option_name, $option_array );
|
||||
|
||||
// Option name is first key
|
||||
$option_name = current( array_keys( $option_array ) );
|
||||
|
||||
// Get value
|
||||
$option_values = get_option( $option_name, '' );
|
||||
|
||||
$key = key( $option_array[ $option_name ] );
|
||||
|
||||
if ( isset( $option_values[ $key ] ) )
|
||||
$option_value = $option_values[ $key ];
|
||||
else
|
||||
$option_value = null;
|
||||
|
||||
// Single value
|
||||
} else {
|
||||
$option_value = get_option( $option_name, null );
|
||||
}
|
||||
|
||||
if ( is_array( $option_value ) )
|
||||
$option_value = array_map( 'stripslashes', $option_value );
|
||||
elseif ( $option_value )
|
||||
$option_value = stripslashes( $option_value );
|
||||
|
||||
return $option_value == null ? $default : $option_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output admin fields.
|
||||
*
|
||||
|
@ -502,144 +574,279 @@ function woocommerce_admin_fields( $options ) {
|
|||
foreach ( $options as $value ) {
|
||||
if ( ! isset( $value['type'] ) ) continue;
|
||||
if ( ! isset( $value['id'] ) ) $value['id'] = '';
|
||||
if ( ! isset( $value['name'] ) ) $value['name'] = '';
|
||||
if ( ! isset( $value['title'] ) ) $value['title'] = isset( $value['name'] ) ? $value['name'] : '';
|
||||
if ( ! isset( $value['class'] ) ) $value['class'] = '';
|
||||
if ( ! isset( $value['css'] ) ) $value['css'] = '';
|
||||
if ( ! isset( $value['std'] ) ) $value['std'] = '';
|
||||
if ( ! isset( $value['default'] ) ) $value['default'] = '';
|
||||
if ( ! isset( $value['desc'] ) ) $value['desc'] = '';
|
||||
if ( ! isset( $value['desc_tip'] ) ) $value['desc_tip'] = false;
|
||||
|
||||
if ( $value['desc_tip'] === true ) {
|
||||
$description = '<img class="help_tip" data-tip="' . esc_attr( $value['desc'] ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" />';
|
||||
} elseif ( $value['desc_tip'] ) {
|
||||
$description = '<img class="help_tip" data-tip="' . esc_attr( $value['desc_tip'] ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" />';
|
||||
} else {
|
||||
$description = '<span class="description">' . wp_kses_post( $value['desc'] ) . '</span>';
|
||||
}
|
||||
// Custom attribute handling
|
||||
$custom_attributes = array();
|
||||
|
||||
if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) )
|
||||
foreach ( $value['custom_attributes'] as $attribute => $attribute_value )
|
||||
$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
|
||||
|
||||
// Description handling
|
||||
if ( $value['desc_tip'] === true ) {
|
||||
$description = '';
|
||||
$tip = $value['desc'];
|
||||
} elseif ( ! empty( $value['desc_tip'] ) ) {
|
||||
$description = $value['desc'];
|
||||
$tip = $value['desc_tip'];
|
||||
} elseif ( ! empty( $value['desc'] ) ) {
|
||||
$description = $value['desc'];
|
||||
$tip = '';
|
||||
} else {
|
||||
$description = $tip = '';
|
||||
}
|
||||
|
||||
if ( $description && in_array( $value['type'], array( 'textarea', 'radio' ) ) ) {
|
||||
$description = '<p style="margin-top:0">' . wp_kses_post( $description ) . '</p>';
|
||||
} elseif ( $description ) {
|
||||
$description = '<span class="description">' . wp_kses_post( $description ) . '</span>';
|
||||
}
|
||||
|
||||
if ( $tip && in_array( $value['type'], array( 'checkbox' ) ) ) {
|
||||
$tip = '<span class="help_tip" data-tip="' . esc_attr( $tip ) . '">[?]</span>';
|
||||
} elseif ( $tip ) {
|
||||
$tip = '<img class="help_tip" data-tip="' . esc_attr( $tip ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" height="16" width="16" />';
|
||||
}
|
||||
|
||||
// Switch based on type
|
||||
switch( $value['type'] ) {
|
||||
|
||||
// Section Titles
|
||||
case 'title':
|
||||
if ( isset($value['name'] ) && $value['name'] ) echo '<h3>' . esc_html( $value['name'] ) . '</h3>';
|
||||
if ( isset($value['desc'] ) && $value['desc'] ) echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) );
|
||||
if ( ! empty( $value['title'] ) ) echo '<h3>' . esc_html( $value['title'] ) . '</h3>';
|
||||
if ( ! empty( $value['desc'] ) ) echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) );
|
||||
echo '<table class="form-table">'. "\n\n";
|
||||
if ( isset($value['id'] ) && $value['id'] ) do_action( 'woocommerce_settings_' . sanitize_title($value['id'] ) );
|
||||
if ( ! empty( $value['id'] ) ) do_action( 'woocommerce_settings_' . sanitize_title( $value['id'] ) );
|
||||
break;
|
||||
|
||||
// Section Ends
|
||||
case 'sectionend':
|
||||
if ( isset($value['id'] ) && $value['id'] ) do_action( 'woocommerce_settings_' . sanitize_title( $value['id'] ) . '_end' );
|
||||
if ( ! empty( $value['id'] ) ) do_action( 'woocommerce_settings_' . sanitize_title( $value['id'] ) . '_end' );
|
||||
echo '</table>';
|
||||
if ( isset($value['id'] ) && $value['id'] ) do_action( 'woocommerce_settings_' . sanitize_title( $value['id'] ) . '_after' );
|
||||
if ( ! empty( $value['id'] ) ) do_action( 'woocommerce_settings_' . sanitize_title( $value['id'] ) . '_after' );
|
||||
break;
|
||||
|
||||
// Standard text inputs and subtypes like 'number'
|
||||
case 'text':
|
||||
?><tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['name'] ); ?></label>
|
||||
</th>
|
||||
<td class="forminp"><input name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'] ); ?>" type="<?php echo esc_attr( $value['type'] ); ?>" style="<?php echo esc_attr( $value['css'] ); ?>" value="<?php if ( get_option( $value['id'] ) !== false && get_option( $value['id'] ) !== null ) { echo esc_attr( stripslashes( get_option($value['id'] ) ) ); } else { echo esc_attr( $value['std'] ); } ?>" /> <?php echo $description; ?></td>
|
||||
</tr><?php
|
||||
break;
|
||||
case 'email':
|
||||
case 'number':
|
||||
case 'color' :
|
||||
|
||||
$type = $value['type'];
|
||||
$class = '';
|
||||
$option_value = woocommerce_settings_get_option( $value['id'], $value['default'] );
|
||||
|
||||
if ( $value['type'] == 'color' ) {
|
||||
$type = 'text';
|
||||
$value['class'] .= 'colorpick';
|
||||
$description .= '<div id="colorPickerDiv_' . esc_attr( $value['id'] ) . '" class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>';
|
||||
}
|
||||
|
||||
?><tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['name'] ); ?></label>
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||
<?php echo $tip; ?>
|
||||
</th>
|
||||
<td class="forminp"><input name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'] ); ?>" type="text" style="<?php echo esc_attr( $value['css'] ); ?>" value="<?php if ( get_option( $value['id'] ) !== false && get_option( $value['id'] ) !== null ) { echo esc_attr( stripslashes( get_option($value['id'] ) ) ); } else { echo esc_attr( $value['std'] ); } ?>" class="colorpick" /> <?php echo $description; ?> <div id="colorPickerDiv_<?php echo esc_attr( $value['id'] ); ?>" class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div></td>
|
||||
<td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
|
||||
<input
|
||||
name="<?php echo esc_attr( $value['id'] ); ?>"
|
||||
id="<?php echo esc_attr( $value['id'] ); ?>"
|
||||
type="<?php echo esc_attr( $type ); ?>"
|
||||
style="<?php echo esc_attr( $value['css'] ); ?>"
|
||||
value="<?php echo esc_attr( $option_value ); ?>"
|
||||
class="<?php echo esc_attr( $value['class'] ); ?>"
|
||||
<?php echo implode( ' ', $custom_attributes ); ?>
|
||||
/> <?php echo $description; ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
case 'image_width' :
|
||||
?><tr valign="top">
|
||||
<th scope="row" class="titledesc"><?php echo esc_html( $value['name'] ) ?></th>
|
||||
<td class="forminp">
|
||||
|
||||
<?php _e( 'Width', 'woocommerce' ); ?> <input name="<?php echo esc_attr( $value['id'] ); ?>_width" id="<?php echo esc_attr( $value['id'] ); ?>_width" type="text" size="3" value="<?php if ( $size = get_option( $value['id'].'_width') ) echo stripslashes($size); else echo $value['std']; ?>" />
|
||||
// Textarea
|
||||
case 'textarea':
|
||||
|
||||
<?php _e( 'Height', 'woocommerce' ); ?> <input name="<?php echo esc_attr( $value['id'] ); ?>_height" id="<?php echo esc_attr( $value['id'] ); ?>_height" type="text" size="3" value="<?php if ( $size = get_option( $value['id'].'_height') ) echo stripslashes($size); else echo $value['std']; ?>" />
|
||||
$option_value = woocommerce_settings_get_option( $value['id'], $value['default'] );
|
||||
|
||||
<label><?php _e( 'Hard Crop', 'woocommerce' ); ?> <input name="<?php echo esc_attr( $value['id'] ); ?>_crop" id="<?php echo esc_attr( $value['id'] ); ?>_crop" type="checkbox" <?php if (get_option( $value['id'].'_crop')!='') checked(get_option( $value['id'].'_crop'), 1); else checked(1); ?> /></label>
|
||||
|
||||
<?php echo $description; ?></td>
|
||||
</tr><?php
|
||||
break;
|
||||
case 'select':
|
||||
?><tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['name'] ); ?></label>
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||
<?php echo $tip; ?>
|
||||
</th>
|
||||
<td class="forminp"><select name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'] ); ?>" style="<?php echo esc_attr( $value['css'] ); ?>" class="<?php if (isset($value['class'])) echo $value['class']; ?>">
|
||||
<?php
|
||||
foreach ($value['options'] as $key => $val) {
|
||||
$_current = get_option( $value['id'] );
|
||||
if ( ! $_current ) {
|
||||
$_current = $value['std'];
|
||||
}
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $_current, $key ); ?>><?php echo $val ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
|
||||
<?php echo $description; ?>
|
||||
|
||||
<textarea
|
||||
name="<?php echo esc_attr( $value['id'] ); ?>"
|
||||
id="<?php echo esc_attr( $value['id'] ); ?>"
|
||||
style="<?php echo esc_attr( $value['css'] ); ?>"
|
||||
class="<?php echo esc_attr( $value['class'] ); ?>"
|
||||
<?php echo implode( ' ', $custom_attributes ); ?>
|
||||
><?php echo esc_textarea( $option_value ); ?></textarea>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
|
||||
// Select boxes
|
||||
case 'select' :
|
||||
case 'multiselect' :
|
||||
|
||||
$option_value = woocommerce_settings_get_option( $value['id'], $value['default'] );
|
||||
|
||||
?><tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||
<?php echo $tip; ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
|
||||
<select
|
||||
name="<?php echo esc_attr( $value['id'] ); ?>"
|
||||
id="<?php echo esc_attr( $value['id'] ); ?>"
|
||||
style="<?php echo esc_attr( $value['css'] ); ?>"
|
||||
class="<?php echo esc_attr( $value['class'] ); ?>"
|
||||
<?php echo implode( ' ', $custom_attributes ); ?>
|
||||
<?php if ( $value['type'] == 'multiselect' ) echo 'multiple="multiple"'; ?>
|
||||
>
|
||||
<?php
|
||||
foreach ( $value['options'] as $key => $val ) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php
|
||||
|
||||
if ( is_array( $option_value ) )
|
||||
selected( in_array( $key, $option_value ), true );
|
||||
else
|
||||
selected( $option_value, $key );
|
||||
|
||||
?>><?php echo $val ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select> <?php echo $description; ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
|
||||
// Radio inputs
|
||||
case 'radio' :
|
||||
|
||||
$option_value = woocommerce_settings_get_option( $value['id'], $value['default'] );
|
||||
|
||||
?><tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||
<?php echo $tip; ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
|
||||
<fieldset>
|
||||
<?php echo $description; ?>
|
||||
<ul>
|
||||
<?php
|
||||
foreach ( $value['options'] as $key => $val ) {
|
||||
?>
|
||||
<li>
|
||||
<label><input
|
||||
name="<?php echo esc_attr( $value['id'] ); ?>"
|
||||
value="<?php echo $key; ?>"
|
||||
type="radio"
|
||||
style="<?php echo esc_attr( $value['css'] ); ?>"
|
||||
class="<?php echo esc_attr( $value['class'] ); ?>"
|
||||
<?php echo implode( ' ', $custom_attributes ); ?>
|
||||
<?php checked( $key, $option_value ); ?>
|
||||
/> <?php echo $val ?></label>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
|
||||
// Checkbox input
|
||||
case 'checkbox' :
|
||||
|
||||
if (!isset($value['hide_if_checked'])) $value['hide_if_checked'] = false;
|
||||
if (!isset($value['show_if_checked'])) $value['show_if_checked'] = false;
|
||||
$option_value = woocommerce_settings_get_option( $value['id'], $value['default'] );
|
||||
|
||||
if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup']=='start')) :
|
||||
if ( ! isset( $value['hide_if_checked'] ) ) $value['hide_if_checked'] = false;
|
||||
if ( ! isset( $value['show_if_checked'] ) ) $value['show_if_checked'] = false;
|
||||
|
||||
if ( ! isset( $value['checkboxgroup'] ) || ( isset( $value['checkboxgroup'] ) && $value['checkboxgroup'] == 'start' ) ) {
|
||||
?>
|
||||
<tr valign="top" class="<?php
|
||||
if ($value['hide_if_checked']=='yes' || $value['show_if_checked']=='yes') echo 'hidden_option';
|
||||
if ($value['hide_if_checked']=='option') echo 'hide_options_if_checked';
|
||||
if ($value['show_if_checked']=='option') echo 'show_options_if_checked';
|
||||
if ( $value['hide_if_checked'] == 'yes' || $value['show_if_checked']=='yes') echo 'hidden_option';
|
||||
if ( $value['hide_if_checked'] == 'option' ) echo 'hide_options_if_checked';
|
||||
if ( $value['show_if_checked'] == 'option' ) echo 'show_options_if_checked';
|
||||
?>">
|
||||
<th scope="row" class="titledesc"><?php echo esc_html( $value['name'] ) ?></th>
|
||||
<td class="forminp">
|
||||
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ) ?></th>
|
||||
<td class="forminp forminp-checkbox">
|
||||
<fieldset>
|
||||
<?php
|
||||
else :
|
||||
} else {
|
||||
?>
|
||||
<fieldset class="<?php
|
||||
if ($value['hide_if_checked']=='yes' || $value['show_if_checked']=='yes') echo 'hidden_option';
|
||||
if ($value['hide_if_checked']=='option') echo 'hide_options_if_checked';
|
||||
if ($value['show_if_checked']=='option') echo 'show_options_if_checked';
|
||||
if ( $value['hide_if_checked'] == 'yes' || $value['show_if_checked'] == 'yes') echo 'hidden_option';
|
||||
if ( $value['hide_if_checked'] == 'option') echo 'hide_options_if_checked';
|
||||
if ( $value['show_if_checked'] == 'option') echo 'show_options_if_checked';
|
||||
?>">
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
|
||||
?>
|
||||
<legend class="screen-reader-text"><span><?php echo esc_html( $value['name'] ) ?></span></legend>
|
||||
<legend class="screen-reader-text"><span><?php echo esc_html( $value['title'] ) ?></span></legend>
|
||||
|
||||
<label for="<?php echo $value['id'] ?>">
|
||||
<input name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'] ); ?>" type="checkbox" value="1" <?php checked(get_option($value['id']), 'yes'); ?> />
|
||||
<?php echo wp_kses_post( $value['desc'] ) ?></label> <?php if ( $value['desc_tip'] ) echo $description; ?><br />
|
||||
<input
|
||||
name="<?php echo esc_attr( $value['id'] ); ?>"
|
||||
id="<?php echo esc_attr( $value['id'] ); ?>"
|
||||
type="checkbox"
|
||||
value="1"
|
||||
<?php checked( $option_value, 'yes'); ?>
|
||||
<?php echo implode( ' ', $custom_attributes ); ?>
|
||||
/> <?php echo wp_kses_post( $value['desc'] ) ?></label> <?php echo $tip; ?><br />
|
||||
<?php
|
||||
|
||||
if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup']=='end')) :
|
||||
if ( ! isset( $value['checkboxgroup'] ) || ( isset( $value['checkboxgroup'] ) && $value['checkboxgroup'] == 'end' ) ) {
|
||||
?>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
else :
|
||||
} else {
|
||||
?>
|
||||
</fieldset>
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'textarea':
|
||||
|
||||
// Image width settings
|
||||
case 'image_width' :
|
||||
|
||||
$width = woocommerce_settings_get_option( $value['id'] . '[width]', $value['default']['width'] );
|
||||
$height = woocommerce_settings_get_option( $value['id'] . '[height]', $value['default']['height'] );
|
||||
$crop = checked( 1, woocommerce_settings_get_option( $value['id'] . '[crop]', $value['default']['crop'] ), false );
|
||||
|
||||
?><tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['name'] ); ?></label>
|
||||
</th>
|
||||
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ) ?></th>
|
||||
<td class="forminp">
|
||||
<?php if ( ! empty( $value['desc'] ) ) echo '<p style="margin-top:0;">' . wp_kses_post( $value['desc'] ) . '</p>'; ?>
|
||||
|
||||
<textarea <?php if ( isset($value['args']) ) echo $value['args'] . ' '; ?>name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'] ); ?>" style="<?php echo esc_attr( $value['css'] ); ?>"><?php if (false !== get_option($value['id'])) echo esc_textarea(stripslashes(get_option($value['id']))); else echo esc_textarea( $value['std'] ); ?></textarea>
|
||||
</td>
|
||||
|
||||
<?php _e( 'Width', 'woocommerce' ); ?> <input name="<?php echo esc_attr( $value['id'] ); ?>[width]" id="<?php echo esc_attr( $value['id'] ); ?>-width" type="text" size="3" value="<?php echo $width; ?>" />
|
||||
|
||||
<?php _e( 'Height', 'woocommerce' ); ?> <input name="<?php echo esc_attr( $value['id'] ); ?>[height]" id="<?php echo esc_attr( $value['id'] ); ?>-height" type="text" size="3" value="<?php echo $height; ?>" />
|
||||
|
||||
<label><?php _e( 'Hard Crop', 'woocommerce' ); ?> <input name="<?php echo esc_attr( $value['id'] ); ?>[crop]" id="<?php echo esc_attr( $value['id'] ); ?>-crop" type="checkbox" <?php echo $crop; ?> /></label>
|
||||
|
||||
<?php echo $description; ?></td>
|
||||
</tr><?php
|
||||
break;
|
||||
|
||||
// Single page selects
|
||||
case 'single_select_page' :
|
||||
$page_setting = (int) get_option($value['id']);
|
||||
|
||||
$args = array( 'name' => $value['id'],
|
||||
'id' => $value['id'],
|
||||
|
@ -648,20 +855,26 @@ function woocommerce_admin_fields( $options ) {
|
|||
'show_option_none' => ' ',
|
||||
'class' => $value['class'],
|
||||
'echo' => false,
|
||||
'selected' => $page_setting);
|
||||
'selected' => absint( woocommerce_settings_get_option( $value['id'] ) )
|
||||
);
|
||||
|
||||
if( isset($value['args']) ) $args = wp_parse_args($value['args'], $args);
|
||||
if( isset( $value['args'] ) )
|
||||
$args = wp_parse_args( $value['args'], $args );
|
||||
|
||||
?><tr valign="top" class="single_select_page">
|
||||
<th scope="row" class="titledesc"><?php echo esc_html( $value['name'] ) ?></th>
|
||||
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ) ?> <?php echo $tip; ?></th>
|
||||
<td class="forminp">
|
||||
<?php echo str_replace(' id=', " data-placeholder='".__( 'Select a page…', 'woocommerce' )."' style='".$value['css']."' class='".$value['class']."' id=", wp_dropdown_pages($args)); ?> <?php echo $description; ?>
|
||||
<?php echo str_replace(' id=', " data-placeholder='" . __( 'Select a page…', 'woocommerce' ) . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages( $args ) ); ?> <?php echo $description; ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
|
||||
// Single country selects
|
||||
case 'single_select_country' :
|
||||
|
||||
$country_setting = (string) woocommerce_settings_get_option( $value['id'] );
|
||||
|
||||
$countries = $woocommerce->countries->countries;
|
||||
$country_setting = (string) get_option($value['id']);
|
||||
if (strstr($country_setting, ':')) :
|
||||
$country = current(explode(':', $country_setting));
|
||||
$state = end(explode(':', $country_setting));
|
||||
|
@ -671,33 +884,41 @@ function woocommerce_admin_fields( $options ) {
|
|||
endif;
|
||||
?><tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['name'] ); ?></label>
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||
<?php echo $tip; ?>
|
||||
</th>
|
||||
<td class="forminp"><select name="<?php echo esc_attr( $value['id'] ); ?>" style="<?php echo esc_attr( $value['css'] ); ?>" data-placeholder="<?php _e( 'Choose a country…', 'woocommerce' ); ?>" title="Country" class="chosen_select">
|
||||
<?php echo $woocommerce->countries->country_dropdown_options($country, $state); ?>
|
||||
<?php echo $woocommerce->countries->country_dropdown_options( $country, $state ); ?>
|
||||
</select> <?php echo $description; ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
|
||||
// Country multiselects
|
||||
case 'multi_select_countries' :
|
||||
|
||||
$selections = (array) woocommerce_settings_get_option( $value['id'] );
|
||||
|
||||
$countries = $woocommerce->countries->countries;
|
||||
asort($countries);
|
||||
$selections = (array) get_option($value['id']);
|
||||
asort( $countries );
|
||||
?><tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['name'] ); ?></label>
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||
<?php echo $tip; ?>
|
||||
</th>
|
||||
<td class="forminp">
|
||||
<select multiple="multiple" name="<?php echo esc_attr( $value['id'] ); ?>[]" style="width:450px;" data-placeholder="<?php _e( 'Choose countries…', 'woocommerce' ); ?>" title="Country" class="chosen_select">
|
||||
<?php
|
||||
if ($countries) foreach ($countries as $key=>$val) :
|
||||
echo '<option value="'.$key.'" '.selected( in_array($key, $selections), true, false ).'>'.$val.'</option>';
|
||||
endforeach;
|
||||
if ( $countries )
|
||||
foreach ( $countries as $key => $val )
|
||||
echo '<option value="'.$key.'" ' . selected( in_array( $key, $selections ), true, false ).'>' . $val . '</option>';
|
||||
?>
|
||||
</select>
|
||||
</select> <?php echo $description; ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
|
||||
// Default: run an action
|
||||
default:
|
||||
do_action( 'woocommerce_admin_field_' . $value['type'], $value );
|
||||
break;
|
||||
|
|
|
@ -23,6 +23,11 @@ function woocommerce_status() {
|
|||
'button' => __('Clear Transients','woocommerce'),
|
||||
'desc' => __( 'This tool will clear the product/shop transients cache.', 'woocommerce' ),
|
||||
),
|
||||
'recount_terms' => array(
|
||||
'name' => __('Term counts','woocommerce'),
|
||||
'button' => __('Recount Terms','woocommerce'),
|
||||
'desc' => __( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', 'woocommerce' ),
|
||||
),
|
||||
'reset_roles' => array(
|
||||
'name' => __('Capabilities','woocommerce'),
|
||||
'button' => __('Reset Capabilities','woocommerce'),
|
||||
|
@ -46,11 +51,23 @@ function woocommerce_status() {
|
|||
break;
|
||||
case "reset_roles" :
|
||||
// Remove then re-add caps and roles
|
||||
woocommerce_remove_roles();
|
||||
woocommerce_remove_roles();
|
||||
woocommerce_init_roles();
|
||||
|
||||
echo '<div class="updated"><p>' . __( 'Roles successfully reset', 'woocommerce' ) . '</p></div>';
|
||||
break;
|
||||
case "recount_terms" :
|
||||
|
||||
$product_cats = get_terms( 'product_cat', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
|
||||
|
||||
_woocommerce_term_recount( $product_cats, get_taxonomy( 'product_cat' ), false, false );
|
||||
|
||||
$product_tags = get_terms( 'product_tag', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
|
||||
|
||||
_woocommerce_term_recount( $product_cats, get_taxonomy( 'product_tag' ), false, false );
|
||||
|
||||
echo '<div class="updated"><p>' . __( 'Terms successfully recounted', 'woocommerce' ) . '</p></div>';
|
||||
break;
|
||||
default:
|
||||
$action = esc_attr( $_GET['action'] );
|
||||
if( isset( $tools[ $action ]['callback'] ) ) {
|
||||
|
@ -253,7 +270,7 @@ function woocommerce_status() {
|
|||
<tr>
|
||||
<td><?php _e('PHP Version','woocommerce')?></td>
|
||||
<td><?php
|
||||
if ( function_exists( 'phpversion' ) )
|
||||
if ( function_exists( 'phpversion' ) )
|
||||
echo esc_html( phpversion() );
|
||||
?></td>
|
||||
</tr>
|
||||
|
@ -334,7 +351,7 @@ function woocommerce_status() {
|
|||
$posting['fsockopen_curl']['note'] = __( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'woocommerce' ). '</mark>';
|
||||
$posting['fsockopen_curl']['success'] = false;
|
||||
}
|
||||
|
||||
|
||||
// SOAP
|
||||
$posting['soap_client']['name'] = __( 'SOAP Client','woocommerce' );
|
||||
if ( class_exists( 'SoapClient' ) ) {
|
||||
|
|
|
@ -39,7 +39,7 @@ function woocommerce_add_category_fields() {
|
|||
<button type="submit" class="remove_image_button button"><?php _e( 'Remove image', 'woocommerce' ); ?></button>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
// Only show the "remove image" button when needed
|
||||
if ( ! jQuery('#product_cat_thumbnail_id').val() )
|
||||
jQuery('.remove_image_button').hide();
|
||||
|
@ -100,7 +100,7 @@ add_action( 'product_cat_add_form_fields', 'woocommerce_add_category_fields' );
|
|||
*/
|
||||
function woocommerce_edit_category_fields( $term, $taxonomy ) {
|
||||
global $woocommerce;
|
||||
|
||||
|
||||
$display_type = get_woocommerce_term_meta( $term->term_id, 'display_type', true );
|
||||
$image = '';
|
||||
$thumbnail_id = absint( get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true ) );
|
||||
|
@ -186,7 +186,7 @@ add_action( 'product_cat_edit_form_fields', 'woocommerce_edit_category_fields',
|
|||
function woocommerce_category_fields_save( $term_id, $tt_id, $taxonomy ) {
|
||||
if ( isset( $_POST['display_type'] ) )
|
||||
update_woocommerce_term_meta( $term_id, 'display_type', esc_attr( $_POST['display_type'] ) );
|
||||
|
||||
|
||||
if ( isset( $_POST['product_cat_thumbnail_id'] ) )
|
||||
update_woocommerce_term_meta( $term_id, 'thumbnail_id', absint( $_POST['product_cat_thumbnail_id'] ) );
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/Updates
|
||||
* @version 1.7.0
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -20,24 +20,24 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
*/
|
||||
function do_update_woocommerce() {
|
||||
global $woocommerce;
|
||||
|
||||
|
||||
// Do updates
|
||||
$current_db_version = get_option( 'woocommerce_db_version' );
|
||||
|
||||
|
||||
if ( version_compare( $current_db_version, '1.4', '<' ) ) {
|
||||
include( 'includes/updates/woocommerce-update-1.4.php' );
|
||||
update_option( 'woocommerce_db_version', '1.4' );
|
||||
}
|
||||
|
||||
|
||||
if ( version_compare( $current_db_version, '1.5', '<' ) ) {
|
||||
include( 'includes/updates/woocommerce-update-1.5.php' );
|
||||
update_option( 'woocommerce_db_version', '1.5' );
|
||||
}
|
||||
|
||||
if ( version_compare( $current_db_version, '1.7', '<' ) ) {
|
||||
include( 'includes/updates/woocommerce-update-1.7.php' );
|
||||
update_option( 'woocommerce_db_version', '1.7' );
|
||||
|
||||
if ( version_compare( $current_db_version, '2.0', '<' ) ) {
|
||||
include( 'includes/updates/woocommerce-update-2.0.php' );
|
||||
update_option( 'woocommerce_db_version', '2.0' );
|
||||
}
|
||||
|
||||
|
||||
update_option( 'woocommerce_db_version', $woocommerce->version );
|
||||
}
|
|
@ -26,7 +26,7 @@ function woocommerce_user_columns( $columns ) {
|
|||
$columns['woocommerce_billing_address'] = __( 'Billing Address', 'woocommerce' );
|
||||
$columns['woocommerce_shipping_address'] = __( 'Shipping Address', 'woocommerce' );
|
||||
$columns['woocommerce_paying_customer'] = __( 'Paying Customer?', 'woocommerce' );
|
||||
$columns['woocommerce_order_count'] = __( 'Orders', 'woocommerce' );
|
||||
$columns['woocommerce_order_count'] = __( 'Completed Orders', 'woocommerce' );
|
||||
return $columns;
|
||||
}
|
||||
|
||||
|
@ -47,15 +47,28 @@ function woocommerce_user_column_values( $value, $column_name, $user_id ) {
|
|||
switch ( $column_name ) :
|
||||
case "woocommerce_order_count" :
|
||||
|
||||
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*)
|
||||
FROM $wpdb->posts
|
||||
LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id
|
||||
WHERE meta_value = $user_id
|
||||
AND meta_key = '_customer_user'
|
||||
AND post_type IN ('shop_order')
|
||||
AND post_status = 'publish'" ) );
|
||||
if ( ! $count = get_user_meta( $user_id, '_order_count', true ) ) {
|
||||
|
||||
$value = '<a href="' . admin_url( 'edit.php?post_status=all&post_type=shop_order&_customer_user=' . absint( $user_id ) . '' ) . '">' . absint( $count ) . '</a>';
|
||||
$count = $wpdb->get_var( "SELECT COUNT(*)
|
||||
FROM $wpdb->posts as posts
|
||||
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
|
||||
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
|
||||
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
|
||||
LEFT JOIN {$wpdb->terms} AS term USING( term_id )
|
||||
|
||||
WHERE meta.meta_key = '_customer_user'
|
||||
AND posts.post_type = 'shop_order'
|
||||
AND posts.post_status = 'publish'
|
||||
AND tax.taxonomy = 'shop_order_status'
|
||||
AND term.slug IN ( 'completed' )
|
||||
AND meta_value = $user_id
|
||||
" );
|
||||
|
||||
update_user_meta( $user_id, '_order_count', $count );
|
||||
}
|
||||
|
||||
$value = '<a href="' . admin_url( 'edit.php?post_status=all&post_type=shop_order&shop_order_status=completed&_customer_user=' . absint( $user_id ) . '' ) . '">' . absint( $count ) . '</a>';
|
||||
|
||||
break;
|
||||
case "woocommerce_billing_address" :
|
||||
|
@ -73,9 +86,9 @@ function woocommerce_user_column_values( $value, $column_name, $user_id ) {
|
|||
|
||||
$formatted_address = $woocommerce->countries->get_formatted_address( $address );
|
||||
|
||||
if ( ! $formatted_address )
|
||||
$value = __( 'N/A', 'woocommerce' );
|
||||
else
|
||||
if ( ! $formatted_address )
|
||||
$value = __( 'N/A', 'woocommerce' );
|
||||
else
|
||||
$value = $formatted_address;
|
||||
|
||||
$value = wpautop( $value );
|
||||
|
@ -95,9 +108,9 @@ function woocommerce_user_column_values( $value, $column_name, $user_id ) {
|
|||
|
||||
$formatted_address = $woocommerce->countries->get_formatted_address( $address );
|
||||
|
||||
if ( ! $formatted_address )
|
||||
$value = __( 'N/A', 'woocommerce' );
|
||||
else
|
||||
if ( ! $formatted_address )
|
||||
$value = __( 'N/A', 'woocommerce' );
|
||||
else
|
||||
$value = $formatted_address;
|
||||
|
||||
$value = wpautop( $value );
|
||||
|
@ -106,10 +119,10 @@ 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.png" alt="yes" />';
|
||||
else
|
||||
$value = '<img src="' . $woocommerce->plugin_url() . '/assets/images/success-off.png" alt="no" />';
|
||||
if ( $paying_customer )
|
||||
$value = '<img src="' . $woocommerce->plugin_url() . '/assets/images/success.png" alt="yes" width="16px" />';
|
||||
else
|
||||
$value = '<img src="' . $woocommerce->plugin_url() . '/assets/images/success-off.png" alt="no" width="16px" />';
|
||||
|
||||
break;
|
||||
endswitch;
|
||||
|
|
|
@ -1 +1 @@
|
|||
.woocommerce-message{position:relative;z-index:100;border:1px solid #b76ca9!important;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:inset 0 0 15px rgba(0,0,0,0.04);-moz-box-shadow:inset 0 0 15px rgba(0,0,0,0.04);box-shadow:inset 0 0 15px rgba(0,0,0,0.04);overflow:hidden;padding:10px 0 10px!important;background:#cc99c2 url(../images/message.png) no-repeat right bottom!important}.woocommerce-message .squeezer{max-width:960px;margin:0;padding:0 10px;text-align:left;overflow:hidden}.woocommerce-message h4{margin:0 10px 0 0;font-size:18px;line-height:36px;font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",Verdana,"Bitstream Vera Sans",sans-serif;font-weight:normal;color:#fff;text-shadow:0 1px 1px #b574a8;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;float:left;vertical-align:middle}.woocommerce-message p{margin:0!important;padding:2px 0!important;float:left!important;line-height:32px;vertical-align:middle}.woocommerce-message p a.button-primary{font-size:16px!important;line-height:16px!important;margin:0 5px 0 0;padding:6px 15px;vertical-align:middle;color:#fff;text-align:center;text-decoration:none;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border:1px solid #88537e;background:#a46497;-moz-box-shadow:inset 0 0 2px #fff,0 1px 1px rgba(0,0,0,0.1);-webkit-box-shadow:inset 0 0 2px #fff,0 1px 1px rgba(0,0,0,0.1);box-shadow:inset 0 0 2px #fff,0 1px 1px rgba(0,0,0,0.1);text-shadow:0 -1px 0 rgba(0,0,0,0.3);-webkit-transition-duration:.3s;-moz-transition-duration:.3s;cursor:pointer;font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",Verdana,"Bitstream Vera Sans",sans-serif}.woocommerce-message p a.button-primary:hover,.woocommerce-message p a.button-primary:active{background-color:#f0a000;border-color:#c87800;-webkit-transition-duration:.3s;outline:0;opacity:1}.woocommerce-message p a.skip,.woocommerce-message p a.docs{opacity:.5}.woocommerce-message .twitter-share-button{vertical-align:middle}
|
||||
.woocommerce-message{position:relative;z-index:100;border:1px solid #b76ca9!important;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:inset 0 0 15px rgba(0,0,0,0.04);-moz-box-shadow:inset 0 0 15px rgba(0,0,0,0.04);box-shadow:inset 0 0 15px rgba(0,0,0,0.04);overflow:hidden;padding:10px 0 10px!important;background:#cc99c2 url(../images/message.png) no-repeat right bottom!important}.woocommerce-message .squeezer{max-width:960px;margin:0;padding:0 10px;text-align:left;overflow:hidden}.woocommerce-message h4{margin:0 10px 0 0;font-size:18px;line-height:36px;font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",Verdana,"Bitstream Vera Sans",sans-serif;font-weight:normal;color:#fff;text-shadow:0 1px 1px #b574a8;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;float:left;vertical-align:middle}.woocommerce-message p{margin:0!important;padding:2px 0!important;float:left!important;line-height:32px;vertical-align:middle}.woocommerce-message p a.button-primary{font-size:16px!important;line-height:16px!important;height:auto!important;margin:0 5px 0 0;padding:6px 15px;vertical-align:middle;color:#fff;text-align:center;text-decoration:none;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border:1px solid #88537e;background:#a46497;-moz-box-shadow:inset 0 0 2px #fff,0 1px 1px rgba(0,0,0,0.1);-webkit-box-shadow:inset 0 0 2px #fff,0 1px 1px rgba(0,0,0,0.1);box-shadow:inset 0 0 2px #fff,0 1px 1px rgba(0,0,0,0.1);text-shadow:0 -1px 0 rgba(0,0,0,0.3);-webkit-transition-duration:.3s;-moz-transition-duration:.3s;cursor:pointer;font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",Verdana,"Bitstream Vera Sans",sans-serif}.woocommerce-message p a.button-primary:hover,.woocommerce-message p a.button-primary:active{background-color:#f0a000;border-color:#c87800;-webkit-transition-duration:.3s;outline:0;opacity:1}.woocommerce-message p a.skip,.woocommerce-message p a.docs{opacity:.5}.woocommerce-message .twitter-share-button{vertical-align:middle}
|
|
@ -41,6 +41,7 @@
|
|||
a.button-primary {
|
||||
font-size: 16px !important;
|
||||
line-height: 16px !important;
|
||||
height: auto !important;
|
||||
margin: 0 5px 0 0;
|
||||
padding: 6px 15px;
|
||||
vertical-align: middle;
|
||||
|
|
|
@ -81,7 +81,10 @@
|
|||
}
|
||||
|
||||
#woocommerce_extensions {
|
||||
background: #f1f1f1 url(../images/icons/wc_icon.png) no-repeat 4px 4px;
|
||||
background-color: #f1f1f1;
|
||||
background-image: url(../images/icons/wc_icon.png);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 4px 4px;
|
||||
padding: 4px 18px 4px 28px;
|
||||
-webkit-border-radius:4px;
|
||||
-moz-border-radius:4px;
|
||||
|
@ -110,6 +113,16 @@
|
|||
}
|
||||
}
|
||||
|
||||
@media
|
||||
(-webkit-min-device-pixel-ratio: 2),
|
||||
(min-resolution: 192dpi) {
|
||||
#woocommerce_extensions {
|
||||
background-image: url(../images/icons/wc_icon@2x.png);
|
||||
background-size: 16px 17px;
|
||||
background-position: 6px 6px;
|
||||
}
|
||||
}
|
||||
|
||||
#wc_get_started { position: relative; margin: 1em 0 2em; padding: 15px 15px 15px 90px; border: 1px solid #d9d9d9; background: #f5f5f5 url(../images/gear.png) no-repeat 15px 15px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #fff; -moz-box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #fff; -webkit-box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #fff; }
|
||||
#wc_get_started span { display: block; text-shadow: 1px 1px 0 #fff; font-size: 14px; line-height: 22px; color: #595959; }
|
||||
#wc_get_started span.main { margin-top: 2px; font-weight: bold; font-size: 16px; }
|
||||
|
@ -129,10 +142,12 @@
|
|||
background-size: auto !important;
|
||||
}
|
||||
|
||||
@media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
|
||||
@media
|
||||
(-webkit-min-device-pixel-ratio: 2),
|
||||
(min-resolution: 192dpi) {
|
||||
#icon-woocommerce, .woocommerce_icon, .icon32-posts-product, .icon32-posts-shop_order, .icon32-posts-shop_coupon, .icon32-posts-product_variation {
|
||||
background-image: url(../images/icons/woocommerce-icons-x2.png) !important;
|
||||
background-size: 986px 45px !important;
|
||||
background-size: 986px 91px !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,6 +193,9 @@
|
|||
.icon32-woocommerce-email {
|
||||
background-position: -940px -5px !important;
|
||||
}
|
||||
.icon32-woocommerce-importer {
|
||||
background-position: -11px -50px !important;
|
||||
}
|
||||
|
||||
.wrap.woocommerce div.updated, .wrap.woocommerce div.error {
|
||||
margin-top: 10px;
|
||||
|
@ -186,9 +204,11 @@ mark.amount {
|
|||
background: transparent none;
|
||||
color: inherit;
|
||||
}
|
||||
input.wc-error {
|
||||
color: #D8000C;
|
||||
background-color: #FFBABA;
|
||||
.postbox, .woocommerce {
|
||||
input:invalid {
|
||||
border: 1px solid #cc010b;
|
||||
background: #ffebe8 url(../images/icons/invalid.png) right center no-repeat;
|
||||
}
|
||||
}
|
||||
|
||||
/* Status page */
|
||||
|
@ -289,8 +309,139 @@ table.wc_status_table {
|
|||
}
|
||||
}
|
||||
|
||||
/* Coupon Lists */
|
||||
.column-coupon_code {
|
||||
line-height: 2.25em;
|
||||
}
|
||||
ul.wc_coupon_list, .column-coupon_code {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
zoom: 1;
|
||||
clear: both;
|
||||
.code {
|
||||
margin-right: 6px;
|
||||
}
|
||||
li.code {
|
||||
margin: 0 6px 12px 0 !important;
|
||||
}
|
||||
.code, .code a, .code span {
|
||||
&:before, &:after {
|
||||
content: "";
|
||||
display: block;
|
||||
position: absolute;
|
||||
width: 8px;
|
||||
height: 4px;
|
||||
background: #f7f7f7;
|
||||
-webkit-border-radius:2px;
|
||||
-moz-border-radius:2px;
|
||||
-o-border-radius:2px;
|
||||
border-radius:2px;
|
||||
-moz-box-shadow: 0 2px 0 0 rgba(255,255,255,0.3), inset 0 2px 0 0 rgba(0,0,0,0.1);
|
||||
-webkit-box-shadow: 0 2px 0 0 rgba(255,255,255,0.3), inset 0 2px 0 0 rgba(0,0,0,0.1);
|
||||
box-shadow: 0 2px 0 0 rgba(255,255,255,0.3), inset 0 2px 0 0 rgba(0,0,0,0.1);
|
||||
}
|
||||
}
|
||||
.code {
|
||||
overflow: hidden;
|
||||
vertical-align: middle;
|
||||
margin: 0 8px 0 0;
|
||||
|
||||
background: #ececec;
|
||||
color: #21759A;
|
||||
text-shadow: 0 1px 0 #ddd;
|
||||
|
||||
padding: 2px;
|
||||
position: relative;
|
||||
float: left;
|
||||
line-height: 1em;
|
||||
-moz-box-shadow: 0 2px 0 0 #dddddd;
|
||||
-webkit-box-shadow: 0 2px 0 0 #dddddd;
|
||||
box-shadow: 0 2px 0 0 #dddddd;
|
||||
font-weight: bold;
|
||||
|
||||
&:before {
|
||||
bottom: 5px;
|
||||
left: 0;
|
||||
margin: 0 0 0 -4px;
|
||||
}
|
||||
&:after {
|
||||
top: 5px;
|
||||
left: 0;
|
||||
margin: 0 0 0 -4px;
|
||||
}
|
||||
a, span {
|
||||
float: left;
|
||||
padding: 0 4px;
|
||||
color: #21759A;
|
||||
&:before {
|
||||
bottom: 5px;
|
||||
right: 0;
|
||||
margin: 0 -4px 0 0;
|
||||
}
|
||||
&:after {
|
||||
content: "";
|
||||
top: 5px;
|
||||
right: 0;
|
||||
margin: 0 -4px 0 0;
|
||||
}
|
||||
span {
|
||||
border: 1px dashed #ccc;
|
||||
padding: .5em 6px;
|
||||
-webkit-border-radius:2px;
|
||||
-moz-border-radius:2px;
|
||||
-o-border-radius:2px;
|
||||
border-radius:2px;
|
||||
&:before {
|
||||
top: 50%;
|
||||
left: 0;
|
||||
margin: -2px 0 0 -4px;
|
||||
}
|
||||
&:after {
|
||||
top: 50%;
|
||||
right: 0;
|
||||
margin: -2px -4px 0 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #975e83;
|
||||
color: #fff;
|
||||
text-shadow: 0 1px 0 #5a324b;
|
||||
a, span {
|
||||
color: #fff;
|
||||
span {
|
||||
border: 1px dashed #bb82a7;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ul.wc_coupon_list_block {
|
||||
margin: 0;
|
||||
padding-bottom: 2px;
|
||||
li {
|
||||
border-top: 1px solid #fff;
|
||||
border-bottom: 1px solid #ccc;
|
||||
line-height: 2.5em;
|
||||
margin: 0;
|
||||
padding: .5em 0;
|
||||
}
|
||||
li:first-child {
|
||||
border-top:0;
|
||||
padding-top: 0;
|
||||
}
|
||||
li:last-child {
|
||||
border-bottom:0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Orders */
|
||||
.tablenav .actions {
|
||||
overflow: visible;
|
||||
}
|
||||
.alignleft.actions .chzn-container-single {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
|
@ -438,6 +589,23 @@ table.wc_status_table {
|
|||
.save_order {
|
||||
float: right;
|
||||
}
|
||||
&#actions {
|
||||
overflow: hidden;
|
||||
.button {
|
||||
width: 25%;
|
||||
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
|
||||
-moz-box-sizing: border-box; /* Firefox, other Gecko */
|
||||
box-sizing: border-box; /* Opera/IE 8+ */
|
||||
float: right;
|
||||
}
|
||||
select {
|
||||
width: 70%;
|
||||
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
|
||||
-moz-box-sizing: border-box; /* Firefox, other Gecko */
|
||||
box-sizing: border-box; /* Opera/IE 8+ */
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#woocommerce-order-items {
|
||||
|
@ -537,7 +705,8 @@ table.wc_status_table {
|
|||
}
|
||||
.buttons {
|
||||
border-top: 1px solid white;
|
||||
padding: 0 10px 0 10px;
|
||||
padding: 1em 10px 1em 10px;
|
||||
margin: 0;
|
||||
text-align: right;
|
||||
.calc_line_taxes {
|
||||
float: left;
|
||||
|
@ -730,6 +899,10 @@ table.wc_status_table {
|
|||
padding: 8px;
|
||||
width: 1%;
|
||||
}
|
||||
tr.refunded {
|
||||
background: url( data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAO0lEQVQYV2NkIAIwElLz5s2b/3gVgRSIiIgwEjQJZBNWRTATYE7BUISuAKdJ6J6Bm4TNBBTr8CkAKQQAdWEXzZ0t/moAAAAASUVORK5CYII= ) repeat;
|
||||
color: #999;
|
||||
}
|
||||
.item {
|
||||
min-width: 200px;
|
||||
}
|
||||
|
@ -806,6 +979,14 @@ table.wc_status_table {
|
|||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAARklEQVQYGWP8//8/AzGACV3Rnj17/oMwujiGQnQFMD7RChlBbsRmFcwkEO3i4sJImonIumGmg0xBFifaRKIVgj2DbAUuNgCfThpracSKqwAAAABJRU5ErkJggg==) no-repeat center;
|
||||
}
|
||||
}
|
||||
tr.refunded {
|
||||
.thumb {
|
||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAS0lEQVQYV42QUQoAIAhD83A7tYcrCiZLsPRL3XOiNiTcfWoNwFhHkiEChA+oEIXcsx8UqwlWTtTDcYMv90vMB+hg/xi6tN5TwfrwBffKRMurJBdPAAAAAElFTkSuQmCC) no-repeat center;
|
||||
* {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -846,7 +1027,7 @@ table.wc_status_table {
|
|||
text-align: center;
|
||||
white-space: nowrap;
|
||||
padding: 0 2px;
|
||||
|
||||
|
||||
background: #999;
|
||||
font-size:11px;
|
||||
line-height: 1.75;
|
||||
|
@ -994,7 +1175,9 @@ table.wp-list-table {
|
|||
.column-is_in_stock {
|
||||
text-align: left !important;
|
||||
}
|
||||
@media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
|
||||
@media
|
||||
(-webkit-min-device-pixel-ratio: 2),
|
||||
(min-resolution: 192dpi) {
|
||||
span.product-type {
|
||||
background-image: url(../images/product_types-x2.png) !important;
|
||||
background-size:96px 16px !important;
|
||||
|
@ -1245,84 +1428,64 @@ a.export_rates, a.import_rates {
|
|||
margin-top: -2px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.woocommerce table.shippingrows, .woocommerce table.taxrows {
|
||||
td, th {
|
||||
vertical-align: top;
|
||||
line-height: 25px;
|
||||
margin-bottom: 9px;
|
||||
}
|
||||
a.remove {
|
||||
margin: 0 !important;
|
||||
}
|
||||
.dupe, .remove {
|
||||
float: right;
|
||||
margin-left: 9px;
|
||||
}
|
||||
tbody .check-column {
|
||||
padding-top: 8px;
|
||||
table.wc_tax_rates {
|
||||
td {
|
||||
padding: 0;
|
||||
border-right: 1px solid #DFDFDF;
|
||||
border-bottom: 1px solid #DFDFDF;
|
||||
border-top: 0;
|
||||
background: #fff;
|
||||
input {
|
||||
margin: 0 0 0 8px;
|
||||
}
|
||||
}
|
||||
input {
|
||||
width: auto;
|
||||
}
|
||||
td.apply_to_shipping {
|
||||
padding-top: 8px;
|
||||
}
|
||||
td.country {
|
||||
overflow: visible !important;
|
||||
p {
|
||||
line-height: 25px;
|
||||
margin: 0;
|
||||
color: #666;
|
||||
}
|
||||
button.edit_options {
|
||||
float: right;
|
||||
}
|
||||
select {
|
||||
margin: 9px 0;
|
||||
width: 100%;
|
||||
height: 160px !important;
|
||||
padding: 5px 7px;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
background: transparent none;
|
||||
}
|
||||
p.edit, .options {
|
||||
min-width: 400px;
|
||||
}
|
||||
.chzn-container {
|
||||
width: 100% !important;
|
||||
margin: 9px 0 5px;
|
||||
.chzn-drop {
|
||||
width: 100% !important;
|
||||
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
|
||||
-moz-box-sizing: border-box; /* Firefox, other Gecko */
|
||||
box-sizing: border-box; /* Opera/IE 8+ */
|
||||
}
|
||||
.search-field input {
|
||||
width: 150px !important;
|
||||
|
||||
&.compound, &.apply_to_shipping {
|
||||
padding: 5px 7px;
|
||||
vertical-align: middle;
|
||||
|
||||
input {
|
||||
width: auto;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
td.local_country {
|
||||
overflow: visible !important;
|
||||
select {
|
||||
width: 198px !important;
|
||||
margin-bottom: 3px;
|
||||
margin-right: 4px;
|
||||
float: left;
|
||||
}
|
||||
select.type {
|
||||
margin-right: 0;
|
||||
}
|
||||
textarea {
|
||||
height: 80px;
|
||||
width: 400px;
|
||||
font-size: 13px;
|
||||
line-height: 16px;
|
||||
display: block;
|
||||
td:last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
tr.current td {
|
||||
background-color: #fefbcc;
|
||||
}
|
||||
.item_cost, .cost {
|
||||
text-align: right;
|
||||
input {
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
td.rate {
|
||||
white-space: nowrap;
|
||||
th.sort {
|
||||
width: 17px;
|
||||
padding: 0;
|
||||
}
|
||||
td.sort {
|
||||
width: 16px;
|
||||
padding: 0;
|
||||
cursor: move;
|
||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAHUlEQVQYV2O8f//+fwY8gJGgAny6QXKETRgEVgAAXxAVsa5Xr3QAAAAASUVORK5CYII=) no-repeat center;
|
||||
}
|
||||
.button {
|
||||
float: left;
|
||||
margin-right: 5px;
|
||||
}
|
||||
.export, .import {
|
||||
float: right;
|
||||
margin-right: 0;
|
||||
margin-left: 5px;
|
||||
}
|
||||
span.tips {
|
||||
padding: 0 3px;
|
||||
}
|
||||
}
|
||||
table.wc_gateways, table.wc_shipping {
|
||||
|
@ -1367,6 +1530,12 @@ img.help_tip {
|
|||
}
|
||||
table.form-table {
|
||||
margin: 0 0 0;
|
||||
.forminp-radio ul {
|
||||
margin: 0;
|
||||
li {
|
||||
line-height: 1.4em;
|
||||
}
|
||||
}
|
||||
textarea.input-text {
|
||||
height: 100%;
|
||||
min-width: 150px;
|
||||
|
@ -1385,6 +1554,19 @@ img.help_tip {
|
|||
cursor: help;
|
||||
line-height: 1;
|
||||
}
|
||||
span.help_tip {
|
||||
cursor: help;
|
||||
color: #21759B;
|
||||
}
|
||||
th {
|
||||
position: relative;
|
||||
padding-right: 24px;
|
||||
}
|
||||
th img.help_tip {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
margin: 0;
|
||||
}
|
||||
fieldset {
|
||||
img.help_tip {
|
||||
margin: -3px 0 0 5px;
|
||||
|
@ -1621,67 +1803,38 @@ img.help_tip {
|
|||
}
|
||||
}
|
||||
}
|
||||
#woocommerce-product-data ul.product_data_tabs, .woocommerce ul.wc-tabs {
|
||||
background: #f9f9f9;
|
||||
border-top: 1px solid #fff;
|
||||
padding: 3px 9px 0;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
zoom: 1;
|
||||
line-height: 1em;
|
||||
-webkit-box-shadow: inset 0 -1px 0 0 #d5d5d5;
|
||||
-moz-box-shadow: inset 0 -1px 0 0x #d5d5d5;
|
||||
box-shadow: inset 0 -1px 0 0 #d5d5d5;
|
||||
li {
|
||||
float: left;
|
||||
padding: 0;
|
||||
margin: 0 6px 0 0;
|
||||
a {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
border: 1px solid #d5d5d5;
|
||||
border-bottom: 0;
|
||||
float: left;
|
||||
padding: 9px 9px;
|
||||
background: #f1f1f1;
|
||||
text-decoration: none;
|
||||
color: #555;
|
||||
|
||||
-moz-border-radius-topleft: 3px;
|
||||
-moz-border-radius-topright: 3px;
|
||||
-webkit-border-top-left-radius: 3px;
|
||||
-webkit-border-top-right-radius: 3px;
|
||||
border-top-left-radius: 3px;
|
||||
border-top-right-radius: 3px;
|
||||
/* Tabs and panels */
|
||||
#woocommerce-product-data {
|
||||
.panel-wrap {
|
||||
background: #f8f8f8;
|
||||
padding-left: 153px;
|
||||
}
|
||||
.woocommerce_options_panel, .wc-metaboxes-wrapper {
|
||||
float: right;
|
||||
width: 100%;
|
||||
|
||||
-webkit-box-shadow: inset 0 1px 0 1px rgba(255, 255, 255, 0.5);
|
||||
-moz-box-shadow: inset 0 1px 0 1px rgba(255, 255, 255, 0.5);
|
||||
box-shadow: inset 0 1px 0 1px rgba(255, 255, 255, 0.5);
|
||||
p, .wc-metaboxes, p.toolbar {
|
||||
padding-left: 12px !important;
|
||||
padding-right: 20px !important;
|
||||
}
|
||||
}
|
||||
.wc-tabs-back {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
background: #f1f1f1;
|
||||
width: 145px;
|
||||
border-right: 1px solid #DFDFDF;
|
||||
}
|
||||
}
|
||||
#woocommerce-product-data ul.product_data_tabs li.active a, .woocommerce ul.wc-tabs li.active a {
|
||||
background: #f8f8f8;
|
||||
color: #555;
|
||||
|
||||
background-image: linear-gradient(bottom, rgb(255,255,255) 0%, rgb(248,248,248) 100%);
|
||||
background-image: -o-linear-gradient(bottom, rgb(255,255,255) 0%, rgb(248,248,248) 100%);
|
||||
background-image: -moz-linear-gradient(bottom, rgb(255,255,255) 0%, rgb(248,248,248) 100%);
|
||||
background-image: -webkit-linear-gradient(bottom, rgb(255,255,255) 0%, rgb(248,248,248) 100%);
|
||||
background-image: -ms-linear-gradient(bottom, rgb(255,255,255) 0%, rgb(248,248,248) 100%);
|
||||
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0, rgb(255,255,255)),
|
||||
color-stop(1, rgb(248,248,248))
|
||||
);
|
||||
}
|
||||
@media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
|
||||
@media
|
||||
(-webkit-min-device-pixel-ratio: 2),
|
||||
(min-resolution: 192dpi) {
|
||||
#woocommerce-product-data ul.product_data_tabs li {
|
||||
&.general_options, &.tax_options, &.inventory_options, &.shipping_options, &.related_product_options, &.attribute_options, &.variation_options, &.advanced_options {
|
||||
&.general_options, &.tax_options, &.inventory_options, &.shipping_options, &.linked_product_options, &.attribute_options, &.variation_options, &.advanced_options {
|
||||
a {
|
||||
background-image: url(../images/icons/wc-tab-icons-x2.png) !important;
|
||||
background-size: 17px 720px !important;
|
||||
|
@ -1690,69 +1843,142 @@ img.help_tip {
|
|||
}
|
||||
|
||||
}
|
||||
#woocommerce-product-data ul.product_data_tabs li {
|
||||
&.general_options, &.tax_options, &.inventory_options, &.shipping_options, &.related_product_options, &.attribute_options, &.variation_options, &.advanced_options {
|
||||
|
||||
#woocommerce-product-data ul.product_data_tabs, .woocommerce ul.wc-tabs {
|
||||
background: #f1f1f1;
|
||||
line-height: 1em;
|
||||
float: left;
|
||||
width: 145px;
|
||||
margin: 0;
|
||||
position: relative;
|
||||
padding: 0 0 10px;
|
||||
margin-left: -153px;
|
||||
|
||||
li {
|
||||
display:block;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
a {
|
||||
padding: 9px 9px 9px 31px;
|
||||
line-height: 16px;
|
||||
border-bottom: 1px solid #d5d5d5;
|
||||
text-shadow: 0 1px 1px #fff;
|
||||
color: #555;
|
||||
background: #f1f1f1 url(../images/icons/wc-tab-icons.png) no-repeat 9px 9px;
|
||||
padding: 5px;
|
||||
line-height: 18px !important;
|
||||
margin: 0;
|
||||
display: block;
|
||||
background: #f1f1f1;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px solid #f1f1f1;
|
||||
border-top: 1px solid #f1f1f1;
|
||||
}
|
||||
}
|
||||
&.general_options {
|
||||
a {
|
||||
background-position: 9px 9px;
|
||||
|
||||
&:first-child {
|
||||
a {
|
||||
border-top: 0 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.tax_options {
|
||||
a {
|
||||
background-position: 9px -55px;
|
||||
|
||||
&.general_options, &.tax_options, &.inventory_options, &.shipping_options, &.linked_product_options, &.attribute_options, &.variation_options, &.advanced_options {
|
||||
a {
|
||||
padding: 5px 5px 5px 28px;
|
||||
background: #f1f1f1 url(../images/icons/wc-tab-icons.png) no-repeat 5px 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.inventory_options {
|
||||
a {
|
||||
background-position: 9px -119px;
|
||||
&.general_options {
|
||||
a {
|
||||
background-position: 5px 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.shipping_options {
|
||||
a {
|
||||
background-position: 9px -631px;
|
||||
&.tax_options {
|
||||
a {
|
||||
background-position: 5px -59px;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.related_product_options {
|
||||
a {
|
||||
background-position: 9px -567px;
|
||||
&.inventory_options {
|
||||
a {
|
||||
background-position: 5px -123px;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.attribute_options {
|
||||
a {
|
||||
background-position: 9px -247px;
|
||||
&.shipping_options {
|
||||
a {
|
||||
background-position: 5px -635px;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.advanced_options {
|
||||
a {
|
||||
background-position: 9px -695px;
|
||||
&.linked_product_options {
|
||||
a {
|
||||
background-position: 5px -571px;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.variation_options {
|
||||
a {
|
||||
background-position: 9px -439px;
|
||||
&.attribute_options {
|
||||
a {
|
||||
background-position: 5px -251px;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.active {
|
||||
a {
|
||||
background-color: #f8f8f8;
|
||||
border-bottom: 1px solid #f8f8f8;
|
||||
&.advanced_options {
|
||||
a {
|
||||
background-position: 5px -698px;
|
||||
}
|
||||
}
|
||||
&.variation_options {
|
||||
a {
|
||||
background-position: 5px -443px;
|
||||
}
|
||||
}
|
||||
|
||||
&.active {
|
||||
a {
|
||||
border-color: #DFDFDF;
|
||||
position: relative;
|
||||
background-color: #f8f8f8;
|
||||
color: #555;
|
||||
margin: 0 -1px 0 0;
|
||||
width: 113px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#woocommerce-product-data .inside, #woocommerce-product-type-options .inside, #woocommerce-order-data .inside, #woocommerce-order-downloads .inside, #woocommerce-coupon-data .inside {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
@media only screen and (max-width: 900px) {
|
||||
|
||||
#woocommerce-product-data {
|
||||
.panel-wrap {
|
||||
padding-left: 35px;
|
||||
}
|
||||
.wc-tabs-back {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
background: #f1f1f1;
|
||||
width: 28px;
|
||||
border-right: 1px solid #DFDFDF;
|
||||
}
|
||||
}
|
||||
|
||||
#woocommerce-product-data ul.product_data_tabs, .woocommerce ul.wc-tabs {
|
||||
width: 28px;
|
||||
margin-left: -35px;
|
||||
li {
|
||||
a {
|
||||
width: 28px;
|
||||
padding: 28px 0 0 0 !important;
|
||||
overflow: hidden;
|
||||
height: 0;
|
||||
}
|
||||
&.active {
|
||||
a {
|
||||
width: 29px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#woocommerce-product-data, #woocommerce-product-type-options, #woocommerce-order-data, #woocommerce-order-downloads, #woocommerce-coupon-data {
|
||||
.inside {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.woocommerce_options_panel, .panel {
|
||||
padding: 9px 9px 9px 9px;
|
||||
color: #555;
|
||||
|
@ -1786,7 +2012,7 @@ img.help_tip {
|
|||
p {
|
||||
margin: 9px 0 9px;
|
||||
}
|
||||
label {
|
||||
label, legend {
|
||||
float: left;
|
||||
width: 150px;
|
||||
padding: 0;
|
||||
|
@ -1838,6 +2064,34 @@ img.help_tip {
|
|||
.options_group:first-child {
|
||||
border-top: 0;
|
||||
}
|
||||
.options_group:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.options_group fieldset {
|
||||
margin: 9px 0;
|
||||
font-size: 12px;
|
||||
padding: 5px 9px;
|
||||
line-height: 24px;
|
||||
label {
|
||||
width: auto;
|
||||
float: none;
|
||||
}
|
||||
ul {
|
||||
float: left;
|
||||
width: 50%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
li {
|
||||
margin: 0;
|
||||
width: auto;
|
||||
input {
|
||||
width: auto;
|
||||
float: none;
|
||||
margin-right: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.dimensions_field {
|
||||
.wrap {
|
||||
input {
|
||||
|
@ -1865,19 +2119,6 @@ img.help_tip {
|
|||
|
||||
/* WC Metabox Panels - used for attributes, download permissions etc */
|
||||
.wc-metaboxes-wrapper {
|
||||
.expand_all, .close_all {
|
||||
float: right;
|
||||
margin-left: 9px;
|
||||
line-height: 22px;
|
||||
}
|
||||
.expand_all {
|
||||
padding-left: 14px;
|
||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAI0lEQVQYV2PcvXv3fwY8gJEoBa6urozYDAFpBpswGBTg8yYA3kYtiYVhDhIAAAAASUVORK5CYII=) no-repeat left;
|
||||
}
|
||||
.close_all {
|
||||
padding-left: 14px;
|
||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAHUlEQVQYV2NkIAAYd+/e/R+fGsIKCFpBUAHt3QAASf0MyQbFJwoAAAAASUVORK5CYII=) no-repeat left;
|
||||
}
|
||||
.toolbar {
|
||||
margin: 0 !important;
|
||||
border-top: 1px solid white;
|
||||
|
@ -1886,6 +2127,9 @@ img.help_tip {
|
|||
&:first-child {
|
||||
border-top:0;
|
||||
}
|
||||
&:last-child {
|
||||
border-bottom:0;
|
||||
}
|
||||
}
|
||||
p.toolbar {
|
||||
overflow: hidden;
|
||||
|
@ -2005,13 +2249,33 @@ img.help_tip {
|
|||
}
|
||||
}
|
||||
}
|
||||
.plus {
|
||||
.expand_all, .close_all {
|
||||
float: right;
|
||||
margin-left: 9px;
|
||||
line-height: 22px;
|
||||
padding-left: 20px;
|
||||
background: #fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAARklEQVQYGWP8//8/AzGACV3Rnj17/oMwujiGQnQFMD7RChlBbsRmFcwkEO3i4sJImonIumGmg0xBFifaRKIVgj2DbAUuNgCfThpracSKqwAAAABJRU5ErkJggg==) no-repeat 7px 5px;
|
||||
background-image: url(../images/icons/edit_variations.png) !important;
|
||||
background-repeat: no-repeat;
|
||||
background-position: 1px -61px;
|
||||
}
|
||||
.minus {
|
||||
padding-left: 20px;
|
||||
background: #fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAKUlEQVQYlWP8//8/Az7AhFeWGAUsDAwMDHv27MFqj4uLCyNBExhp70gAohwKC5KJ+HQAAAAASUVORK5CYII=) no-repeat 7px 6px;
|
||||
.expand_all {
|
||||
background-position: 1px -82px;
|
||||
}
|
||||
a.plus, a.minus {
|
||||
padding-left:20px;
|
||||
background-image: url(../images/icons/edit_variations.png) !important;
|
||||
background-color: #FEFEFE !important;
|
||||
background-repeat: no-repeat !important;
|
||||
background-position: 1px -1px;
|
||||
&:hover {
|
||||
background-position: 1px 0px;
|
||||
}
|
||||
}
|
||||
a.plus {
|
||||
background-position: 1px 0px;
|
||||
}
|
||||
a.minus {
|
||||
background-position: 1px -41px;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2027,17 +2291,21 @@ img.help_tip {
|
|||
margin: 0 6px 0 0;
|
||||
float: left;
|
||||
}
|
||||
a.set, a.toggle, a.delete_variations {
|
||||
padding-left:20px;
|
||||
background-image: url(../images/icons/edit_variations.png) !important;
|
||||
background-color: #FEFEFE !important;
|
||||
background-repeat: no-repeat !important;
|
||||
background-position: 1px 0px;
|
||||
}
|
||||
a.set {
|
||||
padding-left: 20px;
|
||||
background: #fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAARklEQVQYGWP8//8/AzGACV3Rnj17/oMwujiGQnQFMD7RChlBbsRmFcwkEO3i4sJImonIumGmg0xBFifaRKIVgj2DbAUuNgCfThpracSKqwAAAABJRU5ErkJggg==) no-repeat 7px 5px;
|
||||
background-position: 1px 0px;
|
||||
}
|
||||
a.toggle {
|
||||
padding-left: 20px;
|
||||
background: #fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAWUlEQVQYGY3QAQrAIAgFUB07mrfWu7kc+2JRsiA0fJnE7k5m5tQsEWFS1WGduh3mahpNLx3hOs4WAr2zfU8mRBGxorAJ4wAU+boS1g41x4UbScQdQJ3/fvgDtStDiI0qoDcAAAAASUVORK5CYII=) no-repeat 7px 5px;
|
||||
background-position: 1px -21px;
|
||||
}
|
||||
a.delete_variations {
|
||||
padding-left: 20px;
|
||||
background: #fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAKUlEQVQYlWP8//8/Az7AhFeWGAUsDAwMDHv27MFqj4uLCyNBExhp70gAohwKC5KJ+HQAAAAASUVORK5CYII=) no-repeat 7px 6px;
|
||||
background-position: 1px -41px;
|
||||
}
|
||||
.add_variation, .link_all_variations, .fr {
|
||||
float: right;
|
||||
|
@ -2178,6 +2446,30 @@ img.help_tip {
|
|||
}
|
||||
}
|
||||
}
|
||||
@media
|
||||
(-webkit-min-device-pixel-ratio: 2),
|
||||
(min-resolution: 192dpi) {
|
||||
.wc-metaboxes-wrapper {
|
||||
a.plus, a.minus, .expand_all, .close_all {
|
||||
background-image: url(../images/icons/edit_variations@2x.png) !important;
|
||||
background-size: 21px 165px;
|
||||
&:hover {
|
||||
background-size: 21px 165px;
|
||||
}
|
||||
}
|
||||
}
|
||||
#variable_product_options {
|
||||
p.toolbar {
|
||||
a.set, a.toggle, a.delete_variations {
|
||||
background-image: url(../images/icons/edit_variations@2x.png) !important;
|
||||
background-size: 21px 165px;
|
||||
&:hover {
|
||||
background-size: 21px 165px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Tooltips */
|
||||
.tips {
|
||||
|
@ -2420,10 +2712,10 @@ table.bar_chart {
|
|||
line-height: 25px;
|
||||
}
|
||||
.chzn-container-single .chzn-single div b {
|
||||
background: url('../images/chosen-sprite.png') no-repeat 0 0 !important;
|
||||
background: url('../images/chosen-sprite.png') no-repeat 0 2px !important;
|
||||
}
|
||||
.chzn-container-active .chzn-single-with-drop div b {
|
||||
background-position: -18px 1px !important;
|
||||
background-position: -18px 2px !important;
|
||||
}
|
||||
.chzn-container-single .chzn-search input {
|
||||
line-height: 13px;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
}
|
||||
.chzn-container-single .chzn-single {
|
||||
height: 28px;
|
||||
line-height: 29px;
|
||||
line-height: 29px;
|
||||
}
|
||||
.chzn-container-single .chzn-single div b {
|
||||
background: url('../images/chosen-sprite.png') no-repeat 0 3px !important;
|
||||
|
@ -28,6 +28,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-resolution: 144dpi) {
|
||||
.woocommerce-checkout .form-row {
|
||||
.chzn-container-single .chzn-single div b {
|
||||
background-image: url('../images/chosen-sprite@2x.png') !important;
|
||||
background-position: 0 5px !important;
|
||||
background-repeat: no-repeat !important;
|
||||
background-size: 52px 37px !important;
|
||||
}
|
||||
.chzn-container-active .chzn-single-with-drop div b {
|
||||
background-position: -18px 5px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* @group Base */
|
||||
.chzn-container {
|
||||
font-size: 13px;
|
||||
|
@ -45,9 +59,8 @@
|
|||
left: 0;
|
||||
-webkit-box-shadow: 0 4px 5px rgba(0,0,0,.15);
|
||||
-moz-box-shadow : 0 4px 5px rgba(0,0,0,.15);
|
||||
-o-box-shadow : 0 4px 5px rgba(0,0,0,.15);
|
||||
box-shadow : 0 4px 5px rgba(0,0,0,.15);
|
||||
z-index: 999;
|
||||
z-index: 1010;
|
||||
}
|
||||
/* @end */
|
||||
|
||||
|
@ -55,12 +68,11 @@
|
|||
.chzn-container-single .chzn-single {
|
||||
background-color: #ffffff;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0 );
|
||||
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #ffffff), color-stop(50%, #f6f6f6), color-stop(52%, #eeeeee), color-stop(100%, #f4f4f4));
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(20%, #ffffff), color-stop(50%, #f6f6f6), color-stop(52%, #eeeeee), color-stop(100%, #f4f4f4));
|
||||
background-image: -webkit-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
|
||||
background-image: -moz-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
|
||||
background-image: -o-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
|
||||
background-image: -ms-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
|
||||
background-image: linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
|
||||
background-image: linear-gradient(#ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius : 5px;
|
||||
border-radius : 5px;
|
||||
|
@ -75,9 +87,8 @@
|
|||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
position: relative;
|
||||
|
||||
|
||||
|
||||
height: 23px;
|
||||
line-height: 24px;
|
||||
padding: 0 0 0 8px;
|
||||
color: #444444;
|
||||
text-decoration: none;
|
||||
|
@ -100,12 +111,15 @@
|
|||
right: 26px;
|
||||
top: 6px;
|
||||
width: 12px;
|
||||
height: 13px;
|
||||
height: 12px;
|
||||
font-size: 1px;
|
||||
background: url('../images/chosen-sprite.png') right top no-repeat;
|
||||
background: url('../images/chosen-sprite.png') -44px 2px no-repeat;
|
||||
}
|
||||
.chzn-container-single .chzn-single abbr:hover {
|
||||
background-position: right -11px;
|
||||
background-position: -44px -9px;
|
||||
}
|
||||
.chzn-container-single.chzn-disabled .chzn-single abbr:hover {
|
||||
background-position: -44px -9px;
|
||||
}
|
||||
.chzn-container-single .chzn-single div {
|
||||
position: absolute;
|
||||
|
@ -116,7 +130,7 @@
|
|||
width: 18px;
|
||||
}
|
||||
.chzn-container-single .chzn-single div b {
|
||||
background: url('../images/chosen-sprite.png') no-repeat 0 0;
|
||||
background: url('../images/chosen-sprite.png') no-repeat 0px 2px;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
@ -129,13 +143,12 @@
|
|||
z-index: 1010;
|
||||
}
|
||||
.chzn-container-single .chzn-search input {
|
||||
background: #fff url('../images/chosen-sprite.png') no-repeat 100% -22px;
|
||||
background: url('../images/chosen-sprite.png') no-repeat 100% -22px, -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
|
||||
background: url('../images/chosen-sprite.png') no-repeat 100% -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: url('../images/chosen-sprite.png') no-repeat 100% -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: url('../images/chosen-sprite.png') no-repeat 100% -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: url('../images/chosen-sprite.png') no-repeat 100% -22px, -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: url('../images/chosen-sprite.png') no-repeat 100% -22px, linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: #fff url('../images/chosen-sprite.png') no-repeat 100% -20px;
|
||||
background: url('../images/chosen-sprite.png') no-repeat 100% -20px, -webkit-gradient(linear, 0 0, 0 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
|
||||
background: url('../images/chosen-sprite.png') no-repeat 100% -20px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: url('../images/chosen-sprite.png') no-repeat 100% -20px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: url('../images/chosen-sprite.png') no-repeat 100% -20px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: url('../images/chosen-sprite.png') no-repeat 100% -20px, linear-gradient(#eeeeee 1%, #ffffff 15%);
|
||||
margin: 1px 0;
|
||||
padding: 4px 20px 4px 5px;
|
||||
outline: 0;
|
||||
|
@ -161,12 +174,11 @@
|
|||
/* @group Multi Chosen */
|
||||
.chzn-container-multi .chzn-choices {
|
||||
background-color: #fff;
|
||||
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
|
||||
background-image: -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background-image: -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background-image: -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background-image: -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background-image: linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background-image: linear-gradient(#eeeeee 1%, #ffffff 15%);
|
||||
border: 1px solid #aaa;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
@ -197,7 +209,6 @@
|
|||
outline: 0;
|
||||
-webkit-box-shadow: none;
|
||||
-moz-box-shadow : none;
|
||||
-o-box-shadow : none;
|
||||
box-shadow : none;
|
||||
}
|
||||
.chzn-container-multi .chzn-choices .search-field .default {
|
||||
|
@ -212,12 +223,11 @@
|
|||
background-clip : padding-box;
|
||||
background-color: #e4e4e4;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4f4f4', endColorstr='#eeeeee', GradientType=0 );
|
||||
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
|
||||
background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: -ms-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
-webkit-box-shadow: 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
|
||||
-moz-box-shadow : 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
|
||||
box-shadow : 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
|
||||
|
@ -229,6 +239,19 @@
|
|||
position: relative;
|
||||
cursor: default;
|
||||
}
|
||||
.chzn-container-multi .chzn-choices .search-choice.search-choice-disabled {
|
||||
background-color: #e4e4e4;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4f4f4', endColorstr='#eeeeee', GradientType=0 );
|
||||
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
|
||||
background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: -ms-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
color: #666;
|
||||
border: 1px solid #cccccc;
|
||||
padding-right: 5px;
|
||||
}
|
||||
.chzn-container-multi .chzn-choices .search-choice-focus {
|
||||
background: #d4d4d4;
|
||||
}
|
||||
|
@ -238,15 +261,15 @@
|
|||
right: 3px;
|
||||
top: 4px;
|
||||
width: 12px;
|
||||
height: 13px;
|
||||
height: 12px;
|
||||
font-size: 1px;
|
||||
background: url('../images/chosen-sprite.png') right top no-repeat;
|
||||
background: url('../images/chosen-sprite.png') -44px 2px no-repeat;
|
||||
}
|
||||
.chzn-container-multi .chzn-choices .search-choice .search-choice-close:hover {
|
||||
background-position: right -11px;
|
||||
background-position: -44px -9px;
|
||||
}
|
||||
.chzn-container-multi .chzn-choices .search-choice-focus .search-choice-close {
|
||||
background-position: right -11px;
|
||||
background-position: -44px -9px;
|
||||
}
|
||||
/* @end */
|
||||
|
||||
|
@ -258,6 +281,7 @@
|
|||
position: relative;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
.chzn-container-multi .chzn-results {
|
||||
margin: -1px 0 0;
|
||||
|
@ -277,12 +301,11 @@
|
|||
.chzn-container .chzn-results .highlighted {
|
||||
background-color: #3875d7;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3875d7', endColorstr='#2a62bc', GradientType=0 );
|
||||
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #3875d7), color-stop(90%, #2a62bc));
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(20%, #3875d7), color-stop(90%, #2a62bc));
|
||||
background-image: -webkit-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
|
||||
background-image: -moz-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
|
||||
background-image: -o-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
|
||||
background-image: -ms-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
|
||||
background-image: linear-gradient(top, #3875d7 20%, #2a62bc 90%);
|
||||
background-image: linear-gradient(#3875d7 20%, #2a62bc 90%);
|
||||
color: #fff;
|
||||
}
|
||||
.chzn-container .chzn-results li em {
|
||||
|
@ -336,7 +359,6 @@
|
|||
.chzn-container-active .chzn-single {
|
||||
-webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
|
||||
-moz-box-shadow : 0 0 5px rgba(0,0,0,.3);
|
||||
-o-box-shadow : 0 0 5px rgba(0,0,0,.3);
|
||||
box-shadow : 0 0 5px rgba(0,0,0,.3);
|
||||
border: 1px solid #5897fb;
|
||||
}
|
||||
|
@ -344,16 +366,14 @@
|
|||
border: 1px solid #aaa;
|
||||
-webkit-box-shadow: 0 1px 0 #fff inset;
|
||||
-moz-box-shadow : 0 1px 0 #fff inset;
|
||||
-o-box-shadow : 0 1px 0 #fff inset;
|
||||
box-shadow : 0 1px 0 #fff inset;
|
||||
background-color: #eee;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0 );
|
||||
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #eeeeee), color-stop(80%, #ffffff));
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(20%, #eeeeee), color-stop(80%, #ffffff));
|
||||
background-image: -webkit-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
|
||||
background-image: -moz-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
|
||||
background-image: -o-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
|
||||
background-image: -ms-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
|
||||
background-image: linear-gradient(top, #eeeeee 20%, #ffffff 80%);
|
||||
background-image: linear-gradient(#eeeeee 20%, #ffffff 80%);
|
||||
-webkit-border-bottom-left-radius : 0;
|
||||
-webkit-border-bottom-right-radius: 0;
|
||||
-moz-border-radius-bottomleft : 0;
|
||||
|
@ -366,12 +386,11 @@
|
|||
border-left: none;
|
||||
}
|
||||
.chzn-container-active .chzn-single-with-drop div b {
|
||||
background-position: -18px 1px;
|
||||
background-position: -18px 2px;
|
||||
}
|
||||
.chzn-container-active .chzn-choices {
|
||||
-webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
|
||||
-moz-box-shadow : 0 0 5px rgba(0,0,0,.3);
|
||||
-o-box-shadow : 0 0 5px rgba(0,0,0,.3);
|
||||
box-shadow : 0 0 5px rgba(0,0,0,.3);
|
||||
border: 1px solid #5897fb;
|
||||
}
|
||||
|
@ -405,19 +424,34 @@
|
|||
.chzn-rtl .chzn-choices .search-field input { direction: rtl; }
|
||||
.chzn-rtl .chzn-choices li { float: right; }
|
||||
.chzn-rtl .chzn-choices .search-choice { padding: 3px 5px 3px 19px; margin: 3px 5px 3px 0; }
|
||||
.chzn-rtl .chzn-choices .search-choice .search-choice-close { left: 4px; right: auto; background-position: right top;}
|
||||
.chzn-rtl .chzn-choices .search-choice .search-choice-close { left: 4px; right: auto; background-position: -44px 2px;}
|
||||
.chzn-rtl.chzn-container-single .chzn-results { margin: 0 0 4px 4px; padding: 0 4px 0 0; }
|
||||
.chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 15px; }
|
||||
.chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; }
|
||||
.chzn-rtl .chzn-search input {
|
||||
background: #fff url('../images/chosen-sprite.png') no-repeat -38px -22px;
|
||||
background: url('../images/chosen-sprite.png') no-repeat -38px -22px, -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
|
||||
background: url('../images/chosen-sprite.png') no-repeat -38px -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: url('../images/chosen-sprite.png') no-repeat -38px -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: url('../images/chosen-sprite.png') no-repeat -38px -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: url('../images/chosen-sprite.png') no-repeat -38px -22px, -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: url('../images/chosen-sprite.png') no-repeat -38px -22px, linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: #fff url('../images/chosen-sprite.png') no-repeat -30px -20px;
|
||||
background: url('../images/chosen-sprite.png') no-repeat -30px -20px, -webkit-gradient(linear, 0 0, 0 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
|
||||
background: url('../images/chosen-sprite.png') no-repeat -30px -20px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: url('../images/chosen-sprite.png') no-repeat -30px -20px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: url('../images/chosen-sprite.png') no-repeat -30px -20px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: url('../images/chosen-sprite.png') no-repeat -30px -20px, linear-gradient(#eeeeee 1%, #ffffff 15%);
|
||||
padding: 4px 5px 4px 20px;
|
||||
direction: rtl;
|
||||
}
|
||||
.chzn-container-single.chzn-rtl .chzn-single div b {
|
||||
background-position: 6px 2px;
|
||||
}
|
||||
.chzn-container-single.chzn-rtl.chzn-container-active .chzn-single div b {
|
||||
background-position: -12px 2px;
|
||||
}
|
||||
/* @end */
|
||||
|
||||
/* @group Retina compatibility */
|
||||
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-resolution: 144dpi) {
|
||||
.chzn-rtl .chzn-search input, .chzn-container-single .chzn-single abbr, .chzn-container-single .chzn-single div b, .chzn-container-single .chzn-search input, .chzn-container-multi .chzn-choices .search-choice .search-choice-close, .chzn-container .chzn-results-scroll-down span, .chzn-container .chzn-results-scroll-up span {
|
||||
background-image: url('../images/chosen-sprite@2x.png') !important;
|
||||
background-repeat: no-repeat !important;
|
||||
background-size: 52px 37px !important;
|
||||
}
|
||||
}
|
||||
/* @end */
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
* Simple and fancy lightbox alternative
|
||||
*
|
||||
* Examples and documentation at: http://fancybox.net
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2008 - 2010 Janis Skarnelis
|
||||
* That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
|
||||
*
|
||||
*
|
||||
* Version: 1.3.4 (11/11/2010)
|
||||
* Requires: jQuery v1.3+
|
||||
*
|
||||
|
|
|
@ -68,7 +68,7 @@ p.demo_store {
|
|||
z-index: 999999;
|
||||
.inset_box_shadow( 0, 0, 0, 3px, rgba(255,255,255,0.2) );
|
||||
}
|
||||
|
||||
|
||||
.woocommerce, .woocommerce-page { // namespace to avoid conflict with common global class names
|
||||
|
||||
small.note {
|
||||
|
@ -543,6 +543,8 @@ p.demo_store {
|
|||
.darkorlighttextshadow( @secondarytext );
|
||||
border: 1px solid darken( @secondary, 20 );
|
||||
.vertical_gradient( @secondary, darken( @secondary, 10 ) );
|
||||
white-space: nowrap;
|
||||
display: inline-block;
|
||||
|
||||
-webkit-box-shadow:
|
||||
inset 0 -1px 0 rgba(0,0,0,0.075),
|
||||
|
@ -572,7 +574,7 @@ p.demo_store {
|
|||
}
|
||||
}
|
||||
|
||||
&.added {
|
||||
/*&.added {
|
||||
&:before {
|
||||
content: "";
|
||||
position:absolute;
|
||||
|
@ -582,8 +584,9 @@ p.demo_store {
|
|||
right: -26px;
|
||||
text-indent: 0;
|
||||
background: url(../images/success.png) no-repeat;
|
||||
background-size:16px 14px;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
&:hover {
|
||||
.vertical_gradient( @secondary, darken( @secondary, 15 ) );
|
||||
|
@ -612,6 +615,14 @@ p.demo_store {
|
|||
float:none;
|
||||
}
|
||||
|
||||
a.added_to_cart {
|
||||
background: url(../images/success.png) no-repeat left;
|
||||
background-size:16px 14px;
|
||||
padding: 0 0 0 22px;
|
||||
white-space: nowrap;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* =Quantity inputs
|
||||
-------------------------------------------------------------- */
|
||||
|
||||
|
@ -622,6 +633,11 @@ p.demo_store {
|
|||
overflow:hidden;
|
||||
zoom: 1;
|
||||
|
||||
/* Disable input[type=number] buttons until the world is ready */
|
||||
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {
|
||||
display:none;
|
||||
}
|
||||
|
||||
input.qty {
|
||||
width: 40px;
|
||||
height: 28px;
|
||||
|
@ -636,6 +652,11 @@ p.demo_store {
|
|||
.border_radius_left(2px);
|
||||
}
|
||||
|
||||
/* Hide buttons for opera */
|
||||
noindex:-o-prefocus, input[type=number] {
|
||||
padding-right: 1.2em;
|
||||
}
|
||||
|
||||
.plus, .minus {
|
||||
display:block;
|
||||
padding: 0;
|
||||
|
@ -1206,6 +1227,35 @@ p.demo_store {
|
|||
-webkit-box-shadow:none;
|
||||
box-shadow:none;
|
||||
}
|
||||
&.wc-validated {
|
||||
input.input-text {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAVElEQVQYV2NkIAIw4lNz5syZ/yB5nIpgCkxMTBixKkJWgNUkdAVgRciC2BSAFe3evfu/oKAg3P3v379ncHV1RXEGmIOsEORQdB/DBUAKQZLopoDEAE3dJm1YbTYqAAAAAElFTkSuQmCC);
|
||||
background-position: 95% center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
}
|
||||
&.wc-error {
|
||||
input.input-text {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAZUlEQVQYV2NkQAO/6zv+szZWMCILo3BAChjfvgPLs0zpgsthKAKZ8ien7D9WRSBTQCbAFCGbBjeJoCKYAoRJpUBTIfpB1oJZyIpgDmdgANnOCFGEUAARRHYTLBjAPkGECUQhOgAAec48xMU9V4oAAAAASUVORK5CYII=);
|
||||
background-position: 95% center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.chzn-single, .chzn-drop, input.input-text, select {
|
||||
border-color: #fb7f88;
|
||||
}
|
||||
}
|
||||
::-webkit-input-placeholder {
|
||||
line-height: 1em;
|
||||
padding-top: 2px;
|
||||
}
|
||||
:-moz-placeholder {
|
||||
line-height: 1em;
|
||||
padding-top: 2px;
|
||||
}
|
||||
:-ms-input-placeholder {
|
||||
line-height: 1em;
|
||||
padding-top: 2px;
|
||||
}
|
||||
}
|
||||
.form-row-first, .form-row-last {
|
||||
float:left;
|
||||
|
@ -1396,10 +1446,10 @@ p.demo_store {
|
|||
text-transform:none;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
}
|
||||
|
||||
li.method {
|
||||
border:none;
|
||||
&:last-of-type {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Before Width: | Height: | Size: 380 B After Width: | Height: | Size: 806 B |
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 643 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 444 B |
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 677 B After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 711 B After Width: | Height: | Size: 1.4 KiB |
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
$strings = 'tinyMCE.addI18n({' . _WP_Editors::$mce_locale . ':{
|
||||
woocommerce:{
|
||||
insert: "' . esc_js( __( 'Insert Shortcode', 'woocommerce' ) ) . '",
|
||||
|
|
|
@ -3,21 +3,6 @@
|
|||
*/
|
||||
jQuery(function(){
|
||||
|
||||
// Live validation
|
||||
jQuery('body').on(
|
||||
'keyup',
|
||||
'.wc_input_price',
|
||||
function() {
|
||||
var $this = jQuery(this);
|
||||
var value = jQuery(this).val();
|
||||
if ( value !== '' && !jQuery.isNumeric( value ) ) {
|
||||
$this.addClass('wc-error');
|
||||
} else {
|
||||
$this.removeClass('wc-error');
|
||||
}
|
||||
}
|
||||
).keyup();
|
||||
|
||||
// Tooltips
|
||||
jQuery(".tips, .help_tip").tipTip({
|
||||
'attribute' : 'data-tip',
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
/**
|
||||
* WooCommerce Admin JS
|
||||
*/jQuery(function(){jQuery("body").on("keyup",".wc_input_price",function(){var e=jQuery(this),t=jQuery(this).val();t!==""&&!jQuery.isNumeric(t)?e.addClass("wc-error"):e.removeClass("wc-error")}).keyup();jQuery(".tips, .help_tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200});jQuery("select.availability").change(function(){jQuery(this).val()=="specific"?jQuery(this).closest("tr").next("tr").show():jQuery(this).closest("tr").next("tr").hide()}).change();jQuery(".hide_options_if_checked").each(function(){jQuery(this).find("input:eq(0)").change(function(){jQuery(this).is(":checked")?jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").hide():jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").show()}).change()});jQuery(".show_options_if_checked").each(function(){jQuery(this).find("input:eq(0)").change(function(){jQuery(this).is(":checked")?jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").show():jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").hide()}).change()});jQuery("input#woocommerce_demo_store").change(function(){jQuery(this).is(":checked")?jQuery("#woocommerce_demo_store_notice").closest("tr").show():jQuery("#woocommerce_demo_store_notice").closest("tr").hide()}).change()});
|
||||
*/jQuery(function(){jQuery(".tips, .help_tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200});jQuery("select.availability").change(function(){jQuery(this).val()=="specific"?jQuery(this).closest("tr").next("tr").show():jQuery(this).closest("tr").next("tr").hide()}).change();jQuery(".hide_options_if_checked").each(function(){jQuery(this).find("input:eq(0)").change(function(){jQuery(this).is(":checked")?jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").hide():jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").show()}).change()});jQuery(".show_options_if_checked").each(function(){jQuery(this).find("input:eq(0)").change(function(){jQuery(this).is(":checked")?jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").show():jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").hide()}).change()});jQuery("input#woocommerce_demo_store").change(function(){jQuery(this).is(":checked")?jQuery("#woocommerce_demo_store_notice").closest("tr").show():jQuery("#woocommerce_demo_store_notice").closest("tr").hide()}).change()});
|
|
@ -1,5 +1,21 @@
|
|||
jQuery( function($){
|
||||
|
||||
// Scroll to first checked category - https://github.com/scribu/wp-category-checklist-tree/blob/d1c3c1f449e1144542efa17dde84a9f52ade1739/category-checklist-tree.php
|
||||
$(function(){
|
||||
$('[id$="-all"] > ul.categorychecklist').each(function() {
|
||||
var $list = $(this);
|
||||
var $firstChecked = $list.find(':checked').first();
|
||||
|
||||
if ( !$firstChecked.length )
|
||||
return;
|
||||
|
||||
var pos_first = $list.find(':checkbox').position().top;
|
||||
var pos_checked = $firstChecked.position().top;
|
||||
|
||||
$list.closest('.tabs-panel').scrollTop(pos_checked - pos_first + 5);
|
||||
});
|
||||
});
|
||||
|
||||
// Prevent enter submitting post form
|
||||
$("#upsell_product_data").bind("keypress", function(e) {
|
||||
if (e.keyCode == 13) return false;
|
||||
|
@ -90,7 +106,7 @@ jQuery( function($){
|
|||
// TABS
|
||||
$('ul.wc-tabs').show();
|
||||
$('div.panel-wrap').each(function(){
|
||||
$('div.panel:not(div.panel:first)', this).hide();
|
||||
$(this).find('div.panel:not(:first)').hide();
|
||||
});
|
||||
$('ul.wc-tabs a').click(function(){
|
||||
var panel_wrap = $(this).closest('div.panel-wrap');
|
||||
|
@ -161,17 +177,17 @@ jQuery( function($){
|
|||
$(this).closest('.order_data').find('div.edit_address').show();
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
|
||||
$('#order_items_list').on( 'init_row', 'tr.item', function() {
|
||||
var $row = $(this);
|
||||
var $qty = $row.find('input.quantity');
|
||||
var qty = $qty.val();
|
||||
|
||||
|
||||
var line_subtotal = $row.find('input.line_subtotal').val();
|
||||
var line_total = $row.find('input.line_total').val();
|
||||
var line_tax = $row.find('input.line_tax').val();
|
||||
var line_subtotal_tax = $row.find('input.line_subtotal_tax').val();
|
||||
|
||||
|
||||
if ( qty ) {
|
||||
unit_subtotal = accounting.toFixed( ( line_subtotal / qty ), 2 );
|
||||
unit_subtotal_tax = accounting.toFixed( ( line_subtotal_tax / qty ), 2 );
|
||||
|
@ -180,58 +196,58 @@ jQuery( function($){
|
|||
} else {
|
||||
unit_subtotal = unit_subtotal_tax = unit_total = unit_total_tax = 0;
|
||||
}
|
||||
|
||||
|
||||
$qty.attr( 'data-o_qty', qty );
|
||||
$row.attr( 'data-unit_subtotal', unit_subtotal );
|
||||
$row.attr( 'data-unit_subtotal_tax', unit_subtotal_tax );
|
||||
$row.attr( 'data-unit_total', unit_total );
|
||||
$row.attr( 'data-unit_total_tax', unit_total_tax );
|
||||
});
|
||||
|
||||
|
||||
// When the page is loaded, store the unit costs
|
||||
$('#order_items_list tr.item').each( function() {
|
||||
$(this).trigger('init_row');
|
||||
} );
|
||||
|
||||
|
||||
// When the qty is changed, increase or decrease costs
|
||||
$('#order_items_list').on( 'change', 'input.quantity', function() {
|
||||
var $row = $(this).closest('tr.item');
|
||||
var qty = $(this).val();
|
||||
|
||||
|
||||
var unit_subtotal = $row.attr('data-unit_subtotal');
|
||||
var unit_subtotal_tax = $row.attr('data-unit_subtotal_tax');
|
||||
var unit_total = $row.attr('data-unit_total');
|
||||
var unit_total_tax = $row.attr('data-unit_total_tax');
|
||||
var o_qty = $(this).attr('data-o_qty');
|
||||
|
||||
|
||||
var subtotal = accounting.formatNumber( unit_subtotal * qty, 2, '' );
|
||||
var tax = accounting.formatNumber( unit_subtotal_tax * qty, 2, '' );
|
||||
var total = accounting.formatNumber( unit_total * qty, 2, '' );
|
||||
var total_tax = accounting.formatNumber( unit_total_tax * qty, 2, '' );
|
||||
|
||||
|
||||
$row.find('input.line_subtotal').val( subtotal );
|
||||
$row.find('input.line_total').val( total );
|
||||
$row.find('input.line_subtotal_tax').val( tax );
|
||||
$row.find('input.line_tax').val( total_tax );
|
||||
});
|
||||
|
||||
|
||||
// When subtotal is changed, update the unit costs
|
||||
$('#order_items_list').on( 'change', 'input.line_subtotal', function() {
|
||||
var $row = $(this).closest('tr.item');
|
||||
var $qty = $row.find('input.quantity');
|
||||
var qty = $qty.val();
|
||||
var value = ( qty ) ? accounting.toFixed( ( $(this).val() / qty ), 2 ) : 0;
|
||||
|
||||
|
||||
$row.attr( 'data-unit_subtotal', value );
|
||||
});
|
||||
|
||||
|
||||
// When total is changed, update the unit costs + discount amount
|
||||
$('#order_items_list').on( 'change', 'input.line_total', function() {
|
||||
var $row = $(this).closest('tr.item');
|
||||
var $qty = $row.find('input.quantity');
|
||||
var qty = $qty.val();
|
||||
var value = ( qty ) ? accounting.toFixed( ( $(this).val() / qty ), 2 ) : 0;
|
||||
|
||||
|
||||
$row.attr( 'data-unit_total', value );
|
||||
});
|
||||
|
||||
|
@ -241,27 +257,27 @@ jQuery( function($){
|
|||
var $qty = $row.find('input.quantity');
|
||||
var qty = $qty.val();
|
||||
var value = ( qty ) ? accounting.toFixed( ( $(this).val() / qty ), 2 ) : 0;
|
||||
|
||||
|
||||
$row.attr( 'data-unit_subtotal_tax', value );
|
||||
});
|
||||
|
||||
|
||||
// When total is changed, update the unit costs + discount amount
|
||||
$('#order_items_list').on( 'change', 'input.line_tax', function() {
|
||||
var $row = $(this).closest('tr.item');
|
||||
var $qty = $row.find('input.quantity');
|
||||
var qty = $qty.val();
|
||||
var value = ( qty ) ? accounting.toFixed( ( $(this).val() / qty ), 2 ) : 0;
|
||||
|
||||
|
||||
$row.attr( 'data-unit_total_tax', value );
|
||||
});
|
||||
|
||||
// Display a total for taxes
|
||||
|
||||
// Display a total for taxes
|
||||
$('#woocommerce-order-totals').on( 'change', '#_order_tax, #_order_shipping_tax, #_cart_discount, #_order_discount', function() {
|
||||
|
||||
|
||||
var $this = $(this);
|
||||
var fields = $this.closest('.totals').find('input');
|
||||
var total = 0;
|
||||
|
||||
|
||||
fields.each(function(){
|
||||
if ( $(this).val() )
|
||||
total = total + parseFloat( $(this).val() );
|
||||
|
@ -274,12 +290,12 @@ jQuery( function($){
|
|||
precision : woocommerce_writepanel_params.currency_format_num_decimals,
|
||||
format : woocommerce_writepanel_params.currency_format
|
||||
} );
|
||||
|
||||
|
||||
$this.closest('.totals_group').find('span.inline_total').text( formatted_total );
|
||||
} );
|
||||
|
||||
|
||||
$('span.inline_total').closest('.totals_group').find('input').change();
|
||||
|
||||
|
||||
// Calculate totals
|
||||
$('button.calc_line_taxes').live('click', function(){
|
||||
// Block write panel
|
||||
|
@ -302,25 +318,25 @@ jQuery( function($){
|
|||
var postcode = $('#_billing_postcode').val();
|
||||
var city = $('#_billing_city').val();
|
||||
}
|
||||
|
||||
|
||||
// Get items and values
|
||||
var calculate_items = {};
|
||||
|
||||
|
||||
$items.each( function() {
|
||||
|
||||
|
||||
var $row = $(this);
|
||||
|
||||
|
||||
var item_id = $row.find('input.order_item_id').val();
|
||||
var line_subtotal = $row.find('input.line_subtotal').val();
|
||||
var line_total = $row.find('input.line_total').val();
|
||||
var tax_class = $row.find('select.tax_class').val();
|
||||
|
||||
|
||||
calculate_items[ item_id ] = {};
|
||||
calculate_items[ item_id ].line_subtotal = line_subtotal;
|
||||
calculate_items[ item_id ].line_total = line_total;
|
||||
calculate_items[ item_id ].tax_class = tax_class;
|
||||
} );
|
||||
|
||||
|
||||
var data = {
|
||||
action: 'woocommerce_calc_line_taxes',
|
||||
order_id: woocommerce_writepanel_params.post_id,
|
||||
|
@ -334,21 +350,21 @@ jQuery( function($){
|
|||
};
|
||||
|
||||
$.post( woocommerce_writepanel_params.ajax_url, data, function( response ) {
|
||||
|
||||
|
||||
result = jQuery.parseJSON( response );
|
||||
|
||||
|
||||
$items.each( function() {
|
||||
var $row = $(this);
|
||||
var item_id = $row.find('input.order_item_id').val();
|
||||
|
||||
|
||||
$row.find('input.line_tax').val( result['item_taxes'][ item_id ]['line_tax'] ).change();
|
||||
$row.find('input.line_subtotal_tax').val( result['item_taxes'][ item_id ]['line_subtotal_tax'] ).change();
|
||||
$('#tax_rows').empty().append( result['tax_row_html'] );
|
||||
} );
|
||||
|
||||
|
||||
$('#_order_tax').val( result['item_tax'] ).change();
|
||||
$('#_order_shipping_tax').val( result['shipping_tax'] ).change();
|
||||
|
||||
|
||||
$('.woocommerce_order_items_wrapper').unblock();
|
||||
});
|
||||
|
||||
|
@ -407,7 +423,7 @@ jQuery( function($){
|
|||
|
||||
cart_tax = cart_tax + parseFloat( line_tax );
|
||||
});
|
||||
|
||||
|
||||
// Tax
|
||||
if (woocommerce_writepanel_params.round_at_subtotal=='yes') {
|
||||
cart_tax = accounting.toFixed( cart_tax, 2 );
|
||||
|
@ -417,7 +433,7 @@ jQuery( function($){
|
|||
var cart_discount = ( line_subtotals + line_subtotal_taxes ) - ( line_totals + cart_tax );
|
||||
if ( cart_discount < 0 ) cart_discount = 0;
|
||||
cart_discount = accounting.toFixed( cart_discount, 2 );
|
||||
|
||||
|
||||
$('#order_items_list tr.fee').each(function(){
|
||||
var line_total = accounting.unformat( $(this).find('input.line_total').val() );
|
||||
var line_tax = accounting.unformat( $(this).find('input.line_tax').val() );
|
||||
|
@ -443,7 +459,7 @@ jQuery( function($){
|
|||
var order_total = line_totals + cart_tax + order_shipping + order_shipping_tax - order_discount;
|
||||
order_total = accounting.toFixed( order_total, 2 );
|
||||
cart_tax = accounting.toFixed( cart_tax, 2 );
|
||||
|
||||
|
||||
// Set fields
|
||||
$('#_cart_discount').val( cart_discount ).change();
|
||||
$('#_order_tax').val( cart_tax ).change();
|
||||
|
@ -460,10 +476,10 @@ jQuery( function($){
|
|||
}, function() {
|
||||
$('#woocommerce-order-totals .calculated').css('background-color', '');
|
||||
});
|
||||
|
||||
|
||||
// Add a line item
|
||||
$('#woocommerce-order-items button.add_order_item').click(function(){
|
||||
|
||||
|
||||
var add_item_ids = $('select#add_item_id').val();
|
||||
|
||||
if ( add_item_ids ) {
|
||||
|
@ -496,7 +512,7 @@ jQuery( function($){
|
|||
$('select#add_item_id').trigger("liszt:updated");
|
||||
$('table.woocommerce_order_items').unblock();
|
||||
}
|
||||
|
||||
|
||||
$('#order_items_list tr.new_row').trigger('init_row').removeClass('new_row');
|
||||
});
|
||||
|
||||
|
@ -507,10 +523,10 @@ jQuery( function($){
|
|||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
// Add a fee
|
||||
$('#woocommerce-order-items button.add_order_fee').click(function(){
|
||||
|
||||
|
||||
$('table.woocommerce_order_items').block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_writepanel_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
|
||||
|
||||
var data = {
|
||||
|
@ -528,18 +544,18 @@ jQuery( function($){
|
|||
|
||||
// Add some meta to a line item
|
||||
$('#order_items_list button.add_order_item_meta').live('click', function(){
|
||||
|
||||
|
||||
var $button = $(this);
|
||||
var $item = $button.closest('tr.item');
|
||||
|
||||
|
||||
var data = {
|
||||
order_item_id: $item.attr( 'data-order_item_id' ),
|
||||
action: 'woocommerce_add_order_item_meta',
|
||||
security: woocommerce_writepanel_params.order_item_nonce
|
||||
};
|
||||
|
||||
|
||||
$('table.woocommerce_order_items').block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_writepanel_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
|
||||
|
||||
|
||||
$.ajax( {
|
||||
url: woocommerce_writepanel_params.ajax_url,
|
||||
data: data,
|
||||
|
@ -557,15 +573,15 @@ jQuery( function($){
|
|||
var answer = confirm( woocommerce_writepanel_params.remove_item_meta )
|
||||
if ( answer ) {
|
||||
var $row = $(this).closest('tr');
|
||||
|
||||
|
||||
var data = {
|
||||
meta_id: $row.attr( 'data-meta_id' ),
|
||||
action: 'woocommerce_remove_order_item_meta',
|
||||
security: woocommerce_writepanel_params.order_item_nonce
|
||||
};
|
||||
|
||||
|
||||
$('table.woocommerce_order_items').block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_writepanel_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
|
||||
|
||||
|
||||
$.ajax( {
|
||||
url: woocommerce_writepanel_params.ajax_url,
|
||||
data: data,
|
||||
|
@ -578,7 +594,7 @@ jQuery( function($){
|
|||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
// Bulk actions for line items
|
||||
$('#woocommerce-order-items').on( 'click', 'input.check-column', function() {
|
||||
if ( $(this).is(':checked') )
|
||||
|
@ -586,35 +602,35 @@ jQuery( function($){
|
|||
else
|
||||
$('#woocommerce-order-items').find('.check-column input').removeAttr('checked');
|
||||
} );
|
||||
|
||||
|
||||
$('#woocommerce-order-items').on( 'click', '.do_bulk_action', function() {
|
||||
|
||||
|
||||
var action = $(this).closest('.bulk_actions').find('select').val();
|
||||
var selected_rows = $('#woocommerce-order-items').find('.check-column input:checked');
|
||||
var item_ids = [];
|
||||
|
||||
|
||||
$(selected_rows).each( function() {
|
||||
|
||||
|
||||
var $item = $(this).closest('tr.item, tr.fee');
|
||||
|
||||
item_ids.push( $item.attr( 'data-order_item_id' ) );
|
||||
|
||||
|
||||
} );
|
||||
|
||||
|
||||
if ( action == 'delete' ) {
|
||||
|
||||
|
||||
var answer = confirm( woocommerce_writepanel_params.remove_item_notice );
|
||||
|
||||
|
||||
if ( answer ) {
|
||||
|
||||
|
||||
$('table.woocommerce_order_items').block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_writepanel_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
|
||||
|
||||
|
||||
var data = {
|
||||
order_item_ids: item_ids,
|
||||
action: 'woocommerce_remove_order_item',
|
||||
security: woocommerce_writepanel_params.order_item_nonce
|
||||
};
|
||||
|
||||
|
||||
$.ajax( {
|
||||
url: woocommerce_writepanel_params.ajax_url,
|
||||
data: data,
|
||||
|
@ -626,51 +642,58 @@ jQuery( function($){
|
|||
$('table.woocommerce_order_items').unblock();
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else if ( action == 'refund' ) {
|
||||
|
||||
var order_id = $('#post_ID').val();
|
||||
|
||||
|
||||
var answer = confirm( woocommerce_writepanel_params.refund_item_notice );
|
||||
|
||||
|
||||
if ( answer ) {
|
||||
|
||||
|
||||
$('table.woocommerce_order_items').block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_writepanel_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
|
||||
|
||||
|
||||
var data = {
|
||||
order_id: order_id,
|
||||
order_item_ids: item_ids,
|
||||
action: 'woocommerce_refund_order_item',
|
||||
security: woocommerce_writepanel_params.order_item_nonce
|
||||
};
|
||||
|
||||
|
||||
$.ajax( {
|
||||
url: woocommerce_writepanel_params.ajax_url,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
success: function( response ) {
|
||||
$.each( item_ids, function( i, val ) {
|
||||
$('tbody#order_items_list tr[data-order_item_id="' + val + '"]').addClass( 'refunded' );
|
||||
});
|
||||
|
||||
var response_obj = $.parseJSON(response);
|
||||
$('#_order_refund_total').val( response_obj.refund_total );
|
||||
|
||||
$('table.woocommerce_order_items').unblock();
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else if ( action == 'reduce_stock' ) {
|
||||
|
||||
|
||||
$('table.woocommerce_order_items').block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_writepanel_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
|
||||
|
||||
|
||||
var quantities = {};
|
||||
|
||||
|
||||
$(selected_rows).each( function() {
|
||||
|
||||
|
||||
var $item = $(this).closest('tr.item, tr.fee');
|
||||
var $qty = $item.find('input.quantity');
|
||||
|
||||
quantities[ $item.attr( 'data-order_item_id' ) ] = $qty.val();
|
||||
|
||||
quantities[ $item.attr( 'data-order_item_id' ) ] = $qty.val();
|
||||
} );
|
||||
|
||||
|
||||
var data = {
|
||||
order_id: woocommerce_writepanel_params.post_id,
|
||||
order_item_ids: item_ids,
|
||||
|
@ -678,7 +701,7 @@ jQuery( function($){
|
|||
action: 'woocommerce_reduce_order_item_stock',
|
||||
security: woocommerce_writepanel_params.order_item_nonce
|
||||
};
|
||||
|
||||
|
||||
$.ajax( {
|
||||
url: woocommerce_writepanel_params.ajax_url,
|
||||
data: data,
|
||||
|
@ -687,22 +710,22 @@ jQuery( function($){
|
|||
alert( response );
|
||||
$('table.woocommerce_order_items').unblock();
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
} else if ( action == 'increase_stock' ) {
|
||||
|
||||
$('table.woocommerce_order_items').block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_writepanel_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
|
||||
|
||||
|
||||
var quantities = {};
|
||||
|
||||
|
||||
$(selected_rows).each( function() {
|
||||
|
||||
|
||||
var $item = $(this).closest('tr.item, tr.fee');
|
||||
var $qty = $item.find('input.quantity');
|
||||
|
||||
quantities[ $item.attr( 'data-order_item_id' ) ] = $qty.val();
|
||||
|
||||
quantities[ $item.attr( 'data-order_item_id' ) ] = $qty.val();
|
||||
} );
|
||||
|
||||
|
||||
var data = {
|
||||
order_id: woocommerce_writepanel_params.post_id,
|
||||
order_item_ids: item_ids,
|
||||
|
@ -710,7 +733,7 @@ jQuery( function($){
|
|||
action: 'woocommerce_increase_order_item_stock',
|
||||
security: woocommerce_writepanel_params.order_item_nonce
|
||||
};
|
||||
|
||||
|
||||
$.ajax( {
|
||||
url: woocommerce_writepanel_params.ajax_url,
|
||||
data: data,
|
||||
|
@ -719,12 +742,12 @@ jQuery( function($){
|
|||
alert( response );
|
||||
$('table.woocommerce_order_items').unblock();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
||||
|
||||
|
||||
$('button.load_customer_billing').live('click', function(){
|
||||
|
||||
|
@ -862,13 +885,13 @@ jQuery( function($){
|
|||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
// Delete a tax row
|
||||
$('a.delete_tax_row').live('click', function(){
|
||||
$tax_row = $(this).closest('.tax_row');
|
||||
|
||||
|
||||
var tax_row_id = $tax_row.attr( 'data-order_item_id' )
|
||||
|
||||
|
||||
var data = {
|
||||
tax_row_id: tax_row_id,
|
||||
action: 'woocommerce_remove_line_tax',
|
||||
|
@ -886,7 +909,7 @@ jQuery( function($){
|
|||
$('#tax_rows').closest('.totals_group').unblock();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
@ -896,112 +919,127 @@ jQuery( function($){
|
|||
// Get value
|
||||
var select_val = $(this).val();
|
||||
|
||||
$('.hide_if_grouped, .hide_if_external').show();
|
||||
$('.show_if_simple, .show_if_variable, .show_if_grouped, .show_if_external').hide();
|
||||
|
||||
if (select_val=='simple') {
|
||||
$('.show_if_simple').show();
|
||||
if (select_val=='variable') {
|
||||
$('input#_manage_stock').change();
|
||||
}
|
||||
|
||||
else if (select_val=='variable') {
|
||||
$('.show_if_variable').show();
|
||||
$('input#_manage_stock').change();
|
||||
$('input#_downloadable').prop('checked', false).change();
|
||||
$('input#_virtual').removeAttr('checked').change();
|
||||
$('input#_downloadable').prop('checked', false);
|
||||
$('input#_virtual').removeAttr('checked');
|
||||
}
|
||||
|
||||
else if (select_val=='grouped') {
|
||||
$('.show_if_grouped').show();
|
||||
$('input#_downloadable').prop('checked', false).change();
|
||||
$('input#_virtual').removeAttr('checked').change();
|
||||
$('.hide_if_grouped').hide();
|
||||
$('input#_downloadable').prop('checked', false);
|
||||
$('input#_virtual').removeAttr('checked');
|
||||
}
|
||||
|
||||
else if (select_val=='external') {
|
||||
$('.show_if_external').show();
|
||||
$('input#_downloadable').prop('checked', false).change();
|
||||
$('input#_virtual').removeAttr('checked').change();
|
||||
$('.hide_if_external').hide();
|
||||
$('input#_downloadable').prop('checked', false);
|
||||
$('input#_virtual').removeAttr('checked');
|
||||
}
|
||||
|
||||
|
||||
show_and_hide_panels();
|
||||
|
||||
$('ul.wc-tabs li:visible').eq(0).find('a').click();
|
||||
|
||||
$('body').trigger('woocommerce-product-type-change', select_val, $(this) );
|
||||
|
||||
}).change();
|
||||
|
||||
$('input#_downloadable').change(function(){
|
||||
$('input#_downloadable, input#_virtual').change(function(){
|
||||
show_and_hide_panels();
|
||||
});
|
||||
|
||||
$('.show_if_downloadable').hide();
|
||||
function show_and_hide_panels() {
|
||||
var product_type = $('select#product-type').val();
|
||||
var is_virtual = $('input#_virtual:checked').size();
|
||||
var is_downloadable = $('input#_downloadable:checked').size();
|
||||
|
||||
if ($('input#_downloadable').is(':checked')) {
|
||||
// Hide/Show all with rules
|
||||
$('.hide_if_simple, .hide_if_grouped, .hide_if_variable, .hide_if_external, .hide_if_downloadable, .hide_if_virtual').show();
|
||||
$('.show_if_simple, .show_if_grouped, .show_if_variable, .show_if_external, .show_if_downloadable, .show_if_virtual').hide();
|
||||
|
||||
// Shows rules
|
||||
if ( is_downloadable ) {
|
||||
$('.show_if_downloadable').show();
|
||||
}
|
||||
|
||||
if ($('.downloads_tab').is('.active')) $('ul.wc-tabs li:visible').eq(0).find('a').click();
|
||||
|
||||
}).change();
|
||||
|
||||
$('input#_virtual').change(function(){
|
||||
|
||||
$('.show_if_virtual').hide();
|
||||
$('.hide_if_virtual').show();
|
||||
|
||||
if ($('input#_virtual').is(':checked')) {
|
||||
if ( is_virtual ) {
|
||||
$('.show_if_virtual').show();
|
||||
}
|
||||
|
||||
if ( product_type == 'simple' ) {
|
||||
$('.show_if_simple').show();
|
||||
} else if ( product_type == 'variable' ) {
|
||||
$('.show_if_variable').show();
|
||||
} else if ( product_type == 'grouped' ) {
|
||||
$('.show_if_grouped').show();
|
||||
} else if ( product_type == 'external' ) {
|
||||
$('.show_if_external').show();
|
||||
}
|
||||
|
||||
// Hide rules
|
||||
if ( is_downloadable ) {
|
||||
$('.hide_if_downloadable').hide();
|
||||
}
|
||||
if ( is_virtual ) {
|
||||
$('.hide_if_virtual').hide();
|
||||
}
|
||||
|
||||
}).change();
|
||||
if ( product_type == 'simple' ) {
|
||||
$('.hide_if_simple').hide();
|
||||
} else if ( product_type == 'variable' ) {
|
||||
$('.hide_if_variable').hide();
|
||||
} else if ( product_type == 'grouped' ) {
|
||||
$('.hide_if_grouped').hide();
|
||||
} else if ( product_type == 'external' ) {
|
||||
$('.hide_if_external').hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Sale price schedule
|
||||
$('.sale_price_dates_fields').each(function() {
|
||||
|
||||
|
||||
var $these_sale_dates = $(this);
|
||||
var sale_schedule_set = false;
|
||||
var $wrap = $these_sale_dates.closest( 'div, table' );
|
||||
|
||||
|
||||
$these_sale_dates.find('input').each(function(){
|
||||
if ( $(this).val() != '' )
|
||||
if ( $(this).val() != '' )
|
||||
sale_schedule_set = true;
|
||||
});
|
||||
|
||||
|
||||
if ( sale_schedule_set ) {
|
||||
|
||||
|
||||
$wrap.find('.sale_schedule').hide();
|
||||
$wrap.find('.sale_price_dates_fields').show();
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
$wrap.find('.sale_schedule').show();
|
||||
$wrap.find('.sale_price_dates_fields').hide();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('#woocommerce-product-data').on( 'click', '.sale_schedule', function() {
|
||||
var $wrap = $(this).closest( 'div, table' );
|
||||
|
||||
|
||||
$(this).hide();
|
||||
$wrap.find('.cancel_sale_schedule').show();
|
||||
$wrap.find('.sale_price_dates_fields').show();
|
||||
|
||||
|
||||
return false;
|
||||
});
|
||||
$('#woocommerce-product-data').on( 'click', '.cancel_sale_schedule', function() {
|
||||
var $wrap = $(this).closest( 'div, table' );
|
||||
|
||||
|
||||
$(this).hide();
|
||||
$wrap.find('.sale_schedule').show();
|
||||
$wrap.find('.sale_price_dates_fields').hide();
|
||||
$wrap.find('.sale_price_dates_fields').find('input').val('');
|
||||
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
// STOCK OPTIONS
|
||||
$('input#_manage_stock').change(function(){
|
||||
|
@ -1249,6 +1287,36 @@ jQuery( function($){
|
|||
|
||||
});
|
||||
|
||||
// Save attributes and update variations
|
||||
$('.save_attributes').on('click', function(){
|
||||
|
||||
$('.woocommerce_attributes').block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_writepanel_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
|
||||
|
||||
var data = {
|
||||
post_id: woocommerce_writepanel_params.post_id,
|
||||
data: $('.woocommerce_attributes').find('input, select').serialize(),
|
||||
action: 'woocommerce_save_attributes',
|
||||
security: woocommerce_writepanel_params.save_attributes_nonce
|
||||
};
|
||||
|
||||
$.post( woocommerce_writepanel_params.ajax_url, data, function( response ) {
|
||||
|
||||
var this_page = window.location.toString();
|
||||
|
||||
this_page = this_page.replace( 'post-new.php?', 'post.php?post=' + woocommerce_writepanel_params.post_id + '&action=edit&' );
|
||||
|
||||
// Load variations panel
|
||||
$('#variable_product_options').block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_writepanel_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
|
||||
$('#variable_product_options').load( this_page + ' #variable_product_options_inner', function() {
|
||||
$('#variable_product_options').unblock();
|
||||
} );
|
||||
|
||||
$('.woocommerce_attributes').unblock();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Uploading files
|
||||
var file_path_field;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,
|
||||
|
||||
/*
|
||||
* Private methods
|
||||
* Private methods
|
||||
*/
|
||||
|
||||
_abort = function() {
|
||||
|
@ -62,8 +62,8 @@
|
|||
|
||||
_start = function() {
|
||||
var obj = selectedArray[ selectedIndex ],
|
||||
href,
|
||||
type,
|
||||
href,
|
||||
type,
|
||||
title,
|
||||
str,
|
||||
emb,
|
||||
|
@ -145,7 +145,7 @@
|
|||
selectedOpts.width = 'auto';
|
||||
selectedOpts.height = 'auto';
|
||||
} else {
|
||||
selectedOpts.autoDimensions = false;
|
||||
selectedOpts.autoDimensions = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@
|
|||
tmp.css('padding', (selectedOpts.padding + selectedOpts.margin));
|
||||
|
||||
$('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
|
||||
$(this).replaceWith(content.children());
|
||||
$(this).replaceWith(content.children());
|
||||
});
|
||||
|
||||
switch (type) {
|
||||
|
@ -284,14 +284,14 @@
|
|||
w = parseInt( ($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px';
|
||||
|
||||
} else {
|
||||
w = w == 'auto' ? 'auto' : w + 'px';
|
||||
w = w == 'auto' ? 'auto' : w + 'px';
|
||||
}
|
||||
|
||||
if (h.toString().indexOf('%') > -1) {
|
||||
h = parseInt( ($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px';
|
||||
|
||||
} else {
|
||||
h = h == 'auto' ? 'auto' : h + 'px';
|
||||
h = h == 'auto' ? 'auto' : h + 'px';
|
||||
}
|
||||
|
||||
tmp.wrapInner('<div style="width:' + w + ';height:' + h + ';overflow: ' + (selectedOpts.scrolling == 'auto' ? 'auto' : (selectedOpts.scrolling == 'yes' ? 'scroll' : 'hidden')) + ';position:relative;"></div>');
|
||||
|
@ -444,8 +444,8 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if (currentOpts.titlePosition == 'inside' && titleHeight > 0) {
|
||||
title.show();
|
||||
if (currentOpts.titlePosition == 'inside' && titleHeight > 0) {
|
||||
title.show();
|
||||
}
|
||||
|
||||
content
|
||||
|
@ -555,7 +555,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
if (!currentOpts.showNavArrows) {
|
||||
if (!currentOpts.showNavArrows) {
|
||||
nav_left.hide();
|
||||
nav_right.hide();
|
||||
return;
|
||||
|
@ -591,7 +591,7 @@
|
|||
}
|
||||
|
||||
_set_navigation();
|
||||
|
||||
|
||||
if (currentOpts.hideOnContentClick) {
|
||||
content.bind('click', $.fancybox.close);
|
||||
}
|
||||
|
@ -622,7 +622,7 @@
|
|||
},
|
||||
|
||||
_preload_images = function() {
|
||||
var href,
|
||||
var href,
|
||||
objNext;
|
||||
|
||||
if ((currentArray.length -1) > currentIndex) {
|
||||
|
@ -776,7 +776,7 @@
|
|||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
$.fn.fancybox = function(options) {
|
||||
|
@ -1009,14 +1009,14 @@
|
|||
var view, align;
|
||||
|
||||
if (busy) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
align = arguments[0] === true ? 1 : 0;
|
||||
view = _get_viewport();
|
||||
|
||||
if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
wrap
|
||||
|
@ -1145,21 +1145,21 @@
|
|||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
$.fancybox.init();
|
||||
|
||||
|
||||
// Hide review form - it will be in a lightbox
|
||||
$('#review_form_wrapper').hide();
|
||||
|
||||
|
||||
// Lightbox
|
||||
$('a.zoom, a.show_review_form').fancybox({
|
||||
'transitionIn' : 'elastic',
|
||||
'transitionOut' : 'elastic',
|
||||
'speedIn' : 600,
|
||||
'speedOut' : 200,
|
||||
'speedIn' : 600,
|
||||
'speedOut' : 200,
|
||||
'overlayShow' : true
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
|
@ -9,18 +9,26 @@ jQuery(document).ready(function($) {
|
|||
.on( 'click', '.reset_variations', function( event ) {
|
||||
|
||||
$(this).closest('form.variations_form').find('.variations select').val('').change();
|
||||
|
||||
var $sku = $(this).closest('.product').find('.sku');
|
||||
|
||||
var $sku = $(this).closest('.product').find('.sku');
|
||||
var $weight = $(this).closest('.product').find('.product_weight');
|
||||
var $dimensions = $(this).closest('.product').find('.product_dimensions');
|
||||
|
||||
if ( $sku.attr( 'data-o_sku' ) )
|
||||
$sku.text( $sku.attr( 'data-o_sku' ) );
|
||||
|
||||
if ( $weight.attr( 'data-o_weight' ) )
|
||||
$weight.text( $weight.attr( 'data-o_weight' ) );
|
||||
|
||||
if ( $dimensions.attr( 'data-o_dimensions' ) )
|
||||
$dimensions.text( $dimensions.attr( 'data-o_dimensions' ) );
|
||||
|
||||
return false;
|
||||
} )
|
||||
|
||||
// Upon changing an option
|
||||
.on( 'change', '.variations select', function( event ) {
|
||||
|
||||
|
||||
$variation_form = $(this).closest('form.variations_form');
|
||||
$variation_form.find('input[name=variation_id]').val('').change();
|
||||
|
||||
|
@ -87,11 +95,11 @@ jQuery(document).ready(function($) {
|
|||
|
||||
var product_id = parseInt( $variation_form.attr( 'data-product_id' ) );
|
||||
var all_variations = window[ "product_variations" ][ product_id ];
|
||||
|
||||
|
||||
// Fallback
|
||||
if ( ! all_variations )
|
||||
if ( ! all_variations )
|
||||
all_variations = window[ "product_variations" ];
|
||||
|
||||
|
||||
var matching_variations = find_matching_variations( all_variations, current_settings );
|
||||
|
||||
if ( all_set ) {
|
||||
|
@ -115,8 +123,8 @@ jQuery(document).ready(function($) {
|
|||
|
||||
if ( ! focus )
|
||||
$variation_form.trigger( 'reset_image' );
|
||||
|
||||
alert( woocommerce_params.no_matching_variations_text );
|
||||
|
||||
alert( woocommerce_params.i18n_no_matching_variations_text );
|
||||
|
||||
}
|
||||
|
||||
|
@ -227,11 +235,11 @@ jQuery(document).ready(function($) {
|
|||
// Show single variation details (price, stock, image)
|
||||
.on( 'found_variation', function( event, variation ) {
|
||||
var $variation_form = $(this);
|
||||
|
||||
|
||||
var $product = $(this).closest( '.product' );
|
||||
var $product_img = $product.find( 'div.images img:eq(0)' );
|
||||
var $product_link = $product.find( 'div.images a.zoom:eq(0)' );
|
||||
|
||||
|
||||
var o_src = $product_img.attr('data-o_src');
|
||||
var o_title = $product_img.attr('data-o_title');
|
||||
var o_href = $product_link.attr('data-o_href');
|
||||
|
@ -277,33 +285,53 @@ jQuery(document).ready(function($) {
|
|||
}
|
||||
|
||||
var $single_variation_wrap = $variation_form.find('.single_variation_wrap');
|
||||
|
||||
var $sku = $product.find('.product_meta').find('.sku');
|
||||
|
||||
|
||||
var $sku = $product.find('.product_meta').find('.sku');
|
||||
var $weight = $product.find('.product_weight');
|
||||
var $dimensions = $product.find('.product_dimensions');
|
||||
|
||||
if ( ! $sku.attr( 'data-o_sku' ) )
|
||||
$sku.attr( 'data-o_sku', $sku.text() );
|
||||
|
||||
|
||||
if ( ! $weight.attr( 'data-o_weight' ) )
|
||||
$weight.attr( 'data-o_weight', $weight.text() );
|
||||
|
||||
if ( ! $dimensions.attr( 'data-o_dimensions' ) )
|
||||
$dimensions.attr( 'data-o_dimensions', $dimensions.text() );
|
||||
|
||||
if ( variation.sku ) {
|
||||
$sku.text( variation.sku );
|
||||
} else {
|
||||
$sku.text( $sku.attr( 'data-o_sku' ) );
|
||||
}
|
||||
|
||||
if ( variation.weight ) {
|
||||
$weight.text( variation.weight );
|
||||
} else {
|
||||
$weight.text( $weight.attr( 'data-o_weight' ) );
|
||||
}
|
||||
|
||||
if ( variation.dimensions ) {
|
||||
$dimensions.text( variation.dimensions );
|
||||
} else {
|
||||
$dimensions.text( $dimensions.attr( 'data-o_dimensions' ) );
|
||||
}
|
||||
|
||||
$single_variation_wrap.find('.quantity').show();
|
||||
|
||||
|
||||
if ( ! variation.is_in_stock && ! variation.backorders_allowed ) {
|
||||
$variation_form.find('.variations_button').hide();
|
||||
}
|
||||
|
||||
|
||||
if ( variation.min_qty )
|
||||
$single_variation_wrap.find('input[name=quantity]').attr( 'data-min', variation.min_qty ).val( variation.min_qty );
|
||||
$single_variation_wrap.find('input[name=quantity]').attr( 'min', variation.min_qty ).val( variation.min_qty );
|
||||
else
|
||||
$single_variation_wrap.find('input[name=quantity]').removeAttr('data-min');
|
||||
$single_variation_wrap.find('input[name=quantity]').removeAttr('min');
|
||||
|
||||
if ( variation.max_qty )
|
||||
$single_variation_wrap.find('input[name=quantity]').attr('data-max', variation.max_qty);
|
||||
$single_variation_wrap.find('input[name=quantity]').attr('max', variation.max_qty);
|
||||
else
|
||||
$single_variation_wrap.find('input[name=quantity]').removeAttr('data-max');
|
||||
$single_variation_wrap.find('input[name=quantity]').removeAttr('max');
|
||||
|
||||
if ( variation.is_sold_individually == 'yes' ) {
|
||||
$single_variation_wrap.find('input[name=quantity]').val('1');
|
||||
|
|
|
@ -2,43 +2,43 @@ jQuery(document).ready(function($) {
|
|||
|
||||
// Ajax add to cart
|
||||
$('.add_to_cart_button').live('click', function() {
|
||||
|
||||
|
||||
// AJAX add to cart request
|
||||
var $thisbutton = $(this);
|
||||
|
||||
|
||||
if ($thisbutton.is('.product_type_simple, .product_type_downloadable, .product_type_virtual')) {
|
||||
|
||||
|
||||
if (!$thisbutton.attr('data-product_id')) return true;
|
||||
|
||||
|
||||
$thisbutton.removeClass('added');
|
||||
$thisbutton.addClass('loading');
|
||||
|
||||
|
||||
var data = {
|
||||
action: 'woocommerce_add_to_cart',
|
||||
product_id: $thisbutton.attr('data-product_id'),
|
||||
security: woocommerce_params.add_to_cart_nonce
|
||||
};
|
||||
|
||||
|
||||
// Trigger event
|
||||
$('body').trigger('adding_to_cart');
|
||||
|
||||
|
||||
// Ajax action
|
||||
$.post( woocommerce_params.ajax_url, data, function(response) {
|
||||
|
||||
|
||||
var this_page = window.location.toString();
|
||||
|
||||
|
||||
this_page = this_page.replace( 'add-to-cart', 'added-to-cart' );
|
||||
|
||||
|
||||
$thisbutton.removeClass('loading');
|
||||
|
||||
// Get response
|
||||
data = $.parseJSON( response );
|
||||
|
||||
|
||||
if (data.error && data.product_url) {
|
||||
window.location = data.product_url;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
fragments = data;
|
||||
|
||||
// Block fragments class
|
||||
|
@ -47,12 +47,13 @@ jQuery(document).ready(function($) {
|
|||
$(key).addClass('updating');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Block widgets and fragments
|
||||
$('.widget_shopping_cart, .shop_table.cart, .updating, .cart_totals').fadeTo('400', '0.6').block({message: null, overlayCSS: {background: 'transparent url(' + woocommerce_params.ajax_loader_url + ') no-repeat center', opacity: 0.6 } } );
|
||||
|
||||
|
||||
// Changes button classes
|
||||
$thisbutton.addClass('added');
|
||||
if ( $thisbutton.parent().find('.added_to_cart').size() == 0 )
|
||||
$thisbutton.addClass('added').after( ' <a href="' + woocommerce_params.cart_url + '" class="added_to_cart" title="' + woocommerce_params.i18n_view_cart + '">' + woocommerce_params.i18n_view_cart + '</a>' );
|
||||
|
||||
// Cart widget load
|
||||
if ($('.widget_shopping_cart').size()>0) {
|
||||
|
@ -64,10 +65,10 @@ jQuery(document).ready(function($) {
|
|||
$(key).replaceWith(value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Unblock
|
||||
$('.widget_shopping_cart, .updating').stop(true).css('opacity', '1').unblock();
|
||||
|
||||
|
||||
$('body').trigger('cart_widget_refreshed');
|
||||
} );
|
||||
} else {
|
||||
|
@ -77,36 +78,36 @@ jQuery(document).ready(function($) {
|
|||
$(key).replaceWith(value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Unblock
|
||||
$('.widget_shopping_cart, .updating').stop(true).css('opacity', '1').unblock();
|
||||
}
|
||||
|
||||
|
||||
// Cart page elements
|
||||
$('.shop_table.cart').load( this_page + ' .shop_table.cart:eq(0) > *', function() {
|
||||
|
||||
|
||||
$("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass('buttons_added').append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');
|
||||
|
||||
|
||||
$('.shop_table.cart').stop(true).css('opacity', '1').unblock();
|
||||
|
||||
|
||||
$('body').trigger('cart_page_refreshed');
|
||||
});
|
||||
|
||||
|
||||
$('.cart_totals').load( this_page + ' .cart_totals:eq(0) > *', function() {
|
||||
$('.cart_totals').stop(true).css('opacity', '1').unblock();
|
||||
});
|
||||
|
||||
|
||||
// Trigger event so themes can refresh other areas
|
||||
$('body').trigger('added_to_cart');
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
|
@ -1 +1 @@
|
|||
jQuery(document).ready(function(e){e(".add_to_cart_button").live("click",function(){var t=e(this);if(t.is(".product_type_simple, .product_type_downloadable, .product_type_virtual")){if(!t.attr("data-product_id"))return!0;t.removeClass("added");t.addClass("loading");var n={action:"woocommerce_add_to_cart",product_id:t.attr("data-product_id"),security:woocommerce_params.add_to_cart_nonce};e("body").trigger("adding_to_cart");e.post(woocommerce_params.ajax_url,n,function(r){var i=window.location.toString();i=i.replace("add-to-cart","added-to-cart");t.removeClass("loading");n=e.parseJSON(r);if(n.error&&n.product_url){window.location=n.product_url;return}fragments=n;fragments&&e.each(fragments,function(t,n){e(t).addClass("updating")});e(".widget_shopping_cart, .shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{background:"transparent url("+woocommerce_params.ajax_loader_url+") no-repeat center",opacity:.6}});t.addClass("added");if(e(".widget_shopping_cart").size()>0)e(".widget_shopping_cart:eq(0)").load(i+" .widget_shopping_cart:eq(0) > *",function(){fragments&&e.each(fragments,function(t,n){e(t).replaceWith(n)});e(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock();e("body").trigger("cart_widget_refreshed")});else{fragments&&e.each(fragments,function(t,n){e(t).replaceWith(n)});e(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock()}e(".shop_table.cart").load(i+" .shop_table.cart:eq(0) > *",function(){e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');e(".shop_table.cart").stop(!0).css("opacity","1").unblock();e("body").trigger("cart_page_refreshed")});e(".cart_totals").load(i+" .cart_totals:eq(0) > *",function(){e(".cart_totals").stop(!0).css("opacity","1").unblock()});e("body").trigger("added_to_cart")});return!1}return!0})});
|
||||
jQuery(document).ready(function(e){e(".add_to_cart_button").live("click",function(){var t=e(this);if(t.is(".product_type_simple, .product_type_downloadable, .product_type_virtual")){if(!t.attr("data-product_id"))return!0;t.removeClass("added");t.addClass("loading");var n={action:"woocommerce_add_to_cart",product_id:t.attr("data-product_id"),security:woocommerce_params.add_to_cart_nonce};e("body").trigger("adding_to_cart");e.post(woocommerce_params.ajax_url,n,function(r){var i=window.location.toString();i=i.replace("add-to-cart","added-to-cart");t.removeClass("loading");n=e.parseJSON(r);if(n.error&&n.product_url){window.location=n.product_url;return}fragments=n;fragments&&e.each(fragments,function(t,n){e(t).addClass("updating")});e(".widget_shopping_cart, .shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{background:"transparent url("+woocommerce_params.ajax_loader_url+") no-repeat center",opacity:.6}});t.parent().find(".added_to_cart").size()==0&&t.addClass("added").after(' <a href="'+woocommerce_params.cart_url+'" class="added_to_cart" title="'+woocommerce_params.i18n_view_cart+'">'+woocommerce_params.i18n_view_cart+"</a>");if(e(".widget_shopping_cart").size()>0)e(".widget_shopping_cart:eq(0)").load(i+" .widget_shopping_cart:eq(0) > *",function(){fragments&&e.each(fragments,function(t,n){e(t).replaceWith(n)});e(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock();e("body").trigger("cart_widget_refreshed")});else{fragments&&e.each(fragments,function(t,n){e(t).replaceWith(n)});e(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock()}e(".shop_table.cart").load(i+" .shop_table.cart:eq(0) > *",function(){e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');e(".shop_table.cart").stop(!0).css("opacity","1").unblock();e("body").trigger("cart_page_refreshed")});e(".cart_totals").load(i+" .cart_totals:eq(0) > *",function(){e(".cart_totals").stop(!0).css("opacity","1").unblock()});e("body").trigger("added_to_cart")});return!1}return!0})});
|
|
@ -3,52 +3,62 @@ jQuery(document).ready(function($) {
|
|||
var updateTimer;
|
||||
var dirtyInput = false;
|
||||
var xhr;
|
||||
|
||||
|
||||
function update_checkout() {
|
||||
|
||||
|
||||
if (xhr) xhr.abort();
|
||||
|
||||
if ( $('select#shipping_method').size() > 0 )
|
||||
|
||||
if ( $('select#shipping_method').size() > 0 )
|
||||
var method = $('select#shipping_method').val();
|
||||
else
|
||||
var method = $('input[name=shipping_method]:checked').val();
|
||||
|
||||
|
||||
var payment_method = $('#order_review input[name=payment_method]:checked').val();
|
||||
var country = $('#billing_country').val();
|
||||
var state = $('#billing_state').val();
|
||||
var postcode = $('input#billing_postcode').val();
|
||||
var city = $('input#billing_city').val();
|
||||
|
||||
var city = $('input#billing_city').val();
|
||||
var address = $('input#billing_address_1').val();
|
||||
var address_2 = $('input#billing_address_2').val();
|
||||
|
||||
if ( $('#shiptobilling input').is(':checked') || $('#shiptobilling input').size() == 0 ) {
|
||||
var s_country = country;
|
||||
var s_state = state;
|
||||
var s_postcode = postcode;
|
||||
var s_city = city;
|
||||
var s_address = address;
|
||||
var s_address_2 = address_2;
|
||||
} else {
|
||||
var s_country = $('#shipping_country').val();
|
||||
var s_state = $('#shipping_state').val();
|
||||
var s_postcode = $('input#shipping_postcode').val();
|
||||
var s_city = $('input#shipping_city').val();
|
||||
var s_address = $('input#shipping_address_1').val();
|
||||
var s_address_2 = $('input#shipping_address_2').val();
|
||||
}
|
||||
|
||||
|
||||
$('#order_methods, #order_review').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.ajax_loader_url + ') no-repeat center', opacity: 0.6}});
|
||||
|
||||
|
||||
var data = {
|
||||
action: 'woocommerce_update_order_review',
|
||||
security: woocommerce_params.update_order_review_nonce,
|
||||
shipping_method: method,
|
||||
shipping_method: method,
|
||||
payment_method: payment_method,
|
||||
country: country,
|
||||
state: state,
|
||||
postcode: postcode,
|
||||
country: country,
|
||||
state: state,
|
||||
postcode: postcode,
|
||||
city: city,
|
||||
s_country: s_country,
|
||||
s_state: s_state,
|
||||
address: address,
|
||||
address_2: address_2,
|
||||
s_country: s_country,
|
||||
s_state: s_state,
|
||||
s_postcode: s_postcode,
|
||||
s_city: s_city,
|
||||
s_address: s_address,
|
||||
s_address_2: s_address_2,
|
||||
post_data: $('form.checkout').serialize()
|
||||
};
|
||||
|
||||
|
||||
xhr = $.ajax({
|
||||
type: 'POST',
|
||||
url: woocommerce_params.ajax_url,
|
||||
|
@ -56,56 +66,55 @@ jQuery(document).ready(function($) {
|
|||
success: function( response ) {
|
||||
if ( response ) {
|
||||
$('#order_review').after(response).remove();
|
||||
$('#order_review input[name=payment_method]:checked').click();
|
||||
$('body').trigger('updated_checkout');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Event for updating the checkout
|
||||
$('body').bind('update_checkout', function() {
|
||||
clearTimeout(updateTimer);
|
||||
update_checkout();
|
||||
});
|
||||
|
||||
|
||||
$('p.password, form.login, .checkout_coupon, div.shipping_address').hide();
|
||||
|
||||
|
||||
$('input.show_password').change(function(){
|
||||
$('p.password').slideToggle();
|
||||
});
|
||||
|
||||
|
||||
$('a.showlogin').click(function(){
|
||||
$('form.login').slideToggle();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$('a.showcoupon').click(function(){
|
||||
$('.checkout_coupon').slideToggle();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$('#shiptobilling input').change(function(){
|
||||
$('div.shipping_address').hide();
|
||||
if (!$(this).is(':checked')) {
|
||||
$('div.shipping_address').slideDown();
|
||||
}
|
||||
}).change();
|
||||
|
||||
|
||||
if (woocommerce_params.option_guest_checkout=='yes') {
|
||||
|
||||
|
||||
$('div.create-account').hide();
|
||||
|
||||
|
||||
$('input#createaccount').change(function(){
|
||||
$('div.create-account').hide();
|
||||
if ($(this).is(':checked')) {
|
||||
$('div.create-account').slideDown();
|
||||
}
|
||||
}).change();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$('.payment_methods input.input-radio').live('click', function(){
|
||||
if ( $('.payment_methods input.input-radio').length > 1 ) {
|
||||
$('div.payment_box').filter(':visible').slideUp(250);
|
||||
|
@ -116,16 +125,16 @@ jQuery(document).ready(function($) {
|
|||
$('div.payment_box').show();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('#order_review input[name=payment_method]:checked').click();
|
||||
|
||||
|
||||
/* Update totals */
|
||||
// Inputs/selects which update totals instantly
|
||||
$('select#shipping_method, input[name=shipping_method], #shiptobilling input, .update_totals_on_change select').live('change', function(){
|
||||
clearTimeout( updateTimer );
|
||||
$('body').trigger('update_checkout');
|
||||
});
|
||||
|
||||
|
||||
// Inputs which update totals on change
|
||||
function input_changed() {
|
||||
dirtyInput = false;
|
||||
|
@ -145,33 +154,33 @@ jQuery(document).ready(function($) {
|
|||
clearTimeout( updateTimer );
|
||||
updateTimer = setTimeout( input_changed, '1000' );
|
||||
});
|
||||
|
||||
|
||||
/* AJAX Coupon Form Submission */
|
||||
$('form.checkout_coupon').submit( function() {
|
||||
var $form = $(this);
|
||||
|
||||
|
||||
if ( $form.is('.processing') ) return false;
|
||||
|
||||
|
||||
$form.addClass('processing').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.ajax_loader_url + ') no-repeat center', opacity: 0.6}});
|
||||
|
||||
|
||||
var data = {
|
||||
action: 'woocommerce_apply_coupon',
|
||||
security: woocommerce_params.apply_coupon_nonce,
|
||||
coupon_code: $form.find('input[name=coupon_code]').val()
|
||||
};
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: woocommerce_params.ajax_url,
|
||||
data: data,
|
||||
success: function( code ) {
|
||||
$('.woocommerce_error, .woocommerce_message').remove();
|
||||
$form.removeClass('processing').unblock();
|
||||
|
||||
$form.removeClass('processing').unblock();
|
||||
|
||||
if ( code ) {
|
||||
$form.before( code );
|
||||
$form.slideUp();
|
||||
|
||||
|
||||
$('body').trigger('update_checkout');
|
||||
}
|
||||
},
|
||||
|
@ -179,50 +188,82 @@ jQuery(document).ready(function($) {
|
|||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
/* Inline validation */
|
||||
$('form.checkout').on( 'blur change', '.input-text, select', function() {
|
||||
var $this = $(this);
|
||||
var $parent = $this.closest('.form-row');
|
||||
var validated = true;
|
||||
|
||||
if ( $parent.is( '.validate-required' ) ) {
|
||||
if ( $this.val() == '' ) {
|
||||
$parent.removeClass( 'wc-validated' ).addClass( 'wc-error wc-error-required-field' );
|
||||
validated = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $parent.is( '.validate-email' ) ) {
|
||||
if ( $this.val() ) {
|
||||
|
||||
/* http://stackoverflow.com/questions/2855865/jquery-validate-e-mail-address-regex */
|
||||
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
|
||||
|
||||
if ( ! pattern.test( $this.val() ) ) {
|
||||
$parent.removeClass( 'wc-validated' ).addClass( 'wc-error wc-error-email' );
|
||||
validated = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( validated ) {
|
||||
$parent.removeClass( 'wc-error wc-error-required-field' ).addClass( 'wc-validated' );
|
||||
}
|
||||
} );
|
||||
|
||||
/* AJAX Form Submission */
|
||||
$('form.checkout').submit( function() {
|
||||
clearTimeout( updateTimer );
|
||||
|
||||
|
||||
var $form = $(this);
|
||||
|
||||
if ( $form.is('.processing') )
|
||||
if ( $form.is('.processing') )
|
||||
return false;
|
||||
|
||||
// Trigger a handler to let gateways manipulate the checkout if needed
|
||||
if ( $form.triggerHandler('checkout_place_order') !== false && $form.triggerHandler('checkout_place_order_' + $('#order_review input[name=payment_method]:checked').val() ) !== false ) {
|
||||
|
||||
|
||||
$form.addClass('processing');
|
||||
|
||||
var form_data = $form.data();
|
||||
|
||||
|
||||
if ( form_data["blockUI.isBlocked"] != 1 )
|
||||
$form.block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.ajax_loader_url + ') no-repeat center', opacity: 0.6}});
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: woocommerce_params.checkout_url,
|
||||
data: $form.serialize(),
|
||||
success: function( code ) {
|
||||
try {
|
||||
result = $.parseJSON( code );
|
||||
|
||||
result = $.parseJSON( code );
|
||||
|
||||
if (result.result=='success') {
|
||||
|
||||
|
||||
window.location = decodeURI(result.redirect);
|
||||
|
||||
|
||||
} else if (result.result=='failure') {
|
||||
|
||||
|
||||
$('.woocommerce_error, .woocommerce_message').remove();
|
||||
$form.prepend( result.messages );
|
||||
$form.removeClass('processing').unblock();
|
||||
|
||||
$form.removeClass('processing').unblock();
|
||||
$form.find( '.input-text, select' ).blur();
|
||||
|
||||
if (result.refresh=='true') $('body').trigger('update_checkout');
|
||||
|
||||
|
||||
$('html, body').animate({
|
||||
scrollTop: ($('form.checkout').offset().top - 100)
|
||||
}, 1000);
|
||||
|
||||
|
||||
} else {
|
||||
throw "Invalid response";
|
||||
}
|
||||
|
@ -230,8 +271,9 @@ jQuery(document).ready(function($) {
|
|||
catch(err) {
|
||||
$('.woocommerce_error, .woocommerce_message').remove();
|
||||
$form.prepend( code );
|
||||
$form.removeClass('processing').unblock();
|
||||
|
||||
$form.removeClass('processing').unblock();
|
||||
$form.find( '.input-text, select' ).blur();
|
||||
|
||||
$('html, body').animate({
|
||||
scrollTop: ($('form.checkout').offset().top - 100)
|
||||
}, 1000);
|
||||
|
@ -239,57 +281,57 @@ jQuery(document).ready(function($) {
|
|||
},
|
||||
dataType: "html"
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
/* Localisation */
|
||||
var locale_json = woocommerce_params.locale.replace(/"/g, '"');
|
||||
var locale = $.parseJSON( locale_json );
|
||||
var required = ' <abbr class="required" title="' + woocommerce_params.required_text + '">*</abbr>';
|
||||
var required = ' <abbr class="required" title="' + woocommerce_params.i18n_required_text + '">*</abbr>';
|
||||
|
||||
// Handle locale
|
||||
$('body').bind('country_to_state_changing', function( event, country, wrapper ){
|
||||
|
||||
|
||||
var thisform = wrapper;
|
||||
|
||||
|
||||
if ( locale[country] ) {
|
||||
var thislocale = locale[country];
|
||||
} else {
|
||||
var thislocale = locale['default'];
|
||||
}
|
||||
|
||||
|
||||
// Handle locale fields
|
||||
var locale_fields = {
|
||||
'address_1' : '#billing_address_1_field, #shipping_address_1_field',
|
||||
'address_2' : '#billing_address_2_field, #shipping_address_2_field',
|
||||
'state' : '#billing_state_field, #shipping_state_field',
|
||||
var locale_fields = {
|
||||
'address_1' : '#billing_address_1_field, #shipping_address_1_field',
|
||||
'address_2' : '#billing_address_2_field, #shipping_address_2_field',
|
||||
'state' : '#billing_state_field, #shipping_state_field',
|
||||
'postcode' : '#billing_postcode_field, #shipping_postcode_field',
|
||||
'city' : '#billing_city_field, #shipping_city_field'
|
||||
};
|
||||
|
||||
$.each( locale_fields, function( key, value ) {
|
||||
|
||||
};
|
||||
|
||||
$.each( locale_fields, function( key, value ) {
|
||||
|
||||
var field = thisform.find( value );
|
||||
|
||||
|
||||
if ( thislocale[key] ) {
|
||||
|
||||
|
||||
if ( thislocale[key]['label'] ) {
|
||||
field.find('label').html( thislocale[key]['label'] );
|
||||
}
|
||||
|
||||
|
||||
if ( thislocale[key]['placeholder'] ) {
|
||||
field.find('input').attr( 'placeholder', thislocale[key]['placeholder'] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
field.find('label abbr').remove();
|
||||
|
||||
if ( typeof thislocale[key]['required'] == 'undefined' || thislocale[key]['required'] == true ) {
|
||||
field.find('label').append( required );
|
||||
}
|
||||
|
||||
|
||||
if ( key !== 'state' ) {
|
||||
if ( thislocale[key]['hidden'] == true ) {
|
||||
field.fadeOut(200).find('input').val('');
|
||||
|
@ -297,7 +339,7 @@ jQuery(document).ready(function($) {
|
|||
field.fadeIn(500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else if ( locale['default'][key] ) {
|
||||
if ( locale['default'][key]['required'] == true ) {
|
||||
if (field.find('label abbr').size()==0) field.find('label').append( required );
|
||||
|
@ -306,12 +348,12 @@ jQuery(document).ready(function($) {
|
|||
field.fadeIn(500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
var postcodefield = thisform.find('#billing_postcode_field, #shipping_postcode_field');
|
||||
var cityfield = thisform.find('#billing_city_field, #shipping_city_field');
|
||||
|
||||
|
||||
// Re-order postcode/city
|
||||
if ( thislocale['postcode_before_city'] ) {
|
||||
if (cityfield.is('.form-row-first')) {
|
||||
|
@ -332,17 +374,17 @@ jQuery(document).ready(function($) {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
// Init trigger
|
||||
$('body').bind('init_checkout', function() {
|
||||
$('#billing_country, #shipping_country, .country_to_state').change();
|
||||
$('body').trigger('update_checkout');
|
||||
});
|
||||
|
||||
|
||||
// Update on page load
|
||||
if ( woocommerce_params.is_checkout == 1 )
|
||||
if ( woocommerce_params.is_checkout == 1 )
|
||||
$('body').trigger('init_checkout');
|
||||
|
||||
|
||||
});
|
|
@ -1,21 +1,21 @@
|
|||
jQuery(document).ready(function($) {
|
||||
|
||||
|
||||
// Tabs
|
||||
$('.woocommerce_tabs .panel').hide();
|
||||
|
||||
|
||||
$('.woocommerce_tabs ul.tabs li a').click(function(){
|
||||
|
||||
|
||||
var $tab = $(this);
|
||||
var $tabs_wrapper = $tab.closest('.woocommerce_tabs');
|
||||
|
||||
|
||||
$('ul.tabs li', $tabs_wrapper).removeClass('active');
|
||||
$('div.panel', $tabs_wrapper).hide();
|
||||
$('div' + $tab.attr('href')).show();
|
||||
$tab.parent().addClass('active');
|
||||
|
||||
return false;
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$('.woocommerce_tabs').each(function() {
|
||||
var hash = window.location.hash;
|
||||
if (hash.toLowerCase().indexOf("comment-") >= 0) {
|
||||
|
@ -24,10 +24,10 @@ jQuery(document).ready(function($) {
|
|||
$('ul.tabs li:first a', $(this)).click();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Star ratings for comments
|
||||
$('#rating').hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>');
|
||||
|
||||
|
||||
$('p.stars a').click(function(){
|
||||
var $star = $(this);
|
||||
$('#rating').val( $star.text() );
|
||||
|
@ -35,19 +35,19 @@ jQuery(document).ready(function($) {
|
|||
$star.addClass('active');
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$('#review_form #submit').live('click', function(){
|
||||
var rating = $('#rating').val();
|
||||
|
||||
|
||||
if ( $('#rating').size() > 0 && !rating && woocommerce_params.review_rating_required == 'yes' ) {
|
||||
alert(woocommerce_params.required_rating_text);
|
||||
alert(woocommerce_params.i18n_required_rating_text);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// prevent double form submission
|
||||
$('form.cart').submit(function(){
|
||||
$(this).find(':submit').attr( 'disabled','disabled' );
|
||||
});
|
||||
|
||||
|
||||
});
|
|
@ -1 +1 @@
|
|||
jQuery(document).ready(function(e){e(".woocommerce_tabs .panel").hide();e(".woocommerce_tabs ul.tabs li a").click(function(){var t=e(this),n=t.closest(".woocommerce_tabs");e("ul.tabs li",n).removeClass("active");e("div.panel",n).hide();e("div"+t.attr("href")).show();t.parent().addClass("active");return!1});e(".woocommerce_tabs").each(function(){var t=window.location.hash;t.toLowerCase().indexOf("comment-")>=0?e("ul.tabs li.reviews_tab a",e(this)).click():e("ul.tabs li:first a",e(this)).click()});e("#rating").hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>');e("p.stars a").click(function(){var t=e(this);e("#rating").val(t.text());e("p.stars a").removeClass("active");t.addClass("active");return!1});e("#review_form #submit").live("click",function(){var t=e("#rating").val();if(e("#rating").size()>0&&!t&&woocommerce_params.review_rating_required=="yes"){alert(woocommerce_params.required_rating_text);return!1}});e("form.cart").submit(function(){e(this).find(":submit").attr("disabled","disabled")})});
|
||||
jQuery(document).ready(function(e){e(".woocommerce_tabs .panel").hide();e(".woocommerce_tabs ul.tabs li a").click(function(){var t=e(this),n=t.closest(".woocommerce_tabs");e("ul.tabs li",n).removeClass("active");e("div.panel",n).hide();e("div"+t.attr("href")).show();t.parent().addClass("active");return!1});e(".woocommerce_tabs").each(function(){var t=window.location.hash;t.toLowerCase().indexOf("comment-")>=0?e("ul.tabs li.reviews_tab a",e(this)).click():e("ul.tabs li:first a",e(this)).click()});e("#rating").hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>');e("p.stars a").click(function(){var t=e(this);e("#rating").val(t.text());e("p.stars a").removeClass("active");t.addClass("active");return!1});e("#review_form #submit").live("click",function(){var t=e("#rating").val();if(e("#rating").size()>0&&!t&&woocommerce_params.review_rating_required=="yes"){alert(woocommerce_params.i18n_required_rating_text);return!1}});e("form.cart").submit(function(){e(this).find(":submit").attr("disabled","disabled")})});
|
|
@ -4,85 +4,87 @@ jQuery(document).ready(function($) {
|
|||
$('select.orderby').change(function(){
|
||||
$(this).closest('form').submit();
|
||||
});
|
||||
|
||||
|
||||
// Quantity buttons
|
||||
$("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass('buttons_added').append('<input type="button" value="+" class="plus" />').prepend('<input type="button" value="-" class="minus" />');
|
||||
|
||||
|
||||
// Target quantity inputs on product pages
|
||||
$("input.qty:not(.product-quantity input.qty)").each(function(){
|
||||
|
||||
var min = parseInt($(this).attr('data-min'));
|
||||
|
||||
if (min && min > 1 && parseInt($(this).val()) < min) {
|
||||
$(this).val(min);
|
||||
|
||||
var min = parseFloat( $(this).attr('min') );
|
||||
|
||||
if ( min && min > 0 && parseFloat( $(this).val() ) < min ) {
|
||||
$(this).val( min );
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
$(".plus").live('click', function() {
|
||||
var currentVal = parseInt($(this).prev(".qty").val());
|
||||
if (!currentVal || currentVal=="" || currentVal == "NaN") currentVal = 0;
|
||||
|
||||
$qty = $(this).prev(".qty");
|
||||
|
||||
var max = parseInt($qty.attr('data-max'));
|
||||
if (max=="" || max == "NaN") max = '';
|
||||
|
||||
if (max && (max==currentVal || currentVal>max)) {
|
||||
$qty.val(max);
|
||||
|
||||
$(".plus, .minus").live('click', function() {
|
||||
|
||||
// Get values
|
||||
var $qty = $(this).closest('.quantity').find(".qty");
|
||||
var currentVal = parseFloat( $qty.val() );
|
||||
var max = parseFloat( $qty.attr('max') );
|
||||
var min = parseFloat( $qty.attr('min') );
|
||||
var step = $qty.attr('step');
|
||||
|
||||
// Format values
|
||||
if ( ! currentVal || currentVal == "" || currentVal == "NaN" ) currentVal = 0;
|
||||
if ( max == "" || max == "NaN" ) max = '';
|
||||
if ( min == "" || min == "NaN" ) min = 0;
|
||||
if ( step == 'any' || step == "" || step == undefined || parseFloat( step ) == "NaN" ) step = 1;
|
||||
|
||||
// Change the value
|
||||
if ( $(this).is('.plus') ) {
|
||||
|
||||
if ( max && ( max == currentVal || currentVal > max ) ) {
|
||||
$qty.val( max );
|
||||
} else {
|
||||
$qty.val( currentVal + parseFloat( step ) );
|
||||
}
|
||||
|
||||
} else {
|
||||
$qty.val(currentVal + 1);
|
||||
|
||||
if ( min && ( min==currentVal || currentVal < min ) ) {
|
||||
$qty.val( min );
|
||||
} else if ( currentVal > 0 ) {
|
||||
$qty.val( currentVal - parseFloat( step ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$qty.trigger('change');
|
||||
});
|
||||
|
||||
$(".minus").live('click', function() {
|
||||
var currentVal = parseInt($(this).next(".qty").val());
|
||||
if (!currentVal || currentVal=="" || currentVal == "NaN") currentVal = 0;
|
||||
|
||||
$qty = $(this).next(".qty");
|
||||
|
||||
var min = parseInt($qty.attr('data-min'));
|
||||
if (min=="" || min == "NaN") min = 0;
|
||||
|
||||
if (min && (min==currentVal || currentVal<min)) {
|
||||
$qty.val(min);
|
||||
} else if (currentVal > 0) {
|
||||
$qty.val(currentVal - 1);
|
||||
}
|
||||
|
||||
|
||||
// Trigger change event
|
||||
$qty.trigger('change');
|
||||
});
|
||||
|
||||
/* State/Country select boxes */
|
||||
var states_json = woocommerce_params.countries.replace(/"/g, '"');
|
||||
var states = $.parseJSON( states_json );
|
||||
|
||||
var states = $.parseJSON( states_json );
|
||||
|
||||
$('select.country_to_state').change(function(){
|
||||
|
||||
|
||||
var country = $(this).val();
|
||||
|
||||
|
||||
var $statebox = $(this).closest('div').find('#billing_state, #shipping_state, #calc_shipping_state');
|
||||
var $parent = $statebox.parent();
|
||||
|
||||
var input_name = $statebox.attr('name');
|
||||
var input_id = $statebox.attr('id');
|
||||
var value = $statebox.val();
|
||||
|
||||
|
||||
if (states[country]) {
|
||||
if (states[country].length == 0) {
|
||||
|
||||
|
||||
// Empty array means state field is not used
|
||||
$parent.fadeOut(200, function() {
|
||||
$statebox.parent().find('.chzn-container').remove();
|
||||
$statebox.replaceWith('<input type="hidden" class="hidden" name="' + input_name + '" id="' + input_id + '" value="" />');
|
||||
|
||||
|
||||
$('body').trigger('country_to_state_changed', [country, $(this).closest('div')]);
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
$parent.fadeOut(200, function() {
|
||||
var options = '';
|
||||
var state = states[country];
|
||||
|
@ -94,40 +96,40 @@ jQuery(document).ready(function($) {
|
|||
$statebox.replaceWith('<select name="' + input_name + '" id="' + input_id + '" class="state_select"></select>');
|
||||
$statebox = $(this).closest('div').find('#billing_state, #shipping_state, #calc_shipping_state');
|
||||
}
|
||||
$statebox.html( '<option value="">' + woocommerce_params.select_state_text + '</option>' + options);
|
||||
|
||||
$statebox.html( '<option value="">' + woocommerce_params.i18n_select_state_text + '</option>' + options);
|
||||
|
||||
$statebox.val(value);
|
||||
|
||||
|
||||
$('body').trigger('country_to_state_changed', [country, $(this).closest('div')]);
|
||||
|
||||
|
||||
$parent.fadeIn(500);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
if ($statebox.is('select')) {
|
||||
|
||||
|
||||
$parent.fadeOut(200, function() {
|
||||
$parent.find('.chzn-container').remove();
|
||||
$statebox.replaceWith('<input type="text" class="input-text" name="' + input_name + '" id="' + input_id + '" />');
|
||||
|
||||
|
||||
$('body').trigger('country_to_state_changed', [country, $(this).closest('div')]);
|
||||
$parent.fadeIn(500);
|
||||
});
|
||||
|
||||
|
||||
} else if ($statebox.is('.hidden')) {
|
||||
|
||||
|
||||
$parent.find('.chzn-container').remove();
|
||||
$statebox.replaceWith('<input type="text" class="input-text" name="' + input_name + '" id="' + input_id + '" />');
|
||||
|
||||
|
||||
$('body').trigger('country_to_state_changed', [country, $(this).closest('div')]);
|
||||
$parent.delay(200).fadeIn(500);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$('body').delay(200).trigger('country_to_state_changing', [country, $(this).closest('div')]);
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
|
@ -1 +1 @@
|
|||
jQuery(document).ready(function(e){e("select.orderby").change(function(){e(this).closest("form").submit()});e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" class="plus" />').prepend('<input type="button" value="-" class="minus" />');e("input.qty:not(.product-quantity input.qty)").each(function(){var t=parseInt(e(this).attr("data-min"));t&&t>1&&parseInt(e(this).val())<t&&e(this).val(t)});e(".plus").live("click",function(){var t=parseInt(e(this).prev(".qty").val());if(!t||t==""||t=="NaN")t=0;$qty=e(this).prev(".qty");var n=parseInt($qty.attr("data-max"));if(n==""||n=="NaN")n="";n&&(n==t||t>n)?$qty.val(n):$qty.val(t+1);$qty.trigger("change")});e(".minus").live("click",function(){var t=parseInt(e(this).next(".qty").val());if(!t||t==""||t=="NaN")t=0;$qty=e(this).next(".qty");var n=parseInt($qty.attr("data-min"));if(n==""||n=="NaN")n=0;n&&(n==t||t<n)?$qty.val(n):t>0&&$qty.val(t-1);$qty.trigger("change")});var t=woocommerce_params.countries.replace(/"/g,'"'),n=e.parseJSON(t);e("select.country_to_state").change(function(){var t=e(this).val(),r=e(this).closest("div").find("#billing_state, #shipping_state, #calc_shipping_state"),i=r.parent(),s=r.attr("name"),o=r.attr("id"),u=r.val();if(n[t])n[t].length==0?i.fadeOut(200,function(){r.parent().find(".chzn-container").remove();r.replaceWith('<input type="hidden" class="hidden" name="'+s+'" id="'+o+'" value="" />');e("body").trigger("country_to_state_changed",[t,e(this).closest("div")])}):i.fadeOut(200,function(){var a="",f=n[t];for(var l in f)a=a+'<option value="'+l+'">'+f[l]+"</option>";if(r.is("input")){r.replaceWith('<select name="'+s+'" id="'+o+'" class="state_select"></select>');r=e(this).closest("div").find("#billing_state, #shipping_state, #calc_shipping_state")}r.html('<option value="">'+woocommerce_params.select_state_text+"</option>"+a);r.val(u);e("body").trigger("country_to_state_changed",[t,e(this).closest("div")]);i.fadeIn(500)});else if(r.is("select"))i.fadeOut(200,function(){i.find(".chzn-container").remove();r.replaceWith('<input type="text" class="input-text" name="'+s+'" id="'+o+'" />');e("body").trigger("country_to_state_changed",[t,e(this).closest("div")]);i.fadeIn(500)});else if(r.is(".hidden")){i.find(".chzn-container").remove();r.replaceWith('<input type="text" class="input-text" name="'+s+'" id="'+o+'" />');e("body").trigger("country_to_state_changed",[t,e(this).closest("div")]);i.delay(200).fadeIn(500)}e("body").delay(200).trigger("country_to_state_changing",[t,e(this).closest("div")])})});
|
||||
jQuery(document).ready(function(e){e("select.orderby").change(function(){e(this).closest("form").submit()});e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" class="plus" />').prepend('<input type="button" value="-" class="minus" />');e("input.qty:not(.product-quantity input.qty)").each(function(){var t=parseFloat(e(this).attr("min"));t&&t>0&&parseFloat(e(this).val())<t&&e(this).val(t)});e(".plus, .minus").live("click",function(){var t=e(this).closest(".quantity").find(".qty"),n=parseFloat(t.val()),r=parseFloat(t.attr("max")),i=parseFloat(t.attr("min")),s=t.attr("step");if(!n||n==""||n=="NaN")n=0;if(r==""||r=="NaN")r="";if(i==""||i=="NaN")i=0;if(s=="any"||s==""||s==undefined||parseFloat(s)=="NaN")s=1;e(this).is(".plus")?r&&(r==n||n>r)?t.val(r):t.val(n+parseFloat(s)):i&&(i==n||n<i)?t.val(i):n>0&&t.val(n-parseFloat(s));t.trigger("change")});var t=woocommerce_params.countries.replace(/"/g,'"'),n=e.parseJSON(t);e("select.country_to_state").change(function(){var t=e(this).val(),r=e(this).closest("div").find("#billing_state, #shipping_state, #calc_shipping_state"),i=r.parent(),s=r.attr("name"),o=r.attr("id"),u=r.val();if(n[t])n[t].length==0?i.fadeOut(200,function(){r.parent().find(".chzn-container").remove();r.replaceWith('<input type="hidden" class="hidden" name="'+s+'" id="'+o+'" value="" />');e("body").trigger("country_to_state_changed",[t,e(this).closest("div")])}):i.fadeOut(200,function(){var a="",f=n[t];for(var l in f)a=a+'<option value="'+l+'">'+f[l]+"</option>";if(r.is("input")){r.replaceWith('<select name="'+s+'" id="'+o+'" class="state_select"></select>');r=e(this).closest("div").find("#billing_state, #shipping_state, #calc_shipping_state")}r.html('<option value="">'+woocommerce_params.i18n_select_state_text+"</option>"+a);r.val(u);e("body").trigger("country_to_state_changed",[t,e(this).closest("div")]);i.fadeIn(500)});else if(r.is("select"))i.fadeOut(200,function(){i.find(".chzn-container").remove();r.replaceWith('<input type="text" class="input-text" name="'+s+'" id="'+o+'" />');e("body").trigger("country_to_state_changed",[t,e(this).closest("div")]);i.fadeIn(500)});else if(r.is(".hidden")){i.find(".chzn-container").remove();r.replaceWith('<input type="text" class="input-text" name="'+s+'" id="'+o+'" />');e("body").trigger("country_to_state_changed",[t,e(this).closest("div")]);i.delay(200).fadeIn(500)}e("body").delay(200).trigger("country_to_state_changing",[t,e(this).closest("div")])})});
|
|
@ -269,7 +269,7 @@
|
|||
s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:absolute">';
|
||||
if ( opts.title ) {
|
||||
s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || ' ')+'</div>';
|
||||
}
|
||||
}
|
||||
s += '<div class="ui-widget-content ui-dialog-content"></div>';
|
||||
s += '</div>';
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* browser tooltip. It is extremely lightweight and very smart in
|
||||
* that it detects the edges of the browser window and will make sure
|
||||
* the tooltip stays within the current window size. As a result the
|
||||
* tooltip will adjust itself to be displayed above, below, to the left
|
||||
* tooltip will adjust itself to be displayed above, below, to the left
|
||||
* or to the right depending on what is necessary to stay within the
|
||||
* browser window. It is completely customizable as well via CSS.
|
||||
*
|
||||
|
@ -21,7 +21,7 @@
|
|||
|
||||
(function($){
|
||||
$.fn.tipTip = function(options) {
|
||||
var defaults = {
|
||||
var defaults = {
|
||||
activation: "hover",
|
||||
keepAlive: false,
|
||||
maxWidth: "200px",
|
||||
|
@ -36,7 +36,7 @@
|
|||
exit: function(){}
|
||||
};
|
||||
var opts = $.extend(defaults, options);
|
||||
|
||||
|
||||
// Setup tip tip elements and render them to the DOM
|
||||
if($("#tiptip_holder").length <= 0){
|
||||
var tiptip_holder = $('<div id="tiptip_holder" style="max-width:'+ opts.maxWidth +';"></div>');
|
||||
|
@ -48,7 +48,7 @@
|
|||
var tiptip_content = $("#tiptip_content");
|
||||
var tiptip_arrow = $("#tiptip_arrow");
|
||||
}
|
||||
|
||||
|
||||
return this.each(function(){
|
||||
var org_elem = $(this);
|
||||
if(opts.content){
|
||||
|
@ -61,7 +61,7 @@
|
|||
org_elem.removeAttr(opts.attribute); //remove original Attribute
|
||||
}
|
||||
var timeout = false;
|
||||
|
||||
|
||||
if(opts.activation == "hover"){
|
||||
org_elem.hover(function(){
|
||||
active_tiptip();
|
||||
|
@ -96,13 +96,13 @@
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function active_tiptip(){
|
||||
opts.enter.call(this);
|
||||
tiptip_content.html(org_title);
|
||||
tiptip_holder.hide().removeAttr("class").css("margin","0");
|
||||
tiptip_arrow.removeAttr("style");
|
||||
|
||||
|
||||
var top = parseInt(org_elem.offset()['top']);
|
||||
var left = parseInt(org_elem.offset()['left']);
|
||||
var org_width = parseInt(org_elem.outerWidth());
|
||||
|
@ -119,17 +119,17 @@
|
|||
|
||||
if(opts.defaultPosition == "bottom"){
|
||||
t_class = "_bottom";
|
||||
} else if(opts.defaultPosition == "top"){
|
||||
} else if(opts.defaultPosition == "top"){
|
||||
t_class = "_top";
|
||||
} else if(opts.defaultPosition == "left"){
|
||||
t_class = "_left";
|
||||
} else if(opts.defaultPosition == "right"){
|
||||
t_class = "_right";
|
||||
}
|
||||
|
||||
|
||||
var right_compare = (w_compare + left) < parseInt($(window).scrollLeft());
|
||||
var left_compare = (tip_w + left) > parseInt($(window).width());
|
||||
|
||||
|
||||
if((right_compare && w_compare < 0) || (t_class == "_right" && !left_compare) || (t_class == "_left" && left < (tip_w + opts.edgeOffset + 5))){
|
||||
t_class = "_right";
|
||||
arrow_top = Math.round(tip_h - 13) / 2;
|
||||
|
@ -146,7 +146,7 @@
|
|||
|
||||
var top_compare = (top + org_height + opts.edgeOffset + tip_h + 8) > parseInt($(window).height() + $(window).scrollTop());
|
||||
var bottom_compare = ((top + org_height) - (opts.edgeOffset + tip_h + 8)) < 0;
|
||||
|
||||
|
||||
if(top_compare || (t_class == "_bottom" && top_compare) || (t_class == "_top" && !bottom_compare)){
|
||||
if(t_class == "_top" || t_class == "_bottom"){
|
||||
t_class = "_top";
|
||||
|
@ -161,31 +161,31 @@
|
|||
} else {
|
||||
t_class = t_class+"_bottom";
|
||||
}
|
||||
arrow_top = -12;
|
||||
arrow_top = -12;
|
||||
marg_top = Math.round(top + org_height + opts.edgeOffset);
|
||||
}
|
||||
|
||||
|
||||
if(t_class == "_right_top" || t_class == "_left_top"){
|
||||
marg_top = marg_top + 5;
|
||||
} else if(t_class == "_right_bottom" || t_class == "_left_bottom"){
|
||||
} else if(t_class == "_right_bottom" || t_class == "_left_bottom"){
|
||||
marg_top = marg_top - 5;
|
||||
}
|
||||
if(t_class == "_left_top" || t_class == "_left_bottom"){
|
||||
if(t_class == "_left_top" || t_class == "_left_bottom"){
|
||||
marg_left = marg_left + 5;
|
||||
}
|
||||
tiptip_arrow.css({"margin-left": arrow_left+"px", "margin-top": arrow_top+"px"});
|
||||
tiptip_holder.css({"margin-left": marg_left+"px", "margin-top": marg_top+"px"}).attr("class","tip"+t_class);
|
||||
|
||||
|
||||
if (timeout){ clearTimeout(timeout); }
|
||||
timeout = setTimeout(function(){ tiptip_holder.stop(true,true).fadeIn(opts.fadeIn); }, opts.delay);
|
||||
timeout = setTimeout(function(){ tiptip_holder.stop(true,true).fadeIn(opts.fadeIn); }, opts.delay);
|
||||
}
|
||||
|
||||
|
||||
function deactive_tiptip(){
|
||||
opts.exit.call(this);
|
||||
if (timeout){ clearTimeout(timeout); }
|
||||
tiptip_holder.fadeOut(opts.fadeOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})(jQuery);
|
||||
})(jQuery);
|
|
@ -10,7 +10,7 @@
|
|||
* browser tooltip. It is extremely lightweight and very smart in
|
||||
* that it detects the edges of the browser window and will make sure
|
||||
* the tooltip stays within the current window size. As a result the
|
||||
* tooltip will adjust itself to be displayed above, below, to the left
|
||||
* tooltip will adjust itself to be displayed above, below, to the left
|
||||
* or to the right depending on what is necessary to stay within the
|
||||
* browser window. It is completely customizable as well via CSS.
|
||||
*
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/*!
|
||||
* jQuery UI 1.8.16
|
||||
*/
|
||||
(function(c,j){function k(a,b){var d=a.nodeName.toLowerCase();if("area"===d){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&l(a)}return(/input|select|textarea|button|object/.test(d)?!a.disabled:"a"==d?a.href||b:b)&&l(a)}function l(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.16",
|
||||
keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({propAttr:c.fn.prop||c.fn.attr,_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=
|
||||
this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,
|
||||
"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":
|
||||
"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,m,n){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(m)g-=parseFloat(c.curCSS(f,"border"+this+"Width",true))||0;if(n)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,
|
||||
outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){return k(a,!isNaN(c.attr(a,"tabindex")))},tabbable:function(a){var b=c.attr(a,
|
||||
"tabindex"),d=isNaN(b);return(d||b>=0)&&k(a,!d)}});c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&
|
||||
a.element[0].parentNode)for(var e=0;e<b.length;e++)a.options[b[e][0]]&&b[e][1].apply(a.element,d)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")==="hidden")return false;b=b&&b==="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,h,i){return c.ui.isOverAxis(a,d,h)&&
|
||||
c.ui.isOverAxis(b,e,i)}})}})(jQuery);
|
||||
;
|
||||
|
||||
(function(b,j){if(b.cleanData){var k=b.cleanData;b.cleanData=function(a){for(var c=0,d;(d=a[c])!=null;c++)try{b(d).triggerHandler("remove")}catch(e){}k(a)}}else{var l=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add([this]).each(function(){try{b(this).triggerHandler("remove")}catch(d){}});return l.call(b(this),a,c)})}}b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=
|
||||
function(h){return!!b.data(h,a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend(true,{},c.options);b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):
|
||||
d;if(e&&d.charAt(0)==="_")return h;e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==j){h=i;return false}}):this.each(function(){var g=b.data(this,a);g?g.option(d||{})._init():b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){b.data(c,this.widgetName,this);this.element=b(c);this.options=
|
||||
b.extend(true,{},this.options,this._getCreateOptions(),a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+
|
||||
"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(a,c){var d=a;if(arguments.length===0)return b.extend({},this.options);if(typeof a==="string"){if(c===j)return this.options[a];d={};d[a]=c}this._setOptions(d);return this},_setOptions:function(a){var c=this;b.each(a,function(d,e){c._setOption(d,e)});return this},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",
|
||||
c);return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);
|
||||
;
|
||||
|
||||
(function(b){var d=false;b(document).mouseup(function(){d=false});b.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var a=this;this.element.bind("mousedown."+this.widgetName,function(c){return a._mouseDown(c)}).bind("click."+this.widgetName,function(c){if(true===b.data(c.target,a.widgetName+".preventClickEvent")){b.removeData(c.target,a.widgetName+".preventClickEvent");c.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+
|
||||
this.widgetName)},_mouseDown:function(a){if(!d){this._mouseStarted&&this._mouseUp(a);this._mouseDownEvent=a;var c=this,f=a.which==1,g=typeof this.options.cancel=="string"&&a.target.nodeName?b(a.target).closest(this.options.cancel).length:false;if(!f||g||!this._mouseCapture(a))return true;this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet)this._mouseDelayTimer=setTimeout(function(){c.mouseDelayMet=true},this.options.delay);if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a)){this._mouseStarted=
|
||||
this._mouseStart(a)!==false;if(!this._mouseStarted){a.preventDefault();return true}}true===b.data(a.target,this.widgetName+".preventClickEvent")&&b.removeData(a.target,this.widgetName+".preventClickEvent");this._mouseMoveDelegate=function(e){return c._mouseMove(e)};this._mouseUpDelegate=function(e){return c._mouseUp(e)};b(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);a.preventDefault();return d=true}},_mouseMove:function(a){if(b.browser.msie&&
|
||||
!(document.documentMode>=9)&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a);return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=
|
||||
false;a.target==this._mouseDownEvent.target&&b.data(a.target,this.widgetName+".preventClickEvent",true);this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
|
||||
;
|
||||
|
||||
(function(d){d.widget("ui.slider",d.ui.mouse,{widgetEventPrefix:"slide",options:{animate:false,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null},_create:function(){var a=this,b=this.options,c=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),f=b.values&&b.values.length||1,e=[];this._mouseSliding=this._keySliding=false;this._animateOff=true;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+
|
||||
this.orientation+" ui-widget ui-widget-content ui-corner-all"+(b.disabled?" ui-slider-disabled ui-disabled":""));this.range=d([]);if(b.range){if(b.range===true){if(!b.values)b.values=[this._valueMin(),this._valueMin()];if(b.values.length&&b.values.length!==2)b.values=[b.values[0],b.values[0]]}this.range=d("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(b.range==="min"||b.range==="max"?" ui-slider-range-"+b.range:""))}for(var j=c.length;j<f;j+=1)e.push("<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>");
|
||||
this.handles=c.add(d(e.join("")).appendTo(a.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(g){g.preventDefault()}).hover(function(){b.disabled||d(this).addClass("ui-state-hover")},function(){d(this).removeClass("ui-state-hover")}).focus(function(){if(b.disabled)d(this).blur();else{d(".ui-slider .ui-state-focus").removeClass("ui-state-focus");d(this).addClass("ui-state-focus")}}).blur(function(){d(this).removeClass("ui-state-focus")});this.handles.each(function(g){d(this).data("index.ui-slider-handle",
|
||||
g)});this.handles.keydown(function(g){var k=true,l=d(this).data("index.ui-slider-handle"),i,h,m;if(!a.options.disabled){switch(g.keyCode){case d.ui.keyCode.HOME:case d.ui.keyCode.END:case d.ui.keyCode.PAGE_UP:case d.ui.keyCode.PAGE_DOWN:case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:k=false;if(!a._keySliding){a._keySliding=true;d(this).addClass("ui-state-active");i=a._start(g,l);if(i===false)return}break}m=a.options.step;i=a.options.values&&a.options.values.length?
|
||||
(h=a.values(l)):(h=a.value());switch(g.keyCode){case d.ui.keyCode.HOME:h=a._valueMin();break;case d.ui.keyCode.END:h=a._valueMax();break;case d.ui.keyCode.PAGE_UP:h=a._trimAlignValue(i+(a._valueMax()-a._valueMin())/5);break;case d.ui.keyCode.PAGE_DOWN:h=a._trimAlignValue(i-(a._valueMax()-a._valueMin())/5);break;case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:if(i===a._valueMax())return;h=a._trimAlignValue(i+m);break;case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:if(i===a._valueMin())return;h=a._trimAlignValue(i-
|
||||
m);break}a._slide(g,l,h);return k}}).keyup(function(g){var k=d(this).data("index.ui-slider-handle");if(a._keySliding){a._keySliding=false;a._stop(g,k);a._change(g,k);d(this).removeClass("ui-state-active")}});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();
|
||||
return this},_mouseCapture:function(a){var b=this.options,c,f,e,j,g;if(b.disabled)return false;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();c=this._normValueFromMouse({x:a.pageX,y:a.pageY});f=this._valueMax()-this._valueMin()+1;j=this;this.handles.each(function(k){var l=Math.abs(c-j.values(k));if(f>l){f=l;e=d(this);g=k}});if(b.range===true&&this.values(1)===b.min){g+=1;e=d(this.handles[g])}if(this._start(a,g)===false)return false;
|
||||
this._mouseSliding=true;j._handleIndex=g;e.addClass("ui-state-active").focus();b=e.offset();this._clickOffset=!d(a.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:a.pageX-b.left-e.width()/2,top:a.pageY-b.top-e.height()/2-(parseInt(e.css("borderTopWidth"),10)||0)-(parseInt(e.css("borderBottomWidth"),10)||0)+(parseInt(e.css("marginTop"),10)||0)};this.handles.hasClass("ui-state-hover")||this._slide(a,g,c);return this._animateOff=true},_mouseStart:function(){return true},_mouseDrag:function(a){var b=
|
||||
this._normValueFromMouse({x:a.pageX,y:a.pageY});this._slide(a,this._handleIndex,b);return false},_mouseStop:function(a){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(a,this._handleIndex);this._change(a,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=false},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(a){var b;if(this.orientation==="horizontal"){b=
|
||||
this.elementSize.width;a=a.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{b=this.elementSize.height;a=a.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}b=a/b;if(b>1)b=1;if(b<0)b=0;if(this.orientation==="vertical")b=1-b;a=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+b*a)},_start:function(a,b){var c={handle:this.handles[b],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(b);
|
||||
c.values=this.values()}return this._trigger("start",a,c)},_slide:function(a,b,c){var f;if(this.options.values&&this.options.values.length){f=this.values(b?0:1);if(this.options.values.length===2&&this.options.range===true&&(b===0&&c>f||b===1&&c<f))c=f;if(c!==this.values(b)){f=this.values();f[b]=c;a=this._trigger("slide",a,{handle:this.handles[b],value:c,values:f});this.values(b?0:1);a!==false&&this.values(b,c,true)}}else if(c!==this.value()){a=this._trigger("slide",a,{handle:this.handles[b],value:c});
|
||||
a!==false&&this.value(c)}},_stop:function(a,b){var c={handle:this.handles[b],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(b);c.values=this.values()}this._trigger("stop",a,c)},_change:function(a,b){if(!this._keySliding&&!this._mouseSliding){var c={handle:this.handles[b],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(b);c.values=this.values()}this._trigger("change",a,c)}},value:function(a){if(arguments.length){this.options.value=
|
||||
this._trimAlignValue(a);this._refreshValue();this._change(null,0)}else return this._value()},values:function(a,b){var c,f,e;if(arguments.length>1){this.options.values[a]=this._trimAlignValue(b);this._refreshValue();this._change(null,a)}else if(arguments.length)if(d.isArray(arguments[0])){c=this.options.values;f=arguments[0];for(e=0;e<c.length;e+=1){c[e]=this._trimAlignValue(f[e]);this._change(null,e)}this._refreshValue()}else return this.options.values&&this.options.values.length?this._values(a):
|
||||
this.value();else return this._values()},_setOption:function(a,b){var c,f=0;if(d.isArray(this.options.values))f=this.options.values.length;d.Widget.prototype._setOption.apply(this,arguments);switch(a){case "disabled":if(b){this.handles.filter(".ui-state-focus").blur();this.handles.removeClass("ui-state-hover");this.handles.propAttr("disabled",true);this.element.addClass("ui-disabled")}else{this.handles.propAttr("disabled",false);this.element.removeClass("ui-disabled")}break;case "orientation":this._detectOrientation();
|
||||
this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue();break;case "value":this._animateOff=true;this._refreshValue();this._change(null,0);this._animateOff=false;break;case "values":this._animateOff=true;this._refreshValue();for(c=0;c<f;c+=1)this._change(null,c);this._animateOff=false;break}},_value:function(){var a=this.options.value;return a=this._trimAlignValue(a)},_values:function(a){var b,c;if(arguments.length){b=this.options.values[a];
|
||||
return b=this._trimAlignValue(b)}else{b=this.options.values.slice();for(c=0;c<b.length;c+=1)b[c]=this._trimAlignValue(b[c]);return b}},_trimAlignValue:function(a){if(a<=this._valueMin())return this._valueMin();if(a>=this._valueMax())return this._valueMax();var b=this.options.step>0?this.options.step:1,c=(a-this._valueMin())%b;a=a-c;if(Math.abs(c)*2>=b)a+=c>0?b:-b;return parseFloat(a.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var a=
|
||||
this.options.range,b=this.options,c=this,f=!this._animateOff?b.animate:false,e,j={},g,k,l,i;if(this.options.values&&this.options.values.length)this.handles.each(function(h){e=(c.values(h)-c._valueMin())/(c._valueMax()-c._valueMin())*100;j[c.orientation==="horizontal"?"left":"bottom"]=e+"%";d(this).stop(1,1)[f?"animate":"css"](j,b.animate);if(c.options.range===true)if(c.orientation==="horizontal"){if(h===0)c.range.stop(1,1)[f?"animate":"css"]({left:e+"%"},b.animate);if(h===1)c.range[f?"animate":"css"]({width:e-
|
||||
g+"%"},{queue:false,duration:b.animate})}else{if(h===0)c.range.stop(1,1)[f?"animate":"css"]({bottom:e+"%"},b.animate);if(h===1)c.range[f?"animate":"css"]({height:e-g+"%"},{queue:false,duration:b.animate})}g=e});else{k=this.value();l=this._valueMin();i=this._valueMax();e=i!==l?(k-l)/(i-l)*100:0;j[c.orientation==="horizontal"?"left":"bottom"]=e+"%";this.handle.stop(1,1)[f?"animate":"css"](j,b.animate);if(a==="min"&&this.orientation==="horizontal")this.range.stop(1,1)[f?"animate":"css"]({width:e+"%"},
|
||||
b.animate);if(a==="max"&&this.orientation==="horizontal")this.range[f?"animate":"css"]({width:100-e+"%"},{queue:false,duration:b.animate});if(a==="min"&&this.orientation==="vertical")this.range.stop(1,1)[f?"animate":"css"]({height:e+"%"},b.animate);if(a==="max"&&this.orientation==="vertical")this.range[f?"animate":"css"]({height:100-e+"%"},{queue:false,duration:b.animate})}}});d.extend(d.ui.slider,{version:"1.8.16"})})(jQuery);
|
|
@ -3,7 +3,7 @@
|
|||
* Handle data for the current customers session.
|
||||
*
|
||||
* @class WC_Session
|
||||
* @version 1.7
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/Classes/Abstracts
|
||||
* @author WooThemes
|
||||
*/
|
||||
|
@ -13,7 +13,7 @@ abstract class WC_Session {
|
|||
|
||||
/**
|
||||
* save_data function to be implemented
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -29,10 +29,10 @@ abstract class WC_Session {
|
|||
// When leaving or ending page load, store data
|
||||
add_action( 'shutdown', array( &$this, 'save_data' ), 20 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* __get function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $property
|
||||
* @return mixed
|
||||
|
@ -40,10 +40,10 @@ abstract class WC_Session {
|
|||
public function __get( $property ) {
|
||||
return isset( $this->_data[ $property ] ) ? $this->_data[ $property ] : null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* __set function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $property
|
||||
* @param mixed $value
|
||||
|
@ -52,10 +52,10 @@ abstract class WC_Session {
|
|||
public function __set( $property, $value ) {
|
||||
$this->_data[ $property ] = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* __isset function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $property
|
||||
* @return bool
|
||||
|
@ -63,10 +63,10 @@ abstract class WC_Session {
|
|||
public function __isset( $property ) {
|
||||
return isset( $this->_data[ $property ] );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* __unset function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $property
|
||||
* @return void
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* The cart class also has a price calculation function which calls upon other classes to calculate totals.
|
||||
*
|
||||
* @class WC_Cart
|
||||
* @version 1.6.4
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/Classes
|
||||
* @author WooThemes
|
||||
*/
|
||||
|
@ -15,9 +15,12 @@ class WC_Cart {
|
|||
/** @var array Contains an array of cart items. */
|
||||
var $cart_contents;
|
||||
|
||||
/** @var array Contains an array of coupons applied to the cart. */
|
||||
/** @var array Contains an array of coupon codes applied to the cart. */
|
||||
var $applied_coupons;
|
||||
|
||||
/** @var array Contains an array of coupon code discounts after they have been applied. */
|
||||
var $coupon_discount_amounts;
|
||||
|
||||
/** @var float The total cost of the cart items. */
|
||||
var $cart_contents_total;
|
||||
|
||||
|
@ -53,7 +56,7 @@ class WC_Cart {
|
|||
|
||||
/** @var float Discounts after tax. */
|
||||
var $discount_total;
|
||||
|
||||
|
||||
/** @var float Total for additonal fees. */
|
||||
var $fee_total;
|
||||
|
||||
|
@ -68,7 +71,7 @@ class WC_Cart {
|
|||
|
||||
/** @var WC_Tax */
|
||||
var $tax;
|
||||
|
||||
|
||||
/** @var array An array of fees. */
|
||||
var $fees;
|
||||
|
||||
|
@ -80,10 +83,13 @@ class WC_Cart {
|
|||
*/
|
||||
function __construct() {
|
||||
$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;
|
||||
$this->dp = ( '' != get_option( 'woocommerce_price_num_decimals' ) ) ? get_option( 'woocommerce_price_num_decimals' ) : 0;
|
||||
$this->prices_include_tax = ( get_option( 'woocommerce_prices_include_tax' ) == 'yes' ) ? true : false;
|
||||
$this->tax_display_cart = get_option( 'woocommerce_tax_display_cart' );
|
||||
$this->dp = (int) get_option( 'woocommerce_price_num_decimals' );
|
||||
|
||||
$this->display_totals_ex_tax = $this->tax_display_cart == 'excl' ? true : false;
|
||||
$this->display_cart_ex_tax = $this->tax_display_cart == 'excl' ? true : false;
|
||||
|
||||
add_action( 'init', array( &$this, 'init' ), 5 ); // Get cart on init
|
||||
}
|
||||
|
||||
|
@ -116,8 +122,10 @@ class WC_Cart {
|
|||
global $woocommerce;
|
||||
|
||||
// Load the coupons
|
||||
if ( get_option( 'woocommerce_enable_coupons' ) == 'yes' )
|
||||
$this->applied_coupons = ( empty( $woocommerce->session->coupons ) ) ? array() : array_unique( array_filter( (array) $woocommerce->session->coupons ) );
|
||||
if ( get_option( 'woocommerce_enable_coupons' ) == 'yes' ) {
|
||||
$this->applied_coupons = ( empty( $woocommerce->session->coupon_codes ) ) ? array() : array_filter( (array) $woocommerce->session->coupon_codes );
|
||||
$this->coupon_discount_amounts = ( empty( $woocommerce->session->coupon_amounts ) ) ? array() : array_filter( (array) $woocommerce->session->coupon_amounts );
|
||||
}
|
||||
|
||||
// Load the cart
|
||||
if ( isset( $woocommerce->session->cart ) && is_array( $woocommerce->session->cart ) ) {
|
||||
|
@ -125,10 +133,7 @@ class WC_Cart {
|
|||
|
||||
foreach ( $cart as $key => $values ) {
|
||||
|
||||
if ( $values['variation_id'] > 0 )
|
||||
$_product = new WC_Product_Variation( $values['variation_id'] );
|
||||
else
|
||||
$_product = new WC_Product( $values['product_id'] );
|
||||
$_product = get_product( $values['variation_id'] ? $values['variation_id'] : $values['product_id'] );
|
||||
|
||||
if ( $_product->exists() && $values['quantity'] > 0 ) {
|
||||
|
||||
|
@ -205,25 +210,26 @@ class WC_Cart {
|
|||
}
|
||||
}
|
||||
|
||||
$woocommerce->session->cart = $cart_session;
|
||||
$woocommerce->session->coupons = $this->applied_coupons;
|
||||
$woocommerce->session->cart = $cart_session;
|
||||
$woocommerce->session->coupon_codes = $this->applied_coupons;
|
||||
$woocommerce->session->coupon_amounts = $this->coupon_discount_amounts;
|
||||
|
||||
// Store totals to avoid re-calc on page load
|
||||
$woocommerce->session->cart_contents_total = $this->cart_contents_total;
|
||||
$woocommerce->session->cart_contents_total = $this->cart_contents_total;
|
||||
$woocommerce->session->cart_contents_weight = $this->cart_contents_weight;
|
||||
$woocommerce->session->cart_contents_count = $this->cart_contents_count;
|
||||
$woocommerce->session->cart_contents_tax = $this->cart_contents_tax;
|
||||
$woocommerce->session->total = $this->total;
|
||||
$woocommerce->session->subtotal = $this->subtotal;
|
||||
$woocommerce->session->subtotal_ex_tax = $this->subtotal_ex_tax;
|
||||
$woocommerce->session->tax_total = $this->tax_total;
|
||||
$woocommerce->session->shipping_taxes = $this->shipping_taxes;
|
||||
$woocommerce->session->taxes = $this->taxes;
|
||||
$woocommerce->session->discount_cart = $this->discount_cart;
|
||||
$woocommerce->session->discount_total = $this->discount_total;
|
||||
$woocommerce->session->shipping_total = $this->shipping_total;
|
||||
$woocommerce->session->shipping_tax_total = $this->shipping_tax_total;
|
||||
$woocommerce->session->shipping_label = $this->shipping_label;
|
||||
$woocommerce->session->cart_contents_count = $this->cart_contents_count;
|
||||
$woocommerce->session->cart_contents_tax = $this->cart_contents_tax;
|
||||
$woocommerce->session->total = $this->total;
|
||||
$woocommerce->session->subtotal = $this->subtotal;
|
||||
$woocommerce->session->subtotal_ex_tax = $this->subtotal_ex_tax;
|
||||
$woocommerce->session->tax_total = $this->tax_total;
|
||||
$woocommerce->session->shipping_taxes = $this->shipping_taxes;
|
||||
$woocommerce->session->taxes = $this->taxes;
|
||||
$woocommerce->session->discount_cart = $this->discount_cart;
|
||||
$woocommerce->session->discount_total = $this->discount_total;
|
||||
$woocommerce->session->shipping_total = $this->shipping_total;
|
||||
$woocommerce->session->shipping_tax_total = $this->shipping_tax_total;
|
||||
$woocommerce->session->shipping_label = $this->shipping_label;
|
||||
|
||||
if ( get_current_user_id() )
|
||||
$this->persistent_cart_update();
|
||||
|
@ -243,8 +249,8 @@ class WC_Cart {
|
|||
|
||||
$this->cart_contents = array();
|
||||
$this->reset();
|
||||
|
||||
unset( $woocommerce->session->order_awaiting_payment, $woocommerce->session->coupons, $woocommerce->session->cart );
|
||||
|
||||
unset( $woocommerce->session->order_awaiting_payment, $woocommerce->session->coupon_codes, $woocommerce->session->coupon_amounts, $woocommerce->session->cart );
|
||||
|
||||
if ( $clear_persistent_cart && get_current_user_id() )
|
||||
$this->persistent_cart_destroy();
|
||||
|
@ -332,8 +338,9 @@ class WC_Cart {
|
|||
|
||||
// Remove the coupon
|
||||
unset( $this->applied_coupons[ $key ] );
|
||||
$woocommerce->session->coupons = $this->applied_coupons;
|
||||
$woocommerce->session->refresh_totals = true;
|
||||
|
||||
$woocommerce->session->coupon_codes = $this->applied_coupons;
|
||||
$woocommerce->session->refresh_totals = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -407,8 +414,9 @@ class WC_Cart {
|
|||
$woocommerce->add_error( sprintf( __( 'Sorry, it seems the coupon "%s" is not yours - it has now been removed from your order.', 'woocommerce' ), $code ) );
|
||||
// Remove the coupon
|
||||
unset( $this->applied_coupons[ $key ] );
|
||||
$woocommerce->session->coupons = $this->applied_coupons;
|
||||
$woocommerce->session->refresh_totals = true;
|
||||
|
||||
$woocommerce->session->coupon_codes = $this->applied_coupons;
|
||||
$woocommerce->session->refresh_totals = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -494,7 +502,7 @@ class WC_Cart {
|
|||
if ( ! $flat ) $return .= '<dl class="variation">';
|
||||
|
||||
// Variation data
|
||||
if ( $cart_item['data'] instanceof WC_Product_Variation && is_array( $cart_item['variation'] ) ) {
|
||||
if ( ! empty( $cart_item['data']->variation_id ) && is_array( $cart_item['variation'] ) ) {
|
||||
|
||||
$variation_list = array();
|
||||
|
||||
|
@ -727,7 +735,7 @@ class WC_Cart {
|
|||
function add_to_cart( $product_id, $quantity = 1, $variation_id = '', $variation = '', $cart_item_data = array() ) {
|
||||
global $woocommerce;
|
||||
|
||||
if ( $quantity < 1 ) return false;
|
||||
if ( $quantity <= 0 ) return false;
|
||||
|
||||
// Load cart item data - may be added by other plugins
|
||||
$cart_item_data = (array) apply_filters( 'woocommerce_add_cart_item_data', $cart_item_data, $product_id, $variation_id );
|
||||
|
@ -738,10 +746,7 @@ class WC_Cart {
|
|||
// See if this product and its options is already in the cart
|
||||
$cart_item_key = $this->find_product_in_cart( $cart_id );
|
||||
|
||||
if ( $variation_id > 0 )
|
||||
$product_data = new WC_Product_Variation( $variation_id );
|
||||
else
|
||||
$product_data = new WC_Product( $product_id );
|
||||
$product_data = get_product( $variation_id ? $variation_id : $product_id );
|
||||
|
||||
// Force quantity to 1 if sold individually
|
||||
if ( $product_data->is_sold_individually() )
|
||||
|
@ -755,24 +760,24 @@ class WC_Cart {
|
|||
|
||||
// Stock check - only check if we're managing stock and backorders are not allowed
|
||||
if ( ! $product_data->is_in_stock() ) {
|
||||
|
||||
|
||||
$woocommerce->add_error( sprintf( __( 'You cannot add "%s" to the cart because the product is out of stock.', 'woocommerce' ), $product_data->get_title() ) );
|
||||
|
||||
|
||||
return false;
|
||||
} elseif ( ! $product_data->has_enough_stock( $quantity ) ) {
|
||||
|
||||
|
||||
$woocommerce->add_error( sprintf(__( 'You cannot add that amount of "%s" to the cart because there is not enough stock (%s remaining).', 'woocommerce' ), $product_data->get_title(), $product_data->get_stock_quantity() ));
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Downloadable/virtual qty check
|
||||
if ( $product_data->is_sold_individually() ) {
|
||||
$in_cart_quantity = ( $cart_item_key ) ? $this->cart_contents[$cart_item_key]['quantity'] + $quantity : $quantity;
|
||||
$in_cart_quantity = $cart_item_key ? $this->cart_contents[$cart_item_key]['quantity'] : 0;
|
||||
|
||||
// If its greater than 1, its already in the cart
|
||||
if ( $in_cart_quantity > 1 ) {
|
||||
// If its greater than 0, its already in the cart
|
||||
if ( $in_cart_quantity > 0 ) {
|
||||
$woocommerce->add_error( sprintf('<a href="%s" class="button">%s</a> %s', get_permalink(woocommerce_get_page_id('cart')), __( 'View Cart →', 'woocommerce' ), __( 'You already have this item in your cart.', 'woocommerce' ) ) );
|
||||
return false;
|
||||
}
|
||||
|
@ -948,13 +953,17 @@ class WC_Cart {
|
|||
|
||||
if ( $add_totals ) {
|
||||
$this->discount_cart = $this->discount_cart + ( $discount_amount * $values['quantity'] );
|
||||
$this->coupon_discount_amounts[ $code ] = ( $discount_amount * $values['quantity'] );
|
||||
}
|
||||
|
||||
} elseif ( $coupon->type == 'percent_product' ) {
|
||||
|
||||
$percent_discount = ( $values['data']->get_price_excluding_tax() / 100 ) * $coupon->amount;
|
||||
|
||||
if ( $add_totals ) $this->discount_cart = $this->discount_cart + ( $percent_discount * $values['quantity'] );
|
||||
if ( $add_totals ) {
|
||||
$this->discount_cart = $this->discount_cart + ( $percent_discount * $values['quantity'] );
|
||||
$this->coupon_discount_amounts[ $code ] = ( $percent_discount * $values['quantity'] );
|
||||
}
|
||||
|
||||
$price = $price - $percent_discount;
|
||||
|
||||
|
@ -1005,7 +1014,10 @@ class WC_Cart {
|
|||
if ( $price < 0 ) $price = 0;
|
||||
|
||||
// Add coupon to discount total (once, since this is a fixed cart discount and we don't want rounding issues)
|
||||
if ( $add_totals ) $this->discount_cart = $this->discount_cart + ( ( $discount_amount * $values['quantity'] ) / 100 );
|
||||
if ( $add_totals ) {
|
||||
$this->discount_cart = $this->discount_cart + ( ( $discount_amount * $values['quantity'] ) / 100 );
|
||||
$this->coupon_discount_amounts[ $code ] = ( ( $discount_amount * $values['quantity'] ) / 100 );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
@ -1013,8 +1025,10 @@ class WC_Cart {
|
|||
|
||||
$percent_discount = round( ( $values['data']->get_price() / 100 ) * $coupon->amount, $this->dp );
|
||||
|
||||
if ( $add_totals )
|
||||
if ( $add_totals ) {
|
||||
$this->discount_cart = $this->discount_cart + ( $percent_discount * $values['quantity'] );
|
||||
$this->coupon_discount_amounts[ $code ] = ( $percent_discount * $values['quantity'] );
|
||||
}
|
||||
|
||||
$price = $price - $percent_discount;
|
||||
|
||||
|
@ -1094,8 +1108,11 @@ class WC_Cart {
|
|||
|
||||
$this->discount_total = $this->discount_total + ( $discount_amount * $values['quantity'] );
|
||||
|
||||
$this->coupon_discount_amounts[ $code ] = ( $discount_amount * $values['quantity'] );
|
||||
|
||||
} elseif ( $coupon->type == 'percent_product' ) {
|
||||
$this->discount_total = $this->discount_total + round( ( $price / 100 ) * $coupon->amount, $this->dp );
|
||||
$this->coupon_discount_amounts[ $code ] = round( ( $price / 100 ) * $coupon->amount, $this->dp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1125,6 +1142,8 @@ class WC_Cart {
|
|||
|
||||
$this->discount_total = $this->discount_total + $coupon->amount;
|
||||
|
||||
$this->coupon_discount_amounts[ $code ] = $coupon->amount;
|
||||
|
||||
break;
|
||||
|
||||
case "percent" :
|
||||
|
@ -1133,6 +1152,8 @@ class WC_Cart {
|
|||
|
||||
$this->discount_total = $this->discount_total + round( $percent_discount, $this->dp );
|
||||
|
||||
$this->coupon_discount_amounts[ $code ] = round( $percent_discount, $this->dp );
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -1386,19 +1407,19 @@ class WC_Cart {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add fees
|
||||
foreach ( $this->get_fees() as $fee ) {
|
||||
$this->fee_total += $fee->amount;
|
||||
|
||||
|
||||
if ( $fee->taxable ) {
|
||||
// Get tax rates
|
||||
$tax_rates = $this->tax->get_rates();
|
||||
$fee_taxes = $this->tax->calc_tax( $fee->amount, $tax_rates, false );
|
||||
|
||||
|
||||
// Store
|
||||
$fee->tax = array_sum( $fee_taxes );
|
||||
|
||||
|
||||
// Tax rows - merge the totals we just got
|
||||
foreach ( array_keys( $this->taxes + $fee_taxes ) as $key ) {
|
||||
$this->taxes[ $key ] = ( isset( $fee_taxes[ $key ] ) ? $fee_taxes[ $key ] : 0 ) + ( isset( $this->taxes[ $key ] ) ? $this->taxes[ $key ] : 0 );
|
||||
|
@ -1413,7 +1434,7 @@ class WC_Cart {
|
|||
if ( $woocommerce->customer->is_vat_exempt() ) {
|
||||
$this->shipping_tax_total = $this->tax_total = 0;
|
||||
$this->taxes = $this->shipping_taxes = array();
|
||||
|
||||
|
||||
foreach ( $this->cart_contents as $cart_item_key => $item )
|
||||
$this->cart_contents[ $cart_item_key ]['line_subtotal_tax'] = $this->cart_contents[ $cart_item_key ]['line_tax'] = 0;
|
||||
}
|
||||
|
@ -1446,8 +1467,8 @@ class WC_Cart {
|
|||
* Based on discounted product prices, discounted tax, shipping cost + tax, and any discounts to be added after tax (e.g. store credit)
|
||||
*/
|
||||
$this->total = apply_filters( 'woocommerce_calculated_total', number_format( $this->cart_contents_total + $this->tax_total + $this->shipping_tax_total + $this->shipping_total - $this->discount_total + $this->fee_total, $this->dp, '.', '' ), $this );
|
||||
|
||||
if ( $this->total < 0 )
|
||||
|
||||
if ( $this->total < 0 )
|
||||
$this->total = 0;
|
||||
}
|
||||
|
||||
|
@ -1586,21 +1607,25 @@ class WC_Cart {
|
|||
if ( isset( $this->shipping_label ) ) {
|
||||
if ( $this->shipping_total > 0 ) {
|
||||
|
||||
// Display ex tax if the option is set, or prices exclude tax
|
||||
if ( $this->display_totals_ex_tax || !$this->prices_include_tax ) {
|
||||
// Display varies depending on settings
|
||||
if ( $this->tax_display_cart == 'excl' ) {
|
||||
|
||||
$return = woocommerce_price( $this->shipping_total );
|
||||
|
||||
if ( $this->shipping_tax_total > 0 && $this->prices_include_tax ) {
|
||||
$return .= ' <small>' . $woocommerce->countries->ex_tax_or_vat() . '</small>';
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
} else {
|
||||
|
||||
$return = woocommerce_price( $this->shipping_total + $this->shipping_tax_total );
|
||||
|
||||
if ( $this->shipping_tax_total > 0 && ! $this->prices_include_tax ) {
|
||||
$return .= ' <small>' . $woocommerce->countries->inc_tax_or_vat() . '</small>';
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
@ -1679,7 +1704,7 @@ class WC_Cart {
|
|||
}
|
||||
|
||||
$this->applied_coupons[] = $coupon_code;
|
||||
|
||||
|
||||
// Choose free shipping
|
||||
if ( $the_coupon->enable_free_shipping() ) {
|
||||
$woocommerce->session->chosen_shipping_method = 'free_shipping';
|
||||
|
@ -1725,7 +1750,7 @@ class WC_Cart {
|
|||
}
|
||||
}
|
||||
|
||||
$woocommerce->session->coupons = $this->applied_coupons;
|
||||
$woocommerce->session->coupon_codes = $this->applied_coupons;
|
||||
} elseif ( $type == 2 ) {
|
||||
if ( $this->applied_coupons ) {
|
||||
foreach ( $this->applied_coupons as $index => $code ) {
|
||||
|
@ -1734,9 +1759,9 @@ class WC_Cart {
|
|||
}
|
||||
}
|
||||
|
||||
$woocommerce->session->coupons = $this->applied_coupons;
|
||||
$woocommerce->session->coupon_codes = $this->applied_coupons;
|
||||
} else {
|
||||
unset( $woocommerce->session->coupons );
|
||||
unset( $woocommerce->session->coupon_codes, $woocommerce->session->coupon_amounts );
|
||||
$this->applied_coupons = array();
|
||||
}
|
||||
}
|
||||
|
@ -1747,7 +1772,7 @@ class WC_Cart {
|
|||
|
||||
/**
|
||||
* add_fee function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $name
|
||||
* @param mixed $amount
|
||||
|
@ -1756,10 +1781,10 @@ class WC_Cart {
|
|||
* @return void
|
||||
*/
|
||||
function add_fee( $name, $amount, $taxable = false, $tax_class = '' ) {
|
||||
|
||||
if ( empty( $this->fees ) )
|
||||
|
||||
if ( empty( $this->fees ) )
|
||||
$this->fees = array();
|
||||
|
||||
|
||||
$new_fee = new stdClass();
|
||||
$new_fee->id = sanitize_title( $name );
|
||||
$new_fee->name = esc_attr( $name );
|
||||
|
@ -1767,13 +1792,13 @@ class WC_Cart {
|
|||
$new_fee->tax_class = $tax_class;
|
||||
$new_fee->taxable = $taxable ? true : false;
|
||||
$new_fee->tax = 0;
|
||||
|
||||
|
||||
$this->fees[] = $new_fee;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get_fees function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -1856,8 +1881,8 @@ class WC_Cart {
|
|||
// Otherwise we show cart items totals only (before discount)
|
||||
} else {
|
||||
|
||||
// Display ex tax if the option is set, or prices exclude tax
|
||||
if ( $this->display_totals_ex_tax || ! $this->prices_include_tax || $woocommerce->customer->is_vat_exempt() ) {
|
||||
// Display varies depending on settings
|
||||
if ( $this->tax_display_cart == 'excl' ) {
|
||||
|
||||
$cart_subtotal = woocommerce_price( $this->subtotal_ex_tax );
|
||||
|
||||
|
@ -1872,6 +1897,7 @@ class WC_Cart {
|
|||
if ( $this->tax_total > 0 && !$this->prices_include_tax ) {
|
||||
$cart_subtotal .= ' <small>' . $woocommerce->countries->inc_tax_or_vat() . '</small>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1900,44 +1926,33 @@ class WC_Cart {
|
|||
// Taxable
|
||||
if ( $taxable ) {
|
||||
|
||||
if ( ( $this->display_cart_ex_tax || $woocommerce->customer->is_vat_exempt() ) && $this->prices_include_tax ) {
|
||||
|
||||
$base_taxes = $this->tax->calc_tax( $price * $quantity, $base_tax_rates, true );
|
||||
$base_tax_amount = array_sum( $base_taxes );
|
||||
|
||||
$row_price = ( $price * $quantity ) - $base_tax_amount;
|
||||
if ( $this->tax_display_cart == 'excl' ) {
|
||||
|
||||
$row_price = $_product->get_price_excluding_tax( $quantity );
|
||||
$product_subtotal = woocommerce_price( $row_price );
|
||||
$product_subtotal .= ' <small class="tax_label">' . $woocommerce->countries->ex_tax_or_vat() . '</small>';
|
||||
|
||||
} elseif ( ! $this->display_cart_ex_tax && $tax_rates !== $base_tax_rates && $this->prices_include_tax ) {
|
||||
|
||||
$base_taxes = $this->tax->calc_tax( $price * $quantity, $base_tax_rates, true, true );
|
||||
$modded_taxes = $this->tax->calc_tax( ( $price * $quantity ) - array_sum( $base_taxes ), $tax_rates, false );
|
||||
$row_price = (( $price * $quantity ) - array_sum( $base_taxes )) + array_sum( $modded_taxes );
|
||||
|
||||
$product_subtotal = woocommerce_price( $row_price );
|
||||
if ( ! $this->prices_include_tax ) {
|
||||
$product_subtotal .= ' <small class="tax_label">' . $woocommerce->countries->inc_tax_or_vat() . '</small>';
|
||||
}
|
||||
if ( $this->prices_include_tax )
|
||||
$product_subtotal .= ' <small class="tax_label">' . $woocommerce->countries->ex_tax_or_vat() . '</small>';
|
||||
|
||||
} else {
|
||||
|
||||
$row_price = $price * $quantity;
|
||||
$row_price = $_product->get_price_including_tax( $quantity );
|
||||
$product_subtotal = woocommerce_price( $row_price );
|
||||
|
||||
if ( ! $this->prices_include_tax )
|
||||
$product_subtotal .= ' <small class="tax_label">' . $woocommerce->countries->inc_tax_or_vat() . '</small>';
|
||||
|
||||
}
|
||||
|
||||
// Non taxable
|
||||
// Non-taxable
|
||||
} else {
|
||||
|
||||
$row_price = $price * $quantity;
|
||||
$row_price = $price * $quantity;
|
||||
$product_subtotal = woocommerce_price( $row_price );
|
||||
|
||||
}
|
||||
|
||||
return apply_filters( 'woocommerce_cart_product_subtotal', $product_subtotal, $_product, $quantity, $this );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,9 @@ class WC_Checkout {
|
|||
/** @var bool Whether or not the user must create an account to checkout. */
|
||||
var $must_create_account;
|
||||
|
||||
/** @var bool Whether or not signups are allowed. */
|
||||
var $enable_signup;
|
||||
|
||||
/** @var bool True when the user is creating an account. */
|
||||
var $creating_account;
|
||||
|
||||
|
@ -32,11 +35,13 @@ class WC_Checkout {
|
|||
function __construct () {
|
||||
global $woocommerce;
|
||||
|
||||
add_action('woocommerce_checkout_process',array(&$this,'checkout_process'));
|
||||
add_action('woocommerce_checkout_billing',array(&$this,'checkout_form_billing'));
|
||||
add_action('woocommerce_checkout_shipping',array(&$this,'checkout_form_shipping'));
|
||||
add_action( 'woocommerce_checkout_process', array( &$this,'checkout_process' ) );
|
||||
add_action( 'woocommerce_checkout_billing', array( &$this,'checkout_form_billing' ) );
|
||||
add_action( 'woocommerce_checkout_shipping', array( &$this,'checkout_form_shipping' ) );
|
||||
|
||||
$this->must_create_account = get_option('woocommerce_enable_guest_checkout') == 'yes' || is_user_logged_in() ? false : true;
|
||||
$this->enable_signup = get_option( 'woocommerce_enable_signup_and_login_from_checkout' ) == 'yes' ? true : false;
|
||||
$this->enable_guest_checkout = get_option( 'woocommerce_enable_guest_checkout' ) == 'yes' ? true : false;
|
||||
$this->must_create_account = $this->enable_guest_checkout || is_user_logged_in() ? false : true;
|
||||
|
||||
// Define all Checkout fields
|
||||
$this->checkout_fields['billing'] = $woocommerce->countries->get_address_fields( $this->get_value('billing_country'), 'billing_' );
|
||||
|
@ -75,7 +80,10 @@ class WC_Checkout {
|
|||
'placeholder' => _x('Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce')
|
||||
)
|
||||
);
|
||||
$this->checkout_fields = apply_filters('woocommerce_checkout_fields', $this->checkout_fields);
|
||||
|
||||
$this->checkout_fields = apply_filters( 'woocommerce_checkout_fields', $this->checkout_fields );
|
||||
|
||||
do_action( 'woocommerce_checkout_init', $this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,7 +130,7 @@ class WC_Checkout {
|
|||
function process_checkout() {
|
||||
global $wpdb, $woocommerce;
|
||||
|
||||
if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) )
|
||||
if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) )
|
||||
define( 'WOOCOMMERCE_CHECKOUT', true );
|
||||
|
||||
$woocommerce->verify_nonce( 'process_checkout' );
|
||||
|
@ -142,7 +150,7 @@ class WC_Checkout {
|
|||
$this->posted['shipping_method'] = isset( $_POST['shipping_method'] ) ? woocommerce_clean( $_POST['shipping_method'] ) : '';
|
||||
|
||||
// Ship to billing only option
|
||||
if ( $woocommerce->cart->ship_to_billing_address_only() )
|
||||
if ( $woocommerce->cart->ship_to_billing_address_only() )
|
||||
$this->posted['shiptobilling'] = 1;
|
||||
|
||||
// Update customer shipping and payment method to posted method
|
||||
|
@ -398,7 +406,7 @@ class WC_Checkout {
|
|||
'post_password' => uniqid( 'order_' ) // Protects the post just in case
|
||||
) );
|
||||
|
||||
if ( $woocommerce->error_count() > 0 )
|
||||
if ( $woocommerce->error_count() > 0 )
|
||||
throw new MyException();
|
||||
|
||||
// Insert or update the post data
|
||||
|
@ -431,15 +439,15 @@ class WC_Checkout {
|
|||
else
|
||||
do_action( 'woocommerce_new_order', $order_id ); // Inserted successfully
|
||||
}
|
||||
|
||||
|
||||
// DELETE ANY ITEMS IN CURRENT ORDER
|
||||
|
||||
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d )", $order_id ) );
|
||||
|
||||
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d", $order_id ) );
|
||||
|
||||
|
||||
// SAVE LINE ITEMS
|
||||
|
||||
|
||||
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
|
||||
|
||||
$_product = $values['data'];
|
||||
|
@ -449,10 +457,10 @@ class WC_Checkout {
|
|||
'order_item_name' => $_product->get_title(),
|
||||
'order_item_type' => 'line_item'
|
||||
) );
|
||||
|
||||
|
||||
// Add line item meta
|
||||
if ( $item_id ) {
|
||||
woocommerce_add_order_item_meta( $item_id, '_qty', absint( $values['quantity'] ) );
|
||||
woocommerce_add_order_item_meta( $item_id, '_qty', apply_filters( 'woocommerce_stock_amount', $values['quantity'] ) );
|
||||
woocommerce_add_order_item_meta( $item_id, '_tax_class', $_product->get_tax_class() );
|
||||
woocommerce_add_order_item_meta( $item_id, '_product_id', $values['product_id'] );
|
||||
woocommerce_add_order_item_meta( $item_id, '_variation_id', $values['variation_id'] );
|
||||
|
@ -460,39 +468,39 @@ class WC_Checkout {
|
|||
woocommerce_add_order_item_meta( $item_id, '_line_subtotal_tax', woocommerce_format_decimal( $values['line_subtotal_tax'] ) );
|
||||
woocommerce_add_order_item_meta( $item_id, '_line_total', woocommerce_format_decimal( $values['line_total'] ) );
|
||||
woocommerce_add_order_item_meta( $item_id, '_line_tax', woocommerce_format_decimal( $values['line_tax'] ) );
|
||||
|
||||
|
||||
// Store variation data in meta so admin can view it
|
||||
if ( $values['variation'] && is_array( $values['variation'] ) )
|
||||
foreach ( $values['variation'] as $key => $value )
|
||||
woocommerce_add_order_item_meta( $item_id, esc_attr( str_replace( 'attribute_', '', $key ) ), $value );
|
||||
|
||||
|
||||
// Add line item meta for backorder status
|
||||
if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $values['quantity'] ) )
|
||||
woocommerce_add_order_item_meta( $item_id, __( 'Backordered', 'woocommerce' ), $values['quantity'] - max( 0, $_product->get_total_stock() ) );
|
||||
|
||||
|
||||
//allow plugins to add order item meta
|
||||
do_action( 'woocommerce_add_order_item_meta', $item_id, $values );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Store fees
|
||||
foreach ( $woocommerce->cart->get_fees() as $fee ) {
|
||||
$item_id = woocommerce_add_order_item( $order_id, array(
|
||||
'order_item_name' => $fee->name,
|
||||
'order_item_type' => 'fee'
|
||||
) );
|
||||
|
||||
|
||||
if ( $fee->taxable )
|
||||
woocommerce_add_order_item_meta( $item_id, '_tax_class', $fee->tax_class );
|
||||
else
|
||||
woocommerce_add_order_item_meta( $item_id, '_tax_class', '0' );
|
||||
|
||||
|
||||
woocommerce_add_order_item_meta( $item_id, '_line_total', woocommerce_format_decimal( $fee->amount ) );
|
||||
woocommerce_add_order_item_meta( $item_id, '_line_tax', woocommerce_format_decimal( $fee->tax ) );
|
||||
}
|
||||
|
||||
|
||||
// UPDATE USER META
|
||||
|
||||
|
||||
// Save billing and shipping first, also save to user meta if logged in
|
||||
if ( $this->checkout_fields['billing'] ) {
|
||||
foreach ( $this->checkout_fields['billing'] as $key => $field ) {
|
||||
|
@ -507,7 +515,7 @@ class WC_Checkout {
|
|||
// Special fields
|
||||
switch ( $key ) {
|
||||
case "billing_email" :
|
||||
if ( ! email_exists( $this->posted[ $key ] ) )
|
||||
if ( ! email_exists( $this->posted[ $key ] ) )
|
||||
wp_update_user( array ( 'ID' => $user_id, 'user_email' => $this->posted[ $key ] ) ) ;
|
||||
break;
|
||||
case "billing_first_name" :
|
||||
|
@ -541,11 +549,11 @@ class WC_Checkout {
|
|||
}
|
||||
|
||||
// Save any other user meta
|
||||
if ( $user_id )
|
||||
if ( $user_id )
|
||||
do_action( 'woocommerce_checkout_update_user_meta', $user_id, $this->posted );
|
||||
|
||||
|
||||
// UPDATE ORDER META
|
||||
|
||||
|
||||
// Get better formatted shipping method (title)
|
||||
$shipping_method = $this->posted['shipping_method'];
|
||||
if ( isset( $available_methods[ $this->posted['shipping_method'] ] ) )
|
||||
|
@ -555,22 +563,39 @@ class WC_Checkout {
|
|||
$payment_method = $this->posted['payment_method'];
|
||||
if ( isset( $available_gateways[ $this->posted['payment_method'] ] ) )
|
||||
$payment_method = $available_gateways[ $this->posted['payment_method'] ]->get_title();
|
||||
|
||||
|
||||
// Store tax rows
|
||||
foreach ( array_keys( $woocommerce->cart->taxes + $woocommerce->cart->shipping_taxes ) as $key ) {
|
||||
|
||||
|
||||
$item_id = woocommerce_add_order_item( $order_id, array(
|
||||
'order_item_name' => $woocommerce->cart->tax->get_rate_label( $key ),
|
||||
'order_item_name' => $woocommerce->cart->tax->get_rate_code( $key ),
|
||||
'order_item_type' => 'tax'
|
||||
) );
|
||||
|
||||
|
||||
// Add line item meta
|
||||
if ( $item_id ) {
|
||||
woocommerce_add_order_item_meta( $item_id, 'rate_id', $key );
|
||||
woocommerce_add_order_item_meta( $item_id, 'label', $woocommerce->cart->tax->get_rate_label( $key ) );
|
||||
woocommerce_add_order_item_meta( $item_id, 'compound', absint( $woocommerce->cart->tax->is_compound( $key ) ? 1 : 0 ) );
|
||||
woocommerce_add_order_item_meta( $item_id, 'tax_amount', woocommerce_clean( isset( $woocommerce->cart->taxes[ $key ] ) ? $woocommerce->cart->taxes[ $key ] : 0 ) );
|
||||
woocommerce_add_order_item_meta( $item_id, 'shipping_tax_amount', woocommerce_clean( isset( $woocommerce->cart->shipping_taxes[ $key ] ) ? $woocommerce->cart->shipping_taxes[ $key ] : 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Store coupons
|
||||
if ( $applied_coupons = $woocommerce->cart->get_applied_coupons() ) {
|
||||
foreach ( $applied_coupons as $code ) {
|
||||
|
||||
$item_id = woocommerce_add_order_item( $order_id, array(
|
||||
'order_item_name' => $code,
|
||||
'order_item_type' => 'coupon'
|
||||
) );
|
||||
|
||||
// Add line item meta
|
||||
if ( $item_id ) {
|
||||
woocommerce_add_order_item_meta( $item_id, 'discount_amount', isset( $woocommerce->cart->coupon_discount_amounts[ $code ] ) ? $woocommerce->cart->coupon_discount_amounts[ $code ] : 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Save other order meta fields
|
||||
|
@ -590,7 +615,7 @@ class WC_Checkout {
|
|||
update_post_meta( $order_id, '_prices_include_tax', get_option( 'woocommerce_prices_include_tax' ) );
|
||||
|
||||
// Store technical customer details in meta
|
||||
$customer_ip = isset( $_SERVER['HTTP_X_FORWARD_FOR'] ) ? $_SERVER['HTTP_X_FORWARD_FOR'] : $_SERVER['REMOTE_ADDR'];
|
||||
$customer_ip = isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
|
||||
$customer_user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
|
||||
|
||||
update_post_meta( $order_id, __( 'Customer IP Address', 'woocommerce' ), $customer_ip );
|
||||
|
@ -602,17 +627,6 @@ class WC_Checkout {
|
|||
// Order status
|
||||
wp_set_object_terms( $order_id, 'pending', 'shop_order_status' );
|
||||
|
||||
// Discount code meta
|
||||
if ( $applied_coupons = $woocommerce->cart->get_applied_coupons() ) {
|
||||
|
||||
update_post_meta( $order_id, 'coupons', implode(', ', $applied_coupons) );
|
||||
|
||||
if ( empty( $order ) )
|
||||
$order = new WC_Order( $order_id );
|
||||
|
||||
$order->add_order_note( sprintf( __( 'Coupon Code Used: %s', 'woocommerce' ), implode(', ', $applied_coupons ) ) );
|
||||
}
|
||||
|
||||
// Order is saved
|
||||
do_action( 'woocommerce_checkout_order_processed', $order_id, $this->posted );
|
||||
|
||||
|
@ -677,10 +691,10 @@ class WC_Checkout {
|
|||
}
|
||||
|
||||
} catch ( Exception $e ) {
|
||||
|
||||
|
||||
if ( ! empty( $e ) )
|
||||
$woocommerce->add_error( $e );
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // endif
|
||||
|
@ -722,7 +736,7 @@ class WC_Checkout {
|
|||
|
||||
} elseif ( is_user_logged_in() ) {
|
||||
|
||||
if ( $meta = get_user_meta( get_current_user_id(), $input, true ) )
|
||||
if ( $meta = get_user_meta( get_current_user_id(), $input, true ) )
|
||||
return $meta;
|
||||
|
||||
$current_user = wp_get_current_user();
|
||||
|
|
|
@ -480,7 +480,7 @@ class WC_Countries {
|
|||
|
||||
asort( $this->countries );
|
||||
|
||||
if ( get_option('woocommerce_allowed_countries') !== 'specific' )
|
||||
if ( get_option('woocommerce_allowed_countries') !== 'specific' )
|
||||
return $this->countries;
|
||||
|
||||
$allowed_countries = array();
|
||||
|
@ -492,17 +492,17 @@ class WC_Countries {
|
|||
|
||||
return $allowed_countries;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* get_allowed_country_states function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function get_allowed_country_states() {
|
||||
|
||||
if ( get_option('woocommerce_allowed_countries') !== 'specific' )
|
||||
if ( get_option('woocommerce_allowed_countries') !== 'specific' )
|
||||
return $this->states;
|
||||
|
||||
$allowed_states = array();
|
||||
|
@ -510,7 +510,7 @@ class WC_Countries {
|
|||
$allowed_countries_raw = get_option( 'woocommerce_specific_allowed_countries' );
|
||||
|
||||
foreach ( $allowed_countries_raw as $country )
|
||||
if ( ! empty( $this->states[ $country ] ) )
|
||||
if ( ! empty( $this->states[ $country ] ) )
|
||||
$allowed_states[ $country ] = $this->states[ $country ];
|
||||
|
||||
return $allowed_states;
|
||||
|
@ -740,7 +740,7 @@ class WC_Countries {
|
|||
$full_country = ( isset( $this->countries[ $country ] ) ) ? $this->countries[ $country ] : $country;
|
||||
|
||||
// Country is not needed if the same as base
|
||||
if ( $country == $this->get_base_country() )
|
||||
if ( $country == $this->get_base_country() )
|
||||
$format = str_replace( '{country}', '', $format );
|
||||
|
||||
// Handle full state name
|
||||
|
@ -769,7 +769,7 @@ class WC_Countries {
|
|||
'{postcode_upper}' => strtoupper( $postcode ),
|
||||
'{country_upper}' => strtoupper( $full_country ),
|
||||
) ) ;
|
||||
|
||||
|
||||
$replace = array_map( 'esc_html', $replace );
|
||||
|
||||
$formatted_address = str_replace( array_keys( $replace ), $replace, $format );
|
||||
|
@ -1167,7 +1167,8 @@ class WC_Countries {
|
|||
'label' => __( 'Email Address', 'woocommerce' ),
|
||||
'placeholder' => _x('Email Address', 'placeholder', 'woocommerce'),
|
||||
'required' => true,
|
||||
'class' => array('form-row-first')
|
||||
'class' => array('form-row-first'),
|
||||
'validate' => array('email'),
|
||||
);
|
||||
$address_fields['billing_phone'] = array(
|
||||
'label' => __( 'Phone', 'woocommerce' ),
|
||||
|
|
|
@ -76,12 +76,12 @@ class WC_Coupon {
|
|||
global $wpdb;
|
||||
|
||||
$this->code = apply_filters( 'woocommerce_coupon_code', $code );
|
||||
|
||||
|
||||
// Coupon data lets developers create coupons through code
|
||||
$coupon_data = apply_filters( 'woocommerce_get_shop_coupon_data', false, $code );
|
||||
|
||||
if ( $coupon_data ) {
|
||||
|
||||
|
||||
$this->id = absint( $coupon_data['id'] );
|
||||
$this->type = esc_html( $coupon_data['type'] );
|
||||
$this->amount = esc_html( $coupon_data['amount'] );
|
||||
|
@ -97,19 +97,21 @@ class WC_Coupon {
|
|||
$this->exclude_product_categories = is_array( $coupon_data['exclude_product_categories'] ) ? $coupon_data['exclude_product_categories'] : array();
|
||||
$this->minimum_amount = esc_html( $coupon_data['minimum_amount'] );
|
||||
$this->customer_email = esc_html( $coupon_data['customer_email'] );
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
$coupon_id = $wpdb->get_var( $wpdb->prepare( apply_filters( 'woocommerce_coupon_code_query', "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'shop_coupon'" ), $this->code ) );
|
||||
|
||||
if ( $coupon_id )
|
||||
$coupon = get_post( $coupon_id );
|
||||
|
||||
|
||||
if ( $coupon_id )
|
||||
$coupon = get_post( $coupon_id );
|
||||
else
|
||||
return false;
|
||||
|
||||
$coupon->post_title = apply_filters( 'woocommerce_coupon_code', $coupon->post_title );
|
||||
|
||||
if ( empty( $coupon ) || $coupon->post_status !== 'publish' || $this->code !== $coupon->post_title )
|
||||
if ( empty( $coupon ) || $coupon->post_status !== 'publish' || $this->code !== $coupon->post_title )
|
||||
return false;
|
||||
|
||||
$this->id = $coupon->ID;
|
||||
|
@ -132,7 +134,7 @@ class WC_Coupon {
|
|||
'customer_email' => array()
|
||||
);
|
||||
|
||||
foreach ( $load_data as $key => $default )
|
||||
foreach ( $load_data as $key => $default )
|
||||
$this->$key = isset( $this->coupon_custom_fields[ $key ][0] ) && $this->coupon_custom_fields[ $key ][0] !== '' ? $this->coupon_custom_fields[ $key ][0] : $default;
|
||||
|
||||
// Alias
|
||||
|
@ -149,7 +151,7 @@ class WC_Coupon {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -225,7 +227,7 @@ class WC_Coupon {
|
|||
|
||||
// Expired
|
||||
if ( $this->expiry_date ) {
|
||||
if ( strtotime( 'NOW' ) > $this->expiry_date ) {
|
||||
if ( current_time( 'timestamp' ) > $this->expiry_date ) {
|
||||
$valid = false;
|
||||
$error = __( 'This coupon has expired.', 'woocommerce' );
|
||||
}
|
||||
|
@ -244,7 +246,7 @@ class WC_Coupon {
|
|||
$valid_for_cart = false;
|
||||
if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {
|
||||
foreach( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||
|
||||
|
||||
if ( in_array( $cart_item['product_id'], $this->product_ids ) || in_array( $cart_item['variation_id'], $this->product_ids ) || in_array( $cart_item['data']->get_parent(), $this->product_ids ) )
|
||||
$valid_for_cart = true;
|
||||
}
|
||||
|
@ -260,10 +262,10 @@ class WC_Coupon {
|
|||
$valid_for_cart = false;
|
||||
if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {
|
||||
foreach( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||
|
||||
|
||||
$product_cats = wp_get_post_terms($cart_item['product_id'], 'product_cat', array("fields" => "ids"));
|
||||
|
||||
if ( sizeof( array_intersect( $product_cats, $this->product_categories ) ) > 0 )
|
||||
|
||||
if ( sizeof( array_intersect( $product_cats, $this->product_categories ) ) > 0 )
|
||||
$valid_for_cart = true;
|
||||
}
|
||||
}
|
||||
|
@ -297,10 +299,10 @@ class WC_Coupon {
|
|||
$valid_for_cart = true;
|
||||
if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {
|
||||
foreach( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||
|
||||
|
||||
$product_cats = wp_get_post_terms( $cart_item['product_id'], 'product_cat', array( "fields" => "ids" ) );
|
||||
|
||||
if ( sizeof( array_intersect( $product_cats, $this->exclude_product_categories ) ) > 0 )
|
||||
|
||||
if ( sizeof( array_intersect( $product_cats, $this->exclude_product_categories ) ) > 0 )
|
||||
$valid_for_cart = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
* @author WooThemes
|
||||
*/
|
||||
class WC_Customer {
|
||||
|
||||
|
||||
/** Stores customer data as an array */
|
||||
protected $_data;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for the customer class loads the customer data.
|
||||
*
|
||||
|
@ -22,7 +22,7 @@ class WC_Customer {
|
|||
*/
|
||||
function __construct() {
|
||||
global $woocommerce;
|
||||
|
||||
|
||||
if ( empty( $woocommerce->session->customer ) ) {
|
||||
|
||||
$default = apply_filters( 'woocommerce_customer_default_location', get_option( 'woocommerce_default_country' ) );
|
||||
|
@ -39,25 +39,29 @@ class WC_Customer {
|
|||
'state' => '',
|
||||
'postcode' => '',
|
||||
'city' => '',
|
||||
'address' => '',
|
||||
'address_2' => '',
|
||||
'shipping_country' => esc_html( $country ),
|
||||
'shipping_state' => '',
|
||||
'shipping_postcode' => '',
|
||||
'shipping_city' => '',
|
||||
'shipping_address' => '',
|
||||
'shipping_address_2' => '',
|
||||
'is_vat_exempt' => false,
|
||||
'calculated_shipping' => false
|
||||
);
|
||||
|
||||
|
||||
} else {
|
||||
$this->_data = $woocommerce->session->customer;
|
||||
}
|
||||
|
||||
|
||||
// When leaving or ending page load, store data
|
||||
add_action( 'shutdown', array( &$this, 'save_data' ), 10 );
|
||||
}
|
||||
|
||||
/**
|
||||
* __get function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $property
|
||||
* @return mixed
|
||||
|
@ -65,10 +69,10 @@ class WC_Customer {
|
|||
public function __get( $property ) {
|
||||
return isset( $this->_data[ $property ] ) ? $this->_data[ $property ] : null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* __set function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $property
|
||||
* @param mixed $value
|
||||
|
@ -77,10 +81,10 @@ class WC_Customer {
|
|||
public function __set( $property, $value ) {
|
||||
$this->_data[ $property ] = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* save_data function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -152,11 +156,11 @@ class WC_Customer {
|
|||
*/
|
||||
function is_customer_outside_base() {
|
||||
list( $country, $state, $postcode, $city ) = $this->get_taxable_address();
|
||||
|
||||
|
||||
if ( $country ) {
|
||||
|
||||
$default = get_option('woocommerce_default_country');
|
||||
|
||||
|
||||
if ( strstr( $default, ':' ) ) {
|
||||
list( $default_country, $default_state ) = explode( ':', $default );
|
||||
} else {
|
||||
|
@ -216,11 +220,11 @@ class WC_Customer {
|
|||
$validation = $woocommerce->validation();
|
||||
if (isset($this->_data['postcode']) && $this->_data['postcode'] !== false) return $validation->format_postcode( $this->_data['postcode'], $this->get_country());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the city from the current session.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -228,6 +232,25 @@ class WC_Customer {
|
|||
if ( isset( $this->_data['city'] ) ) return $this->_data['city'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the address from the current session.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function get_address() {
|
||||
if ( isset( $this->_data['address'] ) ) return $this->_data['address'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the address_2 from the current session.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function get_address_2() {
|
||||
if ( isset( $this->_data['address_2'] ) ) return $this->_data['address_2'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the state from the current session.
|
||||
|
@ -262,44 +285,83 @@ class WC_Customer {
|
|||
$validation = $woocommerce->validation();
|
||||
if (isset($this->_data['shipping_postcode'])) return $validation->format_postcode( $this->_data['shipping_postcode'], $this->get_shipping_country());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the city from the current session.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function get_shipping_city() {
|
||||
if ( isset( $this->_data['shipping_city'] ) ) return $this->_data['shipping_city'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the address from the current session.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function get_shipping_address() {
|
||||
if ( isset( $this->_data['shipping_address'] ) ) return $this->_data['shipping_address'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the address_2 from the current session.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function get_shipping_address_2() {
|
||||
if ( isset( $this->_data['shipping_address_2'] ) ) return $this->_data['shipping_address_2'];
|
||||
}
|
||||
|
||||
/**
|
||||
* get_taxable_address function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function get_taxable_address() {
|
||||
if ( get_option( 'woocommerce_tax_shipping_address' ) == 'yes' ) {
|
||||
$country = $this->get_shipping_country();
|
||||
$state = $this->get_shipping_state();
|
||||
$postcode = $this->get_shipping_postcode();
|
||||
$city = $this->get_shipping_city();
|
||||
} else {
|
||||
$tax_based_on = get_option( 'woocommerce_tax_based_on' );
|
||||
|
||||
if ( $tax_based_on == 'base' ) {
|
||||
|
||||
$default = get_option( 'woocommerce_default_country' );
|
||||
if ( strstr( $default, ':' ) ) {
|
||||
list( $country, $state ) = explode( ':', $default );
|
||||
} else {
|
||||
$country = $default;
|
||||
$state = '';
|
||||
}
|
||||
|
||||
$postcode = '';
|
||||
$city = '';
|
||||
|
||||
} elseif ( $tax_based_on == 'billing' ) {
|
||||
|
||||
$country = $this->get_country();
|
||||
$state = $this->get_state();
|
||||
$postcode = $this->get_postcode();
|
||||
$city = $this->get_city();
|
||||
|
||||
} else {
|
||||
|
||||
$country = $this->get_shipping_country();
|
||||
$state = $this->get_shipping_state();
|
||||
$postcode = $this->get_shipping_postcode();
|
||||
$city = $this->get_shipping_city();
|
||||
|
||||
}
|
||||
|
||||
return apply_filters( 'woocommerce_customer_taxable_address', array( $country, $state, $postcode, $city ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets session data for the location.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $country
|
||||
* @param mixed $state
|
||||
|
@ -362,6 +424,28 @@ class WC_Customer {
|
|||
$this->_data['city'] = $city;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets session data for the address.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $address
|
||||
* @return void
|
||||
*/
|
||||
function set_address( $address ) {
|
||||
$this->_data['address'] = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets session data for the address_2.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $address_2
|
||||
* @return void
|
||||
*/
|
||||
function set_address_2( $address_2 ) {
|
||||
$this->_data['address_2'] = $address_2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets session data for the location.
|
||||
*
|
||||
|
@ -369,14 +453,14 @@ class WC_Customer {
|
|||
* @param mixed $country
|
||||
* @param string $state (default: '')
|
||||
* @param string $postcode (default: '')
|
||||
* @param string $city (default: '')
|
||||
* @param string $city (default: '')
|
||||
* @return void
|
||||
*/
|
||||
function set_shipping_location( $country, $state = '', $postcode = '', $city = '' ) {
|
||||
$this->_data['shipping_country'] = $country;
|
||||
$this->_data['shipping_state'] = $state;
|
||||
$this->_data['shipping_postcode'] = $postcode;
|
||||
$this->_data['shipping_city'] = $city;
|
||||
$this->_data['shipping_city'] = $city;
|
||||
}
|
||||
|
||||
|
||||
|
@ -427,6 +511,28 @@ class WC_Customer {
|
|||
$this->_data['shipping_city'] = $city;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets session data for the address.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $address
|
||||
* @return void
|
||||
*/
|
||||
function set_shipping_address( $address ) {
|
||||
$this->_data['shipping_address'] = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets session data for the address_2.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $address_2
|
||||
* @return void
|
||||
*/
|
||||
function set_shipping_address_2( $address_2 ) {
|
||||
$this->_data['shipping_address_2'] = $address_2;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets session data for the tax exemption.
|
||||
|
@ -442,7 +548,7 @@ class WC_Customer {
|
|||
|
||||
/**
|
||||
* calculated_shipping function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $calculated
|
||||
* @return void
|
||||
|
@ -450,7 +556,7 @@ class WC_Customer {
|
|||
function calculated_shipping( $calculated = true ) {
|
||||
$this->_data['calculated_shipping'] = $calculated;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets a user's downloadable products if they are logged in.
|
||||
|
@ -468,7 +574,7 @@ class WC_Customer {
|
|||
$user_info = get_userdata( get_current_user_id() );
|
||||
|
||||
$results = $wpdb->get_results( $wpdb->prepare("SELECT * FROM ".$wpdb->prefix."woocommerce_downloadable_product_permissions WHERE user_id = '%s' ORDER BY order_id, product_id, download_id", get_current_user_id()) );
|
||||
|
||||
|
||||
$_product = null;
|
||||
$order = null;
|
||||
$file_number = 0;
|
||||
|
@ -483,21 +589,37 @@ class WC_Customer {
|
|||
}
|
||||
|
||||
// order exists and downloads permitted?
|
||||
if ( ! $order->id || ! $order->is_download_permitted() ) continue;
|
||||
if ( ! $order->id || ! $order->is_download_permitted() || $order->post_status != 'publish' ) continue;
|
||||
|
||||
if ( ! $_product || $_product->id != $result->product_id ) :
|
||||
// new product
|
||||
$file_number = 0;
|
||||
$_product = new WC_Product( $result->product_id );
|
||||
$_product = get_product( $result->product_id );
|
||||
endif;
|
||||
|
||||
if ( ! $_product->exists() ) continue;
|
||||
|
||||
if ( ! $_product || ! $_product->exists() ) continue;
|
||||
|
||||
if ( ! $_product->has_file( $result->download_id ) ) continue;
|
||||
|
||||
// Download name will be 'Product Name' for products with a single downloadable file, and 'Product Name - File X' for products with multiple files
|
||||
$download_name = $_product->get_title() . ( $file_number > 0 ? ' — ' . sprintf( __( 'File %d', 'woocommerce' ), $file_number + 1 ) : '' );
|
||||
if ( $file_number == 1 ) $downloads[ count( $downloads ) - 1 ]['download_name'] .= ' — ' . sprintf( __( 'File %d', 'woocommerce' ), $file_number );
|
||||
$download_name = apply_filters(
|
||||
'woocommerce_downloadable_product_name',
|
||||
$_product->get_title() . ( $file_number > 0 ? ' — ' . sprintf( __( 'File %d', 'woocommerce' ), $file_number + 1 ) : '' ),
|
||||
$_product,
|
||||
$result->download_id,
|
||||
$file_number
|
||||
);
|
||||
|
||||
// Rename previous download with file number if there are multiple files only
|
||||
if ( $file_number == 1 ) {
|
||||
$downloads[ count( $downloads ) - 1 ]['download_name'] = apply_filters(
|
||||
'woocommerce_downloadable_product_name',
|
||||
$downloads[ count( $downloads ) - 1 ]['download_name'] . ' — ' . sprintf( __( 'File %d', 'woocommerce' ), $file_number ),
|
||||
$_product,
|
||||
$result->download_id,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
$downloads[] = array(
|
||||
'download_url' => add_query_arg( array( 'download_file' => $result->product_id, 'order' => $result->order_key, 'email' => $result->user_email, 'key' => $result->download_id ), trailingslashit( home_url() ) ),
|
||||
|
|
|
@ -86,11 +86,11 @@ class WC_Logger {
|
|||
if ( $this->open( $handle ) )
|
||||
ftruncate( $this->handles[ $handle ], 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* file_name function.
|
||||
*
|
||||
*
|
||||
* @access private
|
||||
* @param mixed $handle
|
||||
* @return void
|
||||
|
|
|
@ -14,7 +14,7 @@ class WC_Order {
|
|||
/** @var int Order (post) ID */
|
||||
var $id;
|
||||
|
||||
/** @var string Coupon code. */
|
||||
/** @var string Order status. */
|
||||
var $status;
|
||||
|
||||
/** @var string Order date (placed). */
|
||||
|
@ -107,6 +107,9 @@ class WC_Order {
|
|||
/** @var string After tax discount total */
|
||||
var $order_discount;
|
||||
|
||||
/** @var string Refund total */
|
||||
var $refund_total;
|
||||
|
||||
/** @var string Before tax discount total */
|
||||
var $cart_discount;
|
||||
|
||||
|
@ -146,6 +149,9 @@ class WC_Order {
|
|||
/** @var string */
|
||||
var $formatted_shipping_address;
|
||||
|
||||
/** @var string */
|
||||
var $post_status;
|
||||
|
||||
/**
|
||||
* Get the order if ID is passed, otherwise the order is new and empty.
|
||||
*
|
||||
|
@ -154,9 +160,12 @@ class WC_Order {
|
|||
* @return void
|
||||
*/
|
||||
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;
|
||||
$this->prices_include_tax = get_option('woocommerce_prices_include_tax') == 'yes' ? true : false;
|
||||
$this->tax_display_cart = get_option( 'woocommerce_tax_display_cart' );
|
||||
|
||||
$this->display_totals_ex_tax = $this->tax_display_cart == 'excl' ? true : false;
|
||||
$this->display_cart_ex_tax = $this->tax_display_cart == 'excl' ? true : false;
|
||||
|
||||
if ( $id > 0 )
|
||||
$this->get_order( $id );
|
||||
}
|
||||
|
@ -193,6 +202,7 @@ class WC_Order {
|
|||
$this->order_date = $result->post_date;
|
||||
$this->modified_date = $result->post_modified;
|
||||
$this->customer_note = $result->post_excerpt;
|
||||
$this->post_status = $result->post_status;
|
||||
$this->order_custom_fields = get_post_custom( $this->id );
|
||||
|
||||
// Define the data we're going to load: Key => Default value
|
||||
|
@ -223,6 +233,7 @@ class WC_Order {
|
|||
'payment_method' => '',
|
||||
'payment_method_title' => '',
|
||||
'order_discount' => '',
|
||||
'refund_total' => '',
|
||||
'cart_discount' => '',
|
||||
'order_tax' => '',
|
||||
'order_shipping' => '',
|
||||
|
@ -386,23 +397,23 @@ class WC_Order {
|
|||
|
||||
/**
|
||||
* Return an array of items/products within this order.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param string $type Types of line items to get (array or string)
|
||||
* @return void
|
||||
*/
|
||||
function get_items( $type = '' ) {
|
||||
global $wpdb, $woocommerce;
|
||||
|
||||
|
||||
if ( empty( $type ) )
|
||||
$type = array( 'line_item' );
|
||||
|
||||
|
||||
if ( ! is_array( $type ) ) {
|
||||
$type = array( $type );
|
||||
}
|
||||
|
||||
|
||||
$type = array_map( 'esc_attr', $type );
|
||||
|
||||
|
||||
$line_items = $wpdb->get_results( $wpdb->prepare( "
|
||||
SELECT order_item_id, order_item_name, order_item_type
|
||||
FROM {$wpdb->prefix}woocommerce_order_items
|
||||
|
@ -410,16 +421,16 @@ class WC_Order {
|
|||
AND order_item_type IN ( '" . implode( "','", $type ) . "' )
|
||||
ORDER BY order_item_id
|
||||
", $this->id ) );
|
||||
|
||||
|
||||
$items = array();
|
||||
|
||||
|
||||
foreach ( $line_items as $item ) {
|
||||
|
||||
|
||||
// Place line item into array to return
|
||||
$items[ $item->order_item_id ]['name'] = $item->order_item_name;
|
||||
$items[ $item->order_item_id ]['type'] = $item->order_item_type;
|
||||
$items[ $item->order_item_id ]['item_meta'] = $this->get_item_meta( $item->order_item_id );
|
||||
|
||||
|
||||
// Put meta into item array
|
||||
foreach( $items[ $item->order_item_id ]['item_meta'] as $name => $value ) {
|
||||
$key = substr( $name, 0, 1 ) == '_' ? substr( $name, 1 ) : $name;
|
||||
|
@ -438,10 +449,10 @@ class WC_Order {
|
|||
function get_fees() {
|
||||
return $this->get_items( 'fee' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an array of taxes within this order.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -451,21 +462,21 @@ class WC_Order {
|
|||
|
||||
/**
|
||||
* has_meta function for order items.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return array of meta data
|
||||
*/
|
||||
function has_meta( $order_item_id ) {
|
||||
global $wpdb;
|
||||
|
||||
|
||||
return $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value, meta_id, order_item_id
|
||||
FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id = %d
|
||||
ORDER BY meta_key,meta_id", absint( $order_item_id ) ), ARRAY_A );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get order item meta.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $item_id
|
||||
* @param string $key (default: '')
|
||||
|
@ -512,6 +523,17 @@ class WC_Order {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the total refund amount
|
||||
*
|
||||
* @access public
|
||||
* @return float
|
||||
*/
|
||||
function get_refund_total() {
|
||||
return apply_filters( 'woocommerce_order_refund_total', number_format( (double) $this->refund_total, 2, '.', '' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the total discount amount - both kinds
|
||||
*
|
||||
|
@ -557,6 +579,16 @@ class WC_Order {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* get_order_total function. Alias for get_total()
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function get_order_total() {
|
||||
return $this->get_total();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets shipping method title.
|
||||
*
|
||||
|
@ -677,12 +709,12 @@ class WC_Order {
|
|||
|
||||
if (!isset($item['line_subtotal']) || !isset($item['line_subtotal_tax'])) return;
|
||||
|
||||
if ( $this->display_cart_ex_tax || ! $this->prices_include_tax ) :
|
||||
if ( $this->tax_display_cart == 'excl' ) {
|
||||
if ( $this->prices_include_tax ) $ex_tax_label = 1; else $ex_tax_label = 0;
|
||||
$subtotal = woocommerce_price( $this->get_line_subtotal( $item ), array('ex_tax_label' => $ex_tax_label ) );
|
||||
else :
|
||||
$subtotal = woocommerce_price( $this->get_line_subtotal( $item ), array( 'ex_tax_label' => $ex_tax_label ) );
|
||||
} else {
|
||||
$subtotal = woocommerce_price( $this->get_line_subtotal( $item, true ) );
|
||||
endif;
|
||||
}
|
||||
|
||||
return apply_filters( 'woocommerce_order_formatted_line_subtotal', $subtotal, $item, $this );
|
||||
}
|
||||
|
@ -714,54 +746,54 @@ class WC_Order {
|
|||
|
||||
$subtotal = 0;
|
||||
|
||||
if ( ! $compound ) :
|
||||
if ( ! $compound ) {
|
||||
|
||||
foreach ($this->get_items() as $item) :
|
||||
foreach ( $this->get_items() as $item ) {
|
||||
|
||||
if ( ! isset( $item['line_subtotal'] ) || ! isset( $item['line_subtotal_tax'] ) ) return;
|
||||
|
||||
$subtotal += $this->get_line_subtotal( $item );
|
||||
|
||||
if ( ! $this->display_cart_ex_tax ) :
|
||||
if ( $this->tax_display_cart == 'incl' ) {
|
||||
$subtotal += $item['line_subtotal_tax'];
|
||||
endif;
|
||||
}
|
||||
|
||||
endforeach;
|
||||
}
|
||||
|
||||
$subtotal = woocommerce_price( $subtotal );
|
||||
|
||||
if ( $this->display_cart_ex_tax && $this->prices_include_tax ) :
|
||||
if ( $this->tax_display_cart == 'excl' && $this->prices_include_tax )
|
||||
$subtotal .= ' <small>'.$woocommerce->countries->ex_tax_or_vat().'</small>';
|
||||
endif;
|
||||
|
||||
else :
|
||||
} else {
|
||||
|
||||
if ( $this->prices_include_tax ) return;
|
||||
if ( $this->tax_display_cart == 'incl' )
|
||||
return;
|
||||
|
||||
foreach ($this->get_items() as $item) :
|
||||
foreach ( $this->get_items() as $item ) {
|
||||
|
||||
$subtotal += $item['line_subtotal'];
|
||||
|
||||
endforeach;
|
||||
}
|
||||
|
||||
// Add Shipping Costs
|
||||
$subtotal += $this->get_shipping();
|
||||
|
||||
// Remove non-compound taxes
|
||||
foreach ( $this->get_taxes() as $tax ) :
|
||||
foreach ( $this->get_taxes() as $tax ) {
|
||||
|
||||
if ( ! empty( $tax['compound'] ) ) continue;
|
||||
|
||||
$subtotal = $subtotal + $tax['tax_amount'] + $tax['shipping_tax_amount'];
|
||||
|
||||
endforeach;
|
||||
}
|
||||
|
||||
// Remove discounts
|
||||
$subtotal = $subtotal - $this->get_cart_discount();
|
||||
|
||||
$subtotal = woocommerce_price( $subtotal );
|
||||
|
||||
endif;
|
||||
}
|
||||
|
||||
return apply_filters( 'woocommerce_order_subtotal_to_display', $subtotal, $compound, $this );
|
||||
}
|
||||
|
@ -776,35 +808,35 @@ class WC_Order {
|
|||
function get_shipping_to_display() {
|
||||
global $woocommerce;
|
||||
|
||||
if ( $this->order_shipping > 0 ) :
|
||||
if ( $this->order_shipping > 0 ) {
|
||||
|
||||
$tax_text = '';
|
||||
|
||||
if ($this->display_totals_ex_tax || !$this->prices_include_tax) :
|
||||
if ( $this->tax_display_cart == 'excl' ) {
|
||||
|
||||
// Show shipping excluding tax
|
||||
$shipping = woocommerce_price($this->order_shipping);
|
||||
if ($this->order_shipping_tax > 0 && $this->prices_include_tax) :
|
||||
$tax_text = $woocommerce->countries->ex_tax_or_vat() . ' ';
|
||||
endif;
|
||||
$shipping = woocommerce_price( $this->order_shipping );
|
||||
|
||||
else :
|
||||
if ( $this->order_shipping_tax > 0 && $this->prices_include_tax )
|
||||
$tax_text = $woocommerce->countries->ex_tax_or_vat() . ' ';
|
||||
|
||||
} else {
|
||||
|
||||
// Show shipping including tax
|
||||
$shipping = woocommerce_price($this->order_shipping + $this->order_shipping_tax);
|
||||
if ($this->order_shipping_tax > 0 && !$this->prices_include_tax) :
|
||||
$tax_text = $woocommerce->countries->inc_tax_or_vat() . ' ';
|
||||
endif;
|
||||
$shipping = woocommerce_price( $this->order_shipping + $this->order_shipping_tax );
|
||||
|
||||
endif;
|
||||
if ( $this->order_shipping_tax > 0 && ! $this->prices_include_tax )
|
||||
$tax_text = $woocommerce->countries->inc_tax_or_vat() . ' ';
|
||||
|
||||
}
|
||||
|
||||
$shipping .= sprintf( __( ' <small>%svia %s</small>', 'woocommerce' ), $tax_text, $this->get_shipping_method() );
|
||||
|
||||
elseif ( $this->get_shipping_method() ) :
|
||||
} elseif ( $this->get_shipping_method() ) {
|
||||
$shipping = $this->get_shipping_method();
|
||||
else :
|
||||
} else {
|
||||
$shipping = __( 'Free!', 'woocommerce' );
|
||||
endif;
|
||||
}
|
||||
|
||||
return apply_filters( 'woocommerce_order_shipping_to_display', $shipping, $this );
|
||||
}
|
||||
|
@ -840,12 +872,7 @@ class WC_Order {
|
|||
* @return WC_Product
|
||||
*/
|
||||
function get_product_from_item( $item ) {
|
||||
|
||||
if (isset($item['variation_id']) && $item['variation_id']>0) :
|
||||
$_product = new WC_Product_Variation( $item['variation_id'] );
|
||||
else :
|
||||
$_product = new WC_Product( $item['product_id'] );
|
||||
endif;
|
||||
$_product = get_product( $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );
|
||||
|
||||
return $_product;
|
||||
|
||||
|
@ -880,19 +907,19 @@ class WC_Order {
|
|||
'label' => __( 'Shipping:', 'woocommerce' ),
|
||||
'value' => $this->get_shipping_to_display()
|
||||
);
|
||||
|
||||
|
||||
if ( $fees = $this->get_fees() )
|
||||
foreach( $fees as $id => $fee ) {
|
||||
|
||||
if ( $this->display_cart_ex_tax || ! $this->prices_include_tax ) {
|
||||
|
||||
|
||||
if ( $this->tax_display_cart == 'excl' ) {
|
||||
|
||||
$total_rows[ 'fee_' . $id ] = array(
|
||||
'label' => $fee['name'],
|
||||
'value' => woocommerce_price( $fee['line_total'] )
|
||||
);
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
$total_rows[ 'fee_' . $id ] = array(
|
||||
'label' => $fee['name'],
|
||||
'value' => woocommerce_price( $fee['line_total'] + $fee['line_tax'] )
|
||||
|
@ -900,66 +927,50 @@ class WC_Order {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Tax for tax exclusive prices
|
||||
if ( $this->display_cart_ex_tax || ! $this->prices_include_tax ) {
|
||||
|
||||
if ( $this->get_total_tax() > 0 ) {
|
||||
|
||||
if ( sizeof( $this->get_taxes() ) > 0 ) {
|
||||
|
||||
$has_compound_tax = false;
|
||||
|
||||
foreach ( $this->get_taxes() as $tax ) {
|
||||
if ( $tax[ 'compound' ] ) {
|
||||
$has_compound_tax = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ( $tax[ 'tax_amount' ] + $tax[ 'shipping_tax_amount' ] ) == 0 )
|
||||
continue;
|
||||
|
||||
$total_rows[ sanitize_title( $tax[ 'name' ] ) ] = array(
|
||||
'label' => $tax[ 'name' ] . ':',
|
||||
'value' => woocommerce_price( ( $tax[ 'tax_amount' ] + $tax[ 'shipping_tax_amount' ] ) )
|
||||
);
|
||||
if ( $this->tax_display_cart == 'excl' ) {
|
||||
if ( sizeof( $this->get_taxes() ) > 0 ) {
|
||||
|
||||
$has_compound_tax = false;
|
||||
|
||||
foreach ( $this->get_taxes() as $tax ) {
|
||||
if ( $tax[ 'compound' ] ) {
|
||||
$has_compound_tax = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $has_compound_tax ) {
|
||||
if ( $subtotal = $this->get_subtotal_to_display( true ) ) {
|
||||
$total_rows['subtotal'] = array(
|
||||
'label' => __( 'Subtotal:', 'woocommerce' ),
|
||||
'value' => $subtotal
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $this->get_taxes() as $tax ) {
|
||||
if ( ! $tax[ 'compound' ] )
|
||||
continue;
|
||||
|
||||
if ( ( $tax[ 'tax_amount' ] + $tax[ 'shipping_tax_amount' ] ) == 0 )
|
||||
continue;
|
||||
|
||||
$total_rows[ sanitize_title( $tax[ 'name' ] ) ] = array(
|
||||
'label' => $tax[ 'name' ] . ':',
|
||||
'value' => woocommerce_price( ( $tax[ 'tax_amount' ] + $tax[ 'shipping_tax_amount' ] ) )
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$total_rows['tax'] = array(
|
||||
'label' => $woocommerce->countries->tax_or_vat(),
|
||||
'value' => woocommerce_price( $this->get_total_tax() )
|
||||
|
||||
$total_rows[ sanitize_title( $tax[ 'name' ] ) ] = array(
|
||||
'label' => isset( $tax[ 'label' ] ) ? $tax[ 'label' ] : $tax[ 'name' ] . ':',
|
||||
'value' => woocommerce_price( ( $tax[ 'tax_amount' ] + $tax[ 'shipping_tax_amount' ] ) )
|
||||
);
|
||||
}
|
||||
|
||||
} elseif ( get_option( 'woocommerce_display_cart_taxes_if_zero' ) == 'yes' ) {
|
||||
|
||||
if ( $has_compound_tax ) {
|
||||
if ( $subtotal = $this->get_subtotal_to_display( true ) ) {
|
||||
$total_rows['subtotal'] = array(
|
||||
'label' => __( 'Subtotal:', 'woocommerce' ),
|
||||
'value' => $subtotal
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $this->get_taxes() as $tax ) {
|
||||
if ( ! $tax[ 'compound' ] )
|
||||
continue;
|
||||
|
||||
$total_rows[ sanitize_title( $tax[ 'name' ] ) ] = array(
|
||||
'label' => isset( $tax[ 'label' ] ) ? $tax[ 'label' ] : $tax[ 'name' ] . ':',
|
||||
'value' => woocommerce_price( ( $tax[ 'tax_amount' ] + $tax[ 'shipping_tax_amount' ] ) )
|
||||
);
|
||||
}
|
||||
|
||||
} elseif ( $this->get_total_tax() > 0 ) {
|
||||
$total_rows['tax'] = array(
|
||||
'label' => $woocommerce->countries->tax_or_vat(),
|
||||
'value' => _x( 'N/A', 'Relating to tax', 'woocommerce' )
|
||||
'value' => woocommerce_price( $this->get_total_tax() )
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $this->get_order_discount() > 0 )
|
||||
|
@ -972,37 +983,33 @@ class WC_Order {
|
|||
'label' => __( 'Order Total:', 'woocommerce' ),
|
||||
'value' => $this->get_formatted_order_total()
|
||||
);
|
||||
|
||||
// Tax for inclusive prices
|
||||
if ( ! $this->display_cart_ex_tax && $this->prices_include_tax ) {
|
||||
|
||||
$tax_string_array = array();
|
||||
|
||||
if ( $this->get_total_tax() > 0 ) {
|
||||
|
||||
if ( sizeof( $this->get_taxes() ) > 0 ) {
|
||||
|
||||
foreach ( $this->get_taxes() as $tax ) {
|
||||
|
||||
if ( ( $tax[ 'tax_amount' ] + $tax[ 'shipping_tax_amount' ] ) == 0 )
|
||||
continue;
|
||||
|
||||
$tax_string_array[] = sprintf( '%s %s', woocommerce_price( ( $tax[ 'tax_amount' ] + $tax[ 'shipping_tax_amount' ] ) ), $tax[ 'name' ] );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$tax_string_array[] = sprintf( '%s %s', woocommerce_price( $this->get_total_tax() ), $woocommerce->countries->tax_or_vat() );
|
||||
|
||||
if ( $refund_total = $this->get_refund_total() ) {
|
||||
$total_rows['order_refund_total'] = array(
|
||||
'label' => __( 'Refund total:', 'woocommerce' ),
|
||||
'value' => '-' . $refund_total,
|
||||
);
|
||||
}
|
||||
|
||||
// Tax for inclusive prices
|
||||
if ( $this->tax_display_cart == 'incl' ) {
|
||||
|
||||
$tax_string_array = array();
|
||||
|
||||
if ( sizeof( $this->get_taxes() ) > 0 ) {
|
||||
|
||||
foreach ( $this->get_taxes() as $tax ) {
|
||||
|
||||
$tax_string_array[] = sprintf( '%s %s', woocommerce_price( ( $tax[ 'tax_amount' ] + $tax[ 'shipping_tax_amount' ] ) ), $tax[ 'name' ] );
|
||||
}
|
||||
|
||||
} elseif ( get_option( 'woocommerce_display_cart_taxes_if_zero' ) == 'yes' ) {
|
||||
|
||||
$tax_string_array[] = sprintf( '%s %s', woocommerce_price( 0 ), $woocommerce->countries->tax_or_vat() );
|
||||
|
||||
} elseif ( $this->get_total_tax() > 0 ) {
|
||||
|
||||
$tax_string_array[] = sprintf( '%s %s', woocommerce_price( $this->get_total_tax() ), $woocommerce->countries->tax_or_vat() );
|
||||
|
||||
}
|
||||
|
||||
$total_rows['order_total']['value'] .= ' ' . sprintf( __( '(Includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) );
|
||||
|
||||
$total_rows['order_total']['value'] .= ' ' . sprintf( __( '(Includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) );
|
||||
}
|
||||
|
||||
return apply_filters( 'woocommerce_get_order_item_totals', $total_rows, $this );
|
||||
|
@ -1024,7 +1031,7 @@ class WC_Order {
|
|||
function email_order_items_table( $show_download_links = false, $show_sku = false, $show_purchase_note = false, $show_image = false, $image_size = array( 32, 32 ), $plain_text = false ) {
|
||||
|
||||
ob_start();
|
||||
|
||||
|
||||
$template = $plain_text ? 'emails/plain/email-order-items.php' : 'emails/email-order-items.php';
|
||||
|
||||
woocommerce_get_template( $template, array(
|
||||
|
@ -1044,7 +1051,7 @@ class WC_Order {
|
|||
|
||||
/**
|
||||
* Checks if product download is permitted
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -1116,7 +1123,7 @@ class WC_Order {
|
|||
global $wpdb;
|
||||
|
||||
$download_file = $variation_id > 0 ? $variation_id : $product_id;
|
||||
$_product = new WC_Product( $download_file );
|
||||
$_product = get_product( $download_file );
|
||||
|
||||
$user_email = $this->billing_email;
|
||||
|
||||
|
@ -1150,9 +1157,13 @@ class WC_Order {
|
|||
|
||||
$is_customer_note = intval( $is_customer_note );
|
||||
|
||||
if ( isset( $_SERVER['HTTP_HOST'] ) )
|
||||
$comment_author_email = sanitize_email( strtolower( __( 'WooCommerce', 'woocommerce' ) ) . '@' . str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) );
|
||||
else
|
||||
$comment_author_email = sanitize_email( strtolower( __( 'WooCommerce', 'woocommerce' ) ) . '@noreply.com' );
|
||||
|
||||
$comment_post_ID = $this->id;
|
||||
$comment_author = __( 'WooCommerce', 'woocommerce' );
|
||||
$comment_author_email = sanitize_email( strtolower( __( 'WooCommerce', 'woocommerce' ) ) . '@' . str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) );
|
||||
$comment_author_url = '';
|
||||
$comment_content = $note;
|
||||
$comment_agent = 'WooCommerce';
|
||||
|
@ -1181,12 +1192,12 @@ class WC_Order {
|
|||
*/
|
||||
function update_status( $new_status_slug, $note = '' ) {
|
||||
|
||||
if ( $note )
|
||||
if ( $note )
|
||||
$note .= ' ';
|
||||
|
||||
$old_status = get_term_by( 'slug', sanitize_title( $this->status ), 'shop_order_status' );
|
||||
$new_status = get_term_by( 'slug', sanitize_title( $new_status_slug ), 'shop_order_status' );
|
||||
|
||||
|
||||
if ( $new_status ) {
|
||||
|
||||
wp_set_object_terms( $this->id, array( $new_status->slug ), 'shop_order_status', false );
|
||||
|
@ -1197,7 +1208,7 @@ class WC_Order {
|
|||
do_action( 'woocommerce_order_status_' . $new_status->slug, $this->id );
|
||||
do_action( 'woocommerce_order_status_' . $this->status . '_to_' . $new_status->slug, $this->id );
|
||||
do_action( 'woocommerce_order_status_changed', $this->id, $this->status, $new_status->slug );
|
||||
|
||||
|
||||
$this->add_order_note( $note . sprintf( __( 'Order status changed from %s to %s.', 'woocommerce' ), __( $old_status->name, 'woocommerce' ), __( $new_status->name, 'woocommerce' ) ) );
|
||||
|
||||
// Record the completed date of the order
|
||||
|
@ -1217,6 +1228,7 @@ class WC_Order {
|
|||
if ( $new_status->slug == 'cancelled' )
|
||||
$this->decrease_coupon_usage_counts();
|
||||
|
||||
$this->status = $new_status->slug;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1234,13 +1246,35 @@ class WC_Order {
|
|||
*/
|
||||
function cancel_order( $note = '' ) {
|
||||
global $woocommerce;
|
||||
|
||||
|
||||
unset( $woocommerce->session->order_awaiting_payment );
|
||||
|
||||
$this->update_status('cancelled', $note);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* refund_order function.
|
||||
*
|
||||
* @access public
|
||||
* @param bool $use_gateway (default: false)
|
||||
* @return void
|
||||
*/
|
||||
function refund_order( $use_gateway = false ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* refund_line_item function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $item_id
|
||||
* @param bool $use_gateway (default: false)
|
||||
* @return void
|
||||
*/
|
||||
function refund_line_item( $item_id, $use_gateway = false ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* When a payment is complete this function is called
|
||||
|
@ -1256,7 +1290,7 @@ class WC_Order {
|
|||
*/
|
||||
function payment_complete() {
|
||||
global $woocommerce;
|
||||
|
||||
|
||||
unset( $woocommerce->session->order_awaiting_payment );
|
||||
|
||||
if ( $this->status == 'on-hold' || $this->status == 'pending' || $this->status == 'failed' ) {
|
||||
|
@ -1264,9 +1298,9 @@ class WC_Order {
|
|||
$order_needs_processing = true;
|
||||
|
||||
if ( sizeof( $this->get_items() ) > 0 ) {
|
||||
|
||||
|
||||
foreach( $this->get_items() as $item ) {
|
||||
|
||||
|
||||
if ( $item['product_id'] > 0 ) {
|
||||
|
||||
$_product = $this->get_product_from_item( $item );
|
||||
|
@ -1331,16 +1365,21 @@ class WC_Order {
|
|||
|
||||
|
||||
/**
|
||||
* Increase applied coupon counts
|
||||
* Get coupon codes only.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function get_used_coupons() {
|
||||
|
||||
$coupons = get_post_meta( $this->id, 'coupons', true );
|
||||
$codes = array();
|
||||
$coupons = $this->get_items( 'coupon' );
|
||||
|
||||
return array_map( 'trim', explode( ',', $coupons ) );
|
||||
foreach ( $coupons as $item_id => $item ) {
|
||||
$codes[] = trim( $item['name'] );
|
||||
}
|
||||
|
||||
return $codes;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1540,16 +1579,16 @@ class WC_Order_Item_Meta {
|
|||
global $woocommerce;
|
||||
|
||||
if ( ! empty( $this->meta ) ) {
|
||||
|
||||
|
||||
$output = $flat ? '' : '<dl class="variation">';
|
||||
|
||||
$meta_list = array();
|
||||
|
||||
foreach ( $this->meta as $meta_key => $meta_value ) {
|
||||
|
||||
if ( ! $meta_value || ( ! empty( $hideprefix ) && substr( $meta_key, 0, 1 ) == $hideprefix ) )
|
||||
|
||||
if ( ! $meta_value || ( ! empty( $hideprefix ) && substr( $meta_key, 0, 1 ) == $hideprefix ) )
|
||||
continue;
|
||||
|
||||
|
||||
// Get first value
|
||||
$meta_value = $meta_value[0];
|
||||
|
||||
|
@ -1574,12 +1613,12 @@ class WC_Order_Item_Meta {
|
|||
else
|
||||
$output .= implode( '', $meta_list );
|
||||
|
||||
if ( ! $flat )
|
||||
if ( ! $flat )
|
||||
$output .= '</dl>';
|
||||
|
||||
if ( $return )
|
||||
return $output;
|
||||
else
|
||||
if ( $return )
|
||||
return $output;
|
||||
else
|
||||
echo $output;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/**
|
||||
* External Product Class
|
||||
*
|
||||
* External products cannot be bought; they link offsite. Extends simple products.
|
||||
*
|
||||
* @class WC_Product_External
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/Classes/Products
|
||||
* @author WooThemes
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
class WC_Product_External extends WC_Product_Simple {
|
||||
|
||||
/** @var string URL to external product. */
|
||||
var $product_url;
|
||||
|
||||
/** @var string Text for the buy/link button. */
|
||||
var $button_text;
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $product
|
||||
* @param array $args Contains arguments to set up this product
|
||||
*/
|
||||
function __construct( $product, $args ) {
|
||||
|
||||
parent::__construct( $product, $args );
|
||||
|
||||
$this->product_type = 'external';
|
||||
$this->downloadable = 'no';
|
||||
$this->virtual = 'no';
|
||||
$this->stock = '';
|
||||
$this->stock_status = 'instock';
|
||||
$this->manage_stock = 'no';
|
||||
$this->weight = '';
|
||||
$this->length = '';
|
||||
$this->width = '';
|
||||
$this->height = '';
|
||||
|
||||
$this->load_product_data( array(
|
||||
'product_url' => '',
|
||||
'button_text' => 'no'
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns false if the product cannot be bought.
|
||||
*
|
||||
* @access public
|
||||
* @return cool
|
||||
*/
|
||||
function is_purchasable() {
|
||||
return apply_filters( 'woocommerce_is_purchasable', false, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* get_product_url function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function get_product_url() {
|
||||
return $this->product_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* get_button_text function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function get_button_text() {
|
||||
return $this->button_text ? $this->button_text : __( 'Buy product', 'woocommerce' );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Product Factory Class
|
||||
*
|
||||
* The WooCommerce product factory creating the right product object
|
||||
*
|
||||
* @class WC_Product_Factory
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/Classes
|
||||
* @author WooThemes
|
||||
*/
|
||||
class WC_Product_Factory {
|
||||
|
||||
/**
|
||||
* get_product function.
|
||||
*
|
||||
* @access public
|
||||
* @param bool $the_product (default: false)
|
||||
* @param array $args (default: array())
|
||||
* @return WC_Product_Simple
|
||||
*/
|
||||
public function get_product( $the_product = false, $args = array() ) {
|
||||
global $post;
|
||||
|
||||
if ( false === $the_product ) {
|
||||
$the_product = $post;
|
||||
} elseif ( is_numeric( $the_product ) ) {
|
||||
$the_product = get_post( $the_product );
|
||||
}
|
||||
|
||||
if ( ! $the_product )
|
||||
return false;
|
||||
|
||||
$product_id = absint( $the_product->ID );
|
||||
$post_type = $the_product->post_type;
|
||||
|
||||
if ( isset( $args['product_type'] ) ) {
|
||||
$product_type = $args['product_type'];
|
||||
} elseif ( 'product_variation' == $post_type ) {
|
||||
$product_type = 'variation';
|
||||
} else {
|
||||
$terms = get_the_terms( $product_id, 'product_type' );
|
||||
$product_type = ! empty( $terms ) && isset( current( $terms )->name ) ? sanitize_title( current( $terms )->name ) : 'simple';
|
||||
}
|
||||
|
||||
// Filter classname so that the class can be overridden if extended.
|
||||
$classname = apply_filters( 'woocommerce_product_class', 'WC_Product_' . ucfirst( $product_type ), $product_type, $post_type, $product_id );
|
||||
|
||||
if ( class_exists( $classname ) ) {
|
||||
return new $classname( $the_product, $args );
|
||||
} else {
|
||||
// Use simple
|
||||
return new WC_Product_Simple( $the_product, $args );
|
||||
}
|
||||
}
|
||||
}
|