[Product CRUD] Product crud admin use getters (#12196)
* Initial props * Work on admin saving * Set/get attributes * Atom was moaning about this before but no longer. * Update get_shipping_class * WC_Product_Attribute * Use getter in admin panel * Fix attribute saving * Move settings into new files * Refactor panels and use getters * Use getters for variation panel * Revert save variation changes for now * Add todos * Fix downloads
This commit is contained in:
parent
38703f1907
commit
5855170c5a
|
@ -1044,10 +1044,13 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
* @param $raw_downloads array of arrays with download data (name/file)
|
||||
*/
|
||||
public function set_downloads( $raw_downloads ) {
|
||||
$downloads = array();
|
||||
$errors = array();
|
||||
$downloads = array();
|
||||
$errors = array();
|
||||
$allowed_file_types = apply_filters( 'woocommerce_downloadable_file_allowed_mime_types', get_allowed_mime_types() );
|
||||
|
||||
foreach ( $raw_downloads as $raw_download ) {
|
||||
$file_name = wc_clean( $raw_download['name'] );
|
||||
|
||||
// Find type and file URL
|
||||
if ( 0 === strpos( $raw_download['file'], 'http' ) ) {
|
||||
$file_is = 'absolute';
|
||||
|
@ -1061,14 +1064,12 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
}
|
||||
|
||||
$file_name = wc_clean( $raw_download['name'] );
|
||||
$file_hash = md5( $file_url );
|
||||
|
||||
// Validate the file extension
|
||||
if ( in_array( $file_is, array( 'absolute', 'relative' ) ) ) {
|
||||
$file_type = wp_check_filetype( strtok( $file_url, '?' ), $allowed_file_types );
|
||||
$parsed_url = parse_url( $file_url, PHP_URL_PATH );
|
||||
$extension = pathinfo( $parsed_url, PATHINFO_EXTENSION );
|
||||
|
||||
if ( ! empty( $extension ) && ! in_array( $file_type['type'], $allowed_file_types ) ) {
|
||||
$errors[] = sprintf( __( 'The downloadable file %1$s cannot be used as it does not have an allowed file type. Allowed types include: %2$s', 'woocommerce' ), '<code>' . basename( $file_url ) . '</code>', '<code>' . implode( ', ', array_keys( $allowed_file_types ) ) . '</code>' );
|
||||
continue;
|
||||
|
@ -1083,12 +1084,12 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
}
|
||||
|
||||
if ( ! apply_filters( 'woocommerce_downloadable_file_exists', file_exists( $_file_url ), $file_url ) ) {
|
||||
$errors[] = sprintf( __( 'The downloadable file %1$s cannot be used as it does not have an allowed file type. Allowed types include: %2$s', 'woocommerce' ), '<code>' . basename( $file_url ) . '</code>', '<code>' . implode( ', ', array_keys( $allowed_file_types ) ) . '</code>' );
|
||||
$errors[] = sprintf( __( 'The downloadable file %s cannot be used as it does not exist on the server.', 'woocommerce' ), '<code>' . $file_url . '</code>' );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$downloads[ $file_hash ] = array(
|
||||
$downloads[ md5( $file_url ) ] = array(
|
||||
'name' => $file_name,
|
||||
'file' => $file_url,
|
||||
);
|
||||
|
@ -1194,7 +1195,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
'upsell_ids' => get_post_meta( $id, '_upsell_ids', true ),
|
||||
'cross_sell_ids' => get_post_meta( $id, '_crosssell_ids', true ),
|
||||
'parent_id' => $post_object->post_parent,
|
||||
'reviews_allowed' => $post_object->comment_status,
|
||||
'reviews_allowed' => 'open' === $post_object->comment_status,
|
||||
'purchase_note' => get_post_meta( $id, '_purchase_note', true ),
|
||||
'default_attributes' => get_post_meta( $id, '_default_attributes', true ),
|
||||
'menu_order' => $post_object->menu_order,
|
||||
|
@ -1203,6 +1204,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
'shipping_class_id' => current( $this->get_term_ids( 'product_shipping_class' ) ),
|
||||
'virtual' => get_post_meta( $id, '_virtual', true ),
|
||||
'downloadable' => get_post_meta( $id, '_downloadable', true ),
|
||||
'downloads' => array_filter( (array) get_post_meta( $id, '_downloadable_files', true ) ),
|
||||
) );
|
||||
if ( $this->is_on_sale() ) {
|
||||
$this->set_price( $this->get_sale_price() );
|
||||
|
@ -1261,7 +1263,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
'post_content' => $this->get_description(),
|
||||
'post_excerpt' => $this->get_short_description(),
|
||||
'post_parent' => $this->get_parent_id(),
|
||||
'comment_status' => $this->get_reviews_allowed(),
|
||||
'comment_status' => $this->get_reviews_allowed() ? 'open' : 'closed',
|
||||
'menu_order' => $this->get_menu_order(),
|
||||
'post_date' => date( 'Y-m-d H:i:s', $this->get_date_created() ),
|
||||
'post_date_gmt' => get_gmt_from_date( date( 'Y-m-d H:i:s', $this->get_date_created() ) ),
|
||||
|
@ -1289,7 +1291,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
'post_excerpt' => $this->get_short_description(),
|
||||
'post_title' => $this->get_name(),
|
||||
'post_parent' => $this->get_parent_id(),
|
||||
'comment_status' => $this->get_reviews_allowed(),
|
||||
'comment_status' => $this->get_reviews_allowed() ? 'open' : 'closed',
|
||||
'post_status' => $this->get_status() ? $this->get_status() : 'publish',
|
||||
'menu_order' => $this->get_menu_order(),
|
||||
);
|
||||
|
@ -1682,12 +1684,30 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the product has any child product.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has_child() {
|
||||
return 0 < count( $this->get_children() );
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Non-CRUD Getters
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the children IDs if applicable. Overridden by child classes.
|
||||
*
|
||||
* @return array of IDs
|
||||
*/
|
||||
public function get_children() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the price in html format.
|
||||
* @todo Should this be moved out of the classes?
|
||||
|
@ -1835,24 +1855,6 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
return apply_filters( 'woocommerce_product_gallery_attachment_ids', array_filter( array_filter( (array) explode( ',', $this->product_image_gallery ) ), 'wp_attachment_is_image' ), $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the children.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_children() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the product has any child product.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has_child() {
|
||||
return 0 < count( $this->get_children() );
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| @todo stock functions
|
||||
|
|
|
@ -25,28 +25,34 @@ class WC_Meta_Box_Product_Data {
|
|||
* @param WP_Post $post
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
global $post, $thepostid;
|
||||
|
||||
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
|
||||
global $post, $thepostid, $product_object;
|
||||
|
||||
$thepostid = $post->ID;
|
||||
$product_object = wc_get_product( $thepostid );
|
||||
$product_object = $thepostid ? wc_get_product( $thepostid ) : new WC_Product;
|
||||
|
||||
if ( $terms = wp_get_object_terms( $post->ID, 'product_type' ) ) {
|
||||
$product_type = sanitize_title( current( $terms )->name );
|
||||
} else {
|
||||
$product_type = apply_filters( 'default_product_type', 'simple' );
|
||||
}
|
||||
include( 'views/html-product-data-panel.php' );
|
||||
}
|
||||
|
||||
$type_box = '<label for="product-type"><select id="product-type" name="product-type"><optgroup label="' . esc_attr__( 'Product Type', 'woocommerce' ) . '">';
|
||||
/**
|
||||
* Show tab content/settings.
|
||||
*/
|
||||
private static function output_tabs() {
|
||||
global $post, $thepostid, $product_object;
|
||||
|
||||
foreach ( wc_get_product_types() as $value => $label ) {
|
||||
$type_box .= '<option value="' . esc_attr( $value ) . '" ' . selected( $product_type, $value, false ) . '>' . esc_html( $label ) . '</option>';
|
||||
}
|
||||
include( 'views/html-product-data-general.php' );
|
||||
include( 'views/html-product-data-inventory.php' );
|
||||
include( 'views/html-product-data-shipping.php' );
|
||||
include( 'views/html-product-data-linked-products.php' );
|
||||
include( 'views/html-product-data-attributes.php' );
|
||||
include( 'views/html-product-data-advanced.php' );
|
||||
}
|
||||
|
||||
$type_box .= '</optgroup></select></label>';
|
||||
|
||||
$product_type_options = apply_filters( 'product_type_options', array(
|
||||
/**
|
||||
* Return array of product type options.
|
||||
* @return array
|
||||
*/
|
||||
private static function get_product_type_options() {
|
||||
return apply_filters( 'product_type_options', array(
|
||||
'virtual' => array(
|
||||
'id' => '_virtual',
|
||||
'wrapper_class' => 'show_if_simple',
|
||||
|
@ -62,719 +68,74 @@ class WC_Meta_Box_Product_Data {
|
|||
'default' => 'no',
|
||||
),
|
||||
) );
|
||||
|
||||
foreach ( $product_type_options as $key => $option ) {
|
||||
$selected_value = get_post_meta( $post->ID, '_' . $key, true );
|
||||
|
||||
if ( '' == $selected_value && isset( $option['default'] ) ) {
|
||||
$selected_value = $option['default'];
|
||||
}
|
||||
|
||||
$type_box .= '<label for="' . esc_attr( $option['id'] ) . '" class="' . esc_attr( $option['wrapper_class'] ) . ' tips" data-tip="' . esc_attr( $option['description'] ) . '">' . esc_html( $option['label'] ) . ': <input type="checkbox" name="' . esc_attr( $option['id'] ) . '" id="' . esc_attr( $option['id'] ) . '" ' . checked( $selected_value, 'yes', false ) . ' /></label>';
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="panel-wrap product_data">
|
||||
|
||||
<span class="type_box hidden"> — <?php echo $type_box; ?></span>
|
||||
|
||||
<ul class="product_data_tabs wc-tabs">
|
||||
<?php
|
||||
$product_data_tabs = apply_filters( 'woocommerce_product_data_tabs', array(
|
||||
'general' => array(
|
||||
'label' => __( 'General', 'woocommerce' ),
|
||||
'target' => 'general_product_data',
|
||||
'class' => array( 'hide_if_grouped' ),
|
||||
),
|
||||
'inventory' => array(
|
||||
'label' => __( 'Inventory', 'woocommerce' ),
|
||||
'target' => 'inventory_product_data',
|
||||
'class' => array( 'show_if_simple', 'show_if_variable', 'show_if_grouped', 'show_if_external' ),
|
||||
),
|
||||
'shipping' => array(
|
||||
'label' => __( 'Shipping', 'woocommerce' ),
|
||||
'target' => 'shipping_product_data',
|
||||
'class' => array( 'hide_if_virtual', 'hide_if_grouped', 'hide_if_external' ),
|
||||
),
|
||||
'linked_product' => array(
|
||||
'label' => __( 'Linked Products', 'woocommerce' ),
|
||||
'target' => 'linked_product_data',
|
||||
'class' => array(),
|
||||
),
|
||||
'attribute' => array(
|
||||
'label' => __( 'Attributes', 'woocommerce' ),
|
||||
'target' => 'product_attributes',
|
||||
'class' => array(),
|
||||
),
|
||||
'variations' => array(
|
||||
'label' => __( 'Variations', 'woocommerce' ),
|
||||
'target' => 'variable_product_options',
|
||||
'class' => array( 'variations_tab', 'show_if_variable' ),
|
||||
),
|
||||
'advanced' => array(
|
||||
'label' => __( 'Advanced', 'woocommerce' ),
|
||||
'target' => 'advanced_product_data',
|
||||
'class' => array(),
|
||||
),
|
||||
) );
|
||||
|
||||
foreach ( $product_data_tabs as $key => $tab ) {
|
||||
?><li class="<?php echo $key; ?>_options <?php echo $key; ?>_tab <?php echo implode( ' ' , (array) $tab['class'] ); ?>">
|
||||
<a href="#<?php echo $tab['target']; ?>"><?php echo esc_html( $tab['label'] ); ?></a>
|
||||
</li><?php
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_product_write_panel_tabs' );
|
||||
?>
|
||||
</ul>
|
||||
<div id="general_product_data" class="panel woocommerce_options_panel"><?php
|
||||
|
||||
echo '<div class="options_group show_if_external">';
|
||||
|
||||
// External URL
|
||||
woocommerce_wp_text_input( array( 'id' => '_product_url', 'label' => __( 'Product URL', 'woocommerce' ), 'placeholder' => 'http://', 'description' => __( 'Enter the external URL to the product.', 'woocommerce' ) ) );
|
||||
|
||||
// Button text
|
||||
woocommerce_wp_text_input( array( 'id' => '_button_text', 'label' => __( 'Button text', 'woocommerce' ), 'placeholder' => _x( 'Buy product', 'placeholder', 'woocommerce' ), 'description' => __( 'This text will be shown on the button linking to the external product.', 'woocommerce' ) ) );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="options_group pricing show_if_simple show_if_external hidden">';
|
||||
|
||||
// Price
|
||||
woocommerce_wp_text_input( array( 'id' => '_regular_price', 'label' => __( 'Regular price', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')', 'data_type' => 'price' ) );
|
||||
|
||||
// Special Price
|
||||
woocommerce_wp_text_input( array( 'id' => '_sale_price', 'data_type' => 'price', 'label' => __( 'Sale price', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')', 'description' => '<a href="#" class="sale_schedule">' . __( 'Schedule', 'woocommerce' ) . '</a>' ) );
|
||||
|
||||
// Special Price date range
|
||||
$sale_price_dates_from = ( $date = get_post_meta( $thepostid, '_sale_price_dates_from', true ) ) ? date_i18n( 'Y-m-d', $date ) : '';
|
||||
$sale_price_dates_to = ( $date = get_post_meta( $thepostid, '_sale_price_dates_to', true ) ) ? date_i18n( 'Y-m-d', $date ) : '';
|
||||
|
||||
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="' . esc_attr( $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="' . esc_attr( $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>' . wc_help_tip( __( 'The sale will end at the beginning of the set date.', 'woocommerce' ) ) . '
|
||||
</p>';
|
||||
|
||||
do_action( 'woocommerce_product_options_pricing' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="options_group show_if_downloadable hidden">';
|
||||
|
||||
?>
|
||||
<div class="form-field downloadable_files">
|
||||
<label><?php _e( 'Downloadable files', 'woocommerce' ); ?></label>
|
||||
<table class="widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="sort"> </th>
|
||||
<th><?php _e( 'Name', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the name of the download shown to the customer.', 'woocommerce' ) ); ?></th>
|
||||
<th colspan="2"><?php _e( 'File URL', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the URL or absolute path to the file which customers will get access to. URLs entered here should already be encoded.', 'woocommerce' ) ); ?></th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$downloadable_files = get_post_meta( $post->ID, '_downloadable_files', true );
|
||||
|
||||
if ( $downloadable_files ) {
|
||||
foreach ( $downloadable_files as $key => $file ) {
|
||||
include( 'views/html-product-download.php' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="5">
|
||||
<a href="#" class="button insert" data-row="<?php
|
||||
$file = array(
|
||||
'file' => '',
|
||||
'name' => '',
|
||||
);
|
||||
ob_start();
|
||||
include( 'views/html-product-download.php' );
|
||||
echo esc_attr( ob_get_clean() );
|
||||
?>"><?php _e( 'Add File', 'woocommerce' ); ?></a>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
// 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' ),
|
||||
'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' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'step' => '1',
|
||||
'min' => '0',
|
||||
),
|
||||
) );
|
||||
|
||||
// Download Type
|
||||
woocommerce_wp_select( array(
|
||||
'id' => '_download_type',
|
||||
'label' => __( 'Download type', 'woocommerce' ),
|
||||
'description' => sprintf( __( 'Choose a download type - this controls the <a href="%s">schema</a>.', 'woocommerce' ), 'http://schema.org/' ),
|
||||
'options' => array(
|
||||
'' => __( 'Standard Product', 'woocommerce' ),
|
||||
'application' => __( 'Application/Software', 'woocommerce' ),
|
||||
'music' => __( 'Music', 'woocommerce' ),
|
||||
),
|
||||
) );
|
||||
|
||||
do_action( 'woocommerce_product_options_downloads' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
if ( wc_tax_enabled() ) {
|
||||
|
||||
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' => _x( 'None', 'Tax status', 'woocommerce' ),
|
||||
),
|
||||
'desc_tip' => 'true',
|
||||
'description' => __( 'Define whether or not the entire product is taxable, or just the cost of shipping it.', 'woocommerce' ),
|
||||
) );
|
||||
|
||||
$tax_classes = WC_Tax::get_tax_classes();
|
||||
$classes_options = array();
|
||||
$classes_options[''] = __( 'Standard', 'woocommerce' );
|
||||
|
||||
if ( ! empty( $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,
|
||||
'desc_tip' => 'true',
|
||||
'description' => __( 'Choose a tax class for this product. Tax classes are used to apply different tax rates specific to certain types of product.', 'woocommerce' ),
|
||||
) );
|
||||
|
||||
do_action( 'woocommerce_product_options_tax' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_product_options_general_product_data' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div id="inventory_product_data" class="panel woocommerce_options_panel hidden">
|
||||
|
||||
<?php
|
||||
|
||||
echo '<div class="options_group">';
|
||||
|
||||
// SKU
|
||||
if ( wc_product_sku_enabled() ) {
|
||||
woocommerce_wp_text_input( array( 'id' => '_sku', 'label' => '<abbr title="' . __( 'Stock Keeping Unit', 'woocommerce' ) . '">' . __( 'SKU', 'woocommerce' ) . '</abbr>', 'desc_tip' => 'true', 'description' => __( 'SKU refers to a Stock-keeping unit, a unique identifier for each distinct product and service that can be purchased.', 'woocommerce' ) ) );
|
||||
} else {
|
||||
echo '<input type="hidden" name="_sku" value="' . esc_attr( get_post_meta( $thepostid, '_sku', true ) ) . '" />';
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_product_options_sku' );
|
||||
|
||||
if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) {
|
||||
|
||||
// manage stock
|
||||
woocommerce_wp_checkbox( array( 'id' => '_manage_stock', 'wrapper_class' => 'show_if_simple show_if_variable', 'label' => __( 'Manage stock?', 'woocommerce' ), 'description' => __( 'Enable stock management at product level', 'woocommerce' ) ) );
|
||||
|
||||
do_action( 'woocommerce_product_options_stock' );
|
||||
|
||||
echo '<div class="stock_fields show_if_simple show_if_variable">';
|
||||
|
||||
// Stock
|
||||
woocommerce_wp_text_input( array(
|
||||
'id' => '_stock',
|
||||
'label' => __( 'Stock quantity', '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',
|
||||
),
|
||||
'data_type' => 'stock',
|
||||
) );
|
||||
|
||||
// Backorders?
|
||||
woocommerce_wp_select( array(
|
||||
'id' => '_backorders',
|
||||
'label' => __( 'Allow backorders?', 'woocommerce' ),
|
||||
'options' => array(
|
||||
'no' => __( 'Do not allow', 'woocommerce' ),
|
||||
'notify' => __( 'Allow, but notify customer', 'woocommerce' ),
|
||||
'yes' => __( 'Allow', 'woocommerce' ),
|
||||
),
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'If managing stock, this controls whether or not backorders are allowed. If enabled, stock quantity can go below 0.', 'woocommerce' ),
|
||||
) );
|
||||
|
||||
do_action( 'woocommerce_product_options_stock_fields' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
// Stock status
|
||||
woocommerce_wp_select( array(
|
||||
'id' => '_stock_status',
|
||||
'wrapper_class' => 'hide_if_variable hide_if_external',
|
||||
'label' => __( 'Stock status', 'woocommerce' ),
|
||||
'options' => array(
|
||||
'instock' => __( 'In stock', 'woocommerce' ),
|
||||
'outofstock' => __( 'Out of stock', 'woocommerce' ),
|
||||
),
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ),
|
||||
) );
|
||||
|
||||
do_action( 'woocommerce_product_options_stock_status' );
|
||||
|
||||
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>';
|
||||
|
||||
do_action( 'woocommerce_product_options_inventory_product_data' );
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="shipping_product_data" class="panel woocommerce_options_panel hidden">
|
||||
|
||||
<?php
|
||||
|
||||
echo '<div class="options_group">';
|
||||
|
||||
// Weight
|
||||
if ( wc_product_weight_enabled() ) {
|
||||
woocommerce_wp_text_input( array( 'id' => '_weight', 'label' => __( 'Weight', 'woocommerce' ) . ' (' . get_option( 'woocommerce_weight_unit' ) . ')', 'placeholder' => wc_format_localized_decimal( 0 ), 'desc_tip' => 'true', 'description' => __( 'Weight in decimal form', 'woocommerce' ), 'type' => 'text', 'data_type' => 'decimal' ) );
|
||||
}
|
||||
|
||||
// Size fields
|
||||
if ( wc_product_dimensions_enabled() ) {
|
||||
?><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 esc_attr_e( 'Length', 'woocommerce' ); ?>" class="input-text wc_input_decimal" size="6" type="text" name="_length" value="<?php echo esc_attr( wc_format_localized_decimal( get_post_meta( $thepostid, '_length', true ) ) ); ?>" />
|
||||
<input placeholder="<?php esc_attr_e( 'Width', 'woocommerce' ); ?>" class="input-text wc_input_decimal" size="6" type="text" name="_width" value="<?php echo esc_attr( wc_format_localized_decimal( get_post_meta( $thepostid, '_width', true ) ) ); ?>" />
|
||||
<input placeholder="<?php esc_attr_e( 'Height', 'woocommerce' ); ?>" class="input-text wc_input_decimal last" size="6" type="text" name="_height" value="<?php echo esc_attr( wc_format_localized_decimal( get_post_meta( $thepostid, '_height', true ) ) ); ?>" />
|
||||
</span>
|
||||
<?php echo wc_help_tip( __( 'LxWxH in decimal form', 'woocommerce' ) ); ?>
|
||||
</p><?php
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_product_options_dimensions' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="options_group">';
|
||||
|
||||
// Shipping Class
|
||||
$classes = get_the_terms( $thepostid, 'product_shipping_class' );
|
||||
if ( $classes && ! is_wp_error( $classes ) ) {
|
||||
$current_shipping_class = current( $classes )->term_id;
|
||||
} else {
|
||||
$current_shipping_class = '';
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'taxonomy' => 'product_shipping_class',
|
||||
'hide_empty' => 0,
|
||||
'show_option_none' => __( 'No shipping class', 'woocommerce' ),
|
||||
'name' => 'product_shipping_class',
|
||||
'id' => 'product_shipping_class',
|
||||
'selected' => $current_shipping_class,
|
||||
'class' => 'select short',
|
||||
);
|
||||
?><p class="form-field dimensions_field"><label for="product_shipping_class"><?php _e( 'Shipping class', 'woocommerce' ); ?></label> <?php wp_dropdown_categories( $args ); ?> <?php echo wc_help_tip( __( 'Shipping classes are used by certain shipping methods to group similar products.', 'woocommerce' ) ); ?></p><?php
|
||||
|
||||
do_action( 'woocommerce_product_options_shipping' );
|
||||
|
||||
echo '</div>';
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="product_attributes" class="panel wc-metaboxes-wrapper hidden">
|
||||
<div class="toolbar toolbar-top">
|
||||
<span class="expand-close">
|
||||
<a href="#" class="expand_all"><?php _e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php _e( 'Close', 'woocommerce' ); ?></a>
|
||||
</span>
|
||||
<select name="attribute_taxonomy" class="attribute_taxonomy">
|
||||
<option value=""><?php _e( 'Custom product attribute', 'woocommerce' ); ?></option>
|
||||
<?php
|
||||
global $wc_product_attributes;
|
||||
|
||||
// Array of defined attribute taxonomies
|
||||
$attribute_taxonomies = wc_get_attribute_taxonomies();
|
||||
|
||||
if ( ! empty( $attribute_taxonomies ) ) {
|
||||
foreach ( $attribute_taxonomies as $tax ) {
|
||||
$attribute_taxonomy_name = wc_attribute_taxonomy_name( $tax->attribute_name );
|
||||
$label = $tax->attribute_label ? $tax->attribute_label : $tax->attribute_name;
|
||||
echo '<option value="' . esc_attr( $attribute_taxonomy_name ) . '">' . esc_html( $label ) . '</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<button type="button" class="button add_attribute"><?php _e( 'Add', 'woocommerce' ); ?></button>
|
||||
</div>
|
||||
<div class="product_attributes wc-metaboxes">
|
||||
<?php
|
||||
// Product attributes - taxonomies and custom, ordered, with visibility and variation attributes set
|
||||
$attributes = $product_object->get_attributes();
|
||||
$i = -1;
|
||||
|
||||
foreach ( $attributes as $attribute ) {
|
||||
$i++;
|
||||
$metabox_class = array();
|
||||
|
||||
if ( $attribute->is_taxonomy() ) {
|
||||
$metabox_class[] = 'taxonomy';
|
||||
$metabox_class[] = $attribute->get_name();
|
||||
}
|
||||
|
||||
include( 'views/html-product-attribute.php' );
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<span class="expand-close">
|
||||
<a href="#" class="expand_all"><?php _e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php _e( 'Close', 'woocommerce' ); ?></a>
|
||||
</span>
|
||||
<button type="button" class="button save_attributes button-primary"><?php _e( 'Save attributes', 'woocommerce' ); ?></button>
|
||||
</div>
|
||||
<?php do_action( 'woocommerce_product_options_attributes' ); ?>
|
||||
</div>
|
||||
<div id="linked_product_data" class="panel woocommerce_options_panel hidden">
|
||||
|
||||
<div class="options_group">
|
||||
<p class="form-field">
|
||||
<label for="upsell_ids"><?php _e( 'Up-sells', 'woocommerce' ); ?></label>
|
||||
<input type="hidden" class="wc-product-search" style="width: 50%;" id="upsell_ids" name="upsell_ids" data-placeholder="<?php esc_attr_e( 'Search for a product…', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products" data-multiple="true" data-exclude="<?php echo intval( $post->ID ); ?>" data-selected="<?php
|
||||
$product_ids = array_filter( array_map( 'absint', (array) get_post_meta( $post->ID, '_upsell_ids', true ) ) );
|
||||
$json_ids = array();
|
||||
|
||||
foreach ( $product_ids as $product_id ) {
|
||||
$product = wc_get_product( $product_id );
|
||||
if ( is_object( $product ) ) {
|
||||
$json_ids[ $product_id ] = wp_kses_post( html_entity_decode( $product->get_formatted_name(), ENT_QUOTES, get_bloginfo( 'charset' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
echo esc_attr( json_encode( $json_ids ) );
|
||||
?>" value="<?php echo implode( ',', array_keys( $json_ids ) ); ?>" /> <?php echo wc_help_tip( __( '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' ) ); ?>
|
||||
</p>
|
||||
|
||||
<p class="form-field">
|
||||
<label for="crosssell_ids"><?php _e( 'Cross-sells', 'woocommerce' ); ?></label>
|
||||
<input type="hidden" class="wc-product-search" style="width: 50%;" id="crosssell_ids" name="crosssell_ids" data-placeholder="<?php esc_attr_e( 'Search for a product…', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products" data-multiple="true" data-exclude="<?php echo intval( $post->ID ); ?>" data-selected="<?php
|
||||
$product_ids = array_filter( array_map( 'absint', (array) get_post_meta( $post->ID, '_crosssell_ids', true ) ) );
|
||||
$json_ids = array();
|
||||
|
||||
foreach ( $product_ids as $product_id ) {
|
||||
$product = wc_get_product( $product_id );
|
||||
if ( is_object( $product ) ) {
|
||||
$json_ids[ $product_id ] = wp_kses_post( html_entity_decode( $product->get_formatted_name(), ENT_QUOTES, get_bloginfo( 'charset' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
echo esc_attr( json_encode( $json_ids ) );
|
||||
?>" value="<?php echo implode( ',', array_keys( $json_ids ) ); ?>" /> <?php echo wc_help_tip( __( 'Cross-sells are products which you promote in the cart, based on the current product.', 'woocommerce' ) ); ?>
|
||||
</p>
|
||||
|
||||
<p class="form-field show_if_grouped">
|
||||
<label for="grouped_products"><?php _e( 'Grouped products', 'woocommerce' ); ?></label>
|
||||
<input type="hidden" class="wc-product-search" style="width: 50%;" id="grouped_products" name="grouped_products" data-placeholder="<?php esc_attr_e( 'Search for a product…', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products" data-multiple="true" data-exclude="<?php echo intval( $post->ID ); ?>" data-selected="<?php
|
||||
$product_ids = array_filter( array_map( 'absint', (array) get_post_meta( $post->ID, '_children', true ) ) );
|
||||
$json_ids = array();
|
||||
|
||||
foreach ( $product_ids as $product_id ) {
|
||||
$product = wc_get_product( $product_id );
|
||||
if ( is_object( $product ) ) {
|
||||
$json_ids[ $product_id ] = wp_kses_post( html_entity_decode( $product->get_formatted_name(), ENT_QUOTES, get_bloginfo( 'charset' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
echo esc_attr( json_encode( $json_ids ) );
|
||||
?>" value="<?php echo implode( ',', array_keys( $json_ids ) ); ?>" /> <?php echo wc_help_tip( __( 'This lets you choose which products are part of this group.', 'woocommerce' ) ); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php do_action( 'woocommerce_product_options_related' ); ?>
|
||||
</div>
|
||||
|
||||
<div id="advanced_product_data" class="panel woocommerce_options_panel hidden">
|
||||
|
||||
<div class="options_group hide_if_external">
|
||||
<?php
|
||||
// Purchase note
|
||||
woocommerce_wp_textarea_input( array( 'id' => '_purchase_note', 'label' => __( 'Purchase note', 'woocommerce' ), 'desc_tip' => 'true', 'description' => __( 'Enter an optional note to send the customer after purchase.', 'woocommerce' ) ) );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="options_group">
|
||||
<?php
|
||||
// menu_order
|
||||
woocommerce_wp_text_input( array(
|
||||
'id' => 'menu_order',
|
||||
'label' => __( 'Menu order', 'woocommerce' ),
|
||||
'desc_tip' => 'true',
|
||||
'description' => __( 'Custom ordering position.', 'woocommerce' ),
|
||||
'value' => intval( $post->menu_order ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'step' => '1',
|
||||
),
|
||||
) );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="options_group reviews">
|
||||
<?php
|
||||
woocommerce_wp_checkbox( array( 'id' => 'comment_status', 'label' => __( 'Enable reviews', 'woocommerce' ), 'cbvalue' => 'open', 'value' => esc_attr( $post->comment_status ) ) );
|
||||
|
||||
do_action( 'woocommerce_product_options_reviews' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php do_action( 'woocommerce_product_options_advanced' ); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
self::output_variations();
|
||||
|
||||
do_action( 'woocommerce_product_data_panels' );
|
||||
do_action( 'woocommerce_product_write_panels' ); // _deprecated
|
||||
?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array of tabs to show.
|
||||
* @return array
|
||||
*/
|
||||
private static function get_product_data_tabs() {
|
||||
return apply_filters( 'woocommerce_product_data_tabs', array(
|
||||
'general' => array(
|
||||
'label' => __( 'General', 'woocommerce' ),
|
||||
'target' => 'general_product_data',
|
||||
'class' => array( 'hide_if_grouped' ),
|
||||
),
|
||||
'inventory' => array(
|
||||
'label' => __( 'Inventory', 'woocommerce' ),
|
||||
'target' => 'inventory_product_data',
|
||||
'class' => array( 'show_if_simple', 'show_if_variable', 'show_if_grouped', 'show_if_external' ),
|
||||
),
|
||||
'shipping' => array(
|
||||
'label' => __( 'Shipping', 'woocommerce' ),
|
||||
'target' => 'shipping_product_data',
|
||||
'class' => array( 'hide_if_virtual', 'hide_if_grouped', 'hide_if_external' ),
|
||||
),
|
||||
'linked_product' => array(
|
||||
'label' => __( 'Linked Products', 'woocommerce' ),
|
||||
'target' => 'linked_product_data',
|
||||
'class' => array(),
|
||||
),
|
||||
'attribute' => array(
|
||||
'label' => __( 'Attributes', 'woocommerce' ),
|
||||
'target' => 'product_attributes',
|
||||
'class' => array(),
|
||||
),
|
||||
'variations' => array(
|
||||
'label' => __( 'Variations', 'woocommerce' ),
|
||||
'target' => 'variable_product_options',
|
||||
'class' => array( 'variations_tab', 'show_if_variable' ),
|
||||
),
|
||||
'advanced' => array(
|
||||
'label' => __( 'Advanced', 'woocommerce' ),
|
||||
'target' => 'advanced_product_data',
|
||||
'class' => array(),
|
||||
),
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter callback for finding variation attributes.
|
||||
* @param WC_Product_Attribute $attribute
|
||||
* @return bool
|
||||
*/
|
||||
private static function filter_variation_attributes( $attribute ) {
|
||||
return true === $attribute->get_variation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show options for the variable product type.
|
||||
*/
|
||||
public static function output_variations() {
|
||||
global $post, $wpdb;
|
||||
|
||||
// Get attributes
|
||||
$attributes = maybe_unserialize( get_post_meta( $post->ID, '_product_attributes', true ) );
|
||||
|
||||
// See if any are set
|
||||
$variation_attribute_found = false;
|
||||
|
||||
if ( $attributes ) {
|
||||
foreach ( $attributes as $attribute ) {
|
||||
if ( ! empty( $attribute['is_variation'] ) ) {
|
||||
$variation_attribute_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
global $post, $wpdb, $product_object;
|
||||
|
||||
$variation_attributes = array_filter( $product_object->get_attributes(), array( __CLASS__, 'filter_variation_attributes' ) );
|
||||
$default_attributes = $product_object->get_default_attributes();
|
||||
$variations_count = absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'product_variation' AND post_status IN ('publish', 'private')", $post->ID ) ) );
|
||||
$variations_per_page = absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 15 ) );
|
||||
$variations_total_pages = ceil( $variations_count / $variations_per_page );
|
||||
?>
|
||||
<div id="variable_product_options" class="panel wc-metaboxes-wrapper hidden"><div id="variable_product_options_inner">
|
||||
|
||||
<?php if ( ! $variation_attribute_found ) : ?>
|
||||
|
||||
<div id="message" class="inline notice woocommerce-message">
|
||||
<p><?php _e( 'Before you can add a variation you need to add some variation attributes on the <strong>Attributes</strong> tab.', 'woocommerce' ); ?></p>
|
||||
<p>
|
||||
<a class="button-primary" href="<?php echo esc_url( apply_filters( 'woocommerce_docs_url', 'https://docs.woocommerce.com/document/variable-product/', 'product-variations' ) ); ?>" target="_blank"><?php _e( 'Learn more', 'woocommerce' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<div class="toolbar toolbar-variations-defaults">
|
||||
<div class="variations-defaults">
|
||||
<strong><?php _e( 'Default Form Values', 'woocommerce' ); ?>: <?php echo wc_help_tip( __( 'These are the attributes that will be pre-selected on the frontend.', 'woocommerce' ) ); ?></strong>
|
||||
<?php
|
||||
$default_attributes = maybe_unserialize( get_post_meta( $post->ID, '_default_attributes', true ) );
|
||||
|
||||
foreach ( $attributes as $attribute ) {
|
||||
|
||||
// Only deal with attributes that are variations
|
||||
if ( ! $attribute['is_variation'] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get current value for variation (if set)
|
||||
$variation_selected_value = isset( $default_attributes[ sanitize_title( $attribute['name'] ) ] ) ? $default_attributes[ sanitize_title( $attribute['name'] ) ] : '';
|
||||
|
||||
// Name will be something like attribute_pa_color
|
||||
echo '<select name="default_attribute_' . sanitize_title( $attribute['name'] ) . '" data-current="' . esc_attr( $variation_selected_value ) . '"><option value="">' . __( 'No default', 'woocommerce' ) . ' ' . esc_html( wc_attribute_label( $attribute['name'] ) ) . '…</option>';
|
||||
|
||||
// Get terms for attribute taxonomy or value if its a custom attribute
|
||||
if ( $attribute['is_taxonomy'] ) {
|
||||
$post_terms = wp_get_post_terms( $post->ID, $attribute['name'] );
|
||||
|
||||
foreach ( $post_terms as $term ) {
|
||||
echo '<option ' . selected( $variation_selected_value, $term->slug, false ) . ' value="' . esc_attr( $term->slug ) . '">' . esc_html( apply_filters( 'woocommerce_variation_option_name', $term->name ) ) . '</option>';
|
||||
}
|
||||
} else {
|
||||
$options = wc_get_text_attributes( $attribute['value'] );
|
||||
|
||||
foreach ( $options as $option ) {
|
||||
$selected = sanitize_title( $variation_selected_value ) === $variation_selected_value ? selected( $variation_selected_value, sanitize_title( $option ), false ) : selected( $variation_selected_value, $option, false );
|
||||
echo '<option ' . $selected . ' value="' . esc_attr( $option ) . '">' . esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ) . '</option>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '</select>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<div class="toolbar toolbar-top">
|
||||
<select id="field_to_edit" class="variation_actions">
|
||||
<option data-global="true" value="add_variation"><?php _e( 'Add variation', 'woocommerce' ); ?></option>
|
||||
<option data-global="true" value="link_all_variations"><?php _e( 'Create variations from all attributes', 'woocommerce' ); ?></option>
|
||||
<option value="delete_all"><?php _e( 'Delete all variations', 'woocommerce' ); ?></option>
|
||||
<optgroup label="<?php esc_attr_e( 'Status', 'woocommerce' ); ?>">
|
||||
<option value="toggle_enabled"><?php _e( 'Toggle "Enabled"', 'woocommerce' ); ?></option>
|
||||
<option value="toggle_downloadable"><?php _e( 'Toggle "Downloadable"', 'woocommerce' ); ?></option>
|
||||
<option value="toggle_virtual"><?php _e( 'Toggle "Virtual"', 'woocommerce' ); ?></option>
|
||||
</optgroup>
|
||||
<optgroup label="<?php esc_attr_e( 'Pricing', 'woocommerce' ); ?>">
|
||||
<option value="variable_regular_price"><?php _e( 'Set regular prices', 'woocommerce' ); ?></option>
|
||||
<option value="variable_regular_price_increase"><?php _e( 'Increase regular prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
|
||||
<option value="variable_regular_price_decrease"><?php _e( 'Decrease regular prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
|
||||
<option value="variable_sale_price"><?php _e( 'Set sale prices', 'woocommerce' ); ?></option>
|
||||
<option value="variable_sale_price_increase"><?php _e( 'Increase sale prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
|
||||
<option value="variable_sale_price_decrease"><?php _e( 'Decrease sale prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
|
||||
<option value="variable_sale_schedule"><?php _e( 'Set scheduled sale dates', 'woocommerce' ); ?></option>
|
||||
</optgroup>
|
||||
<optgroup label="<?php esc_attr_e( 'Inventory', 'woocommerce' ); ?>">
|
||||
<option value="toggle_manage_stock"><?php _e( 'Toggle "Manage stock"', 'woocommerce' ); ?></option>
|
||||
<option value="variable_stock"><?php _e( 'Stock', 'woocommerce' ); ?></option>
|
||||
</optgroup>
|
||||
<optgroup label="<?php esc_attr_e( 'Shipping', 'woocommerce' ); ?>">
|
||||
<option value="variable_length"><?php _e( 'Length', 'woocommerce' ); ?></option>
|
||||
<option value="variable_width"><?php _e( 'Width', 'woocommerce' ); ?></option>
|
||||
<option value="variable_height"><?php _e( 'Height', 'woocommerce' ); ?></option>
|
||||
<option value="variable_weight"><?php _e( 'Weight', 'woocommerce' ); ?></option>
|
||||
</optgroup>
|
||||
<optgroup label="<?php esc_attr_e( 'Downloadable products', 'woocommerce' ); ?>">
|
||||
<option value="variable_download_limit"><?php _e( 'Download limit', 'woocommerce' ); ?></option>
|
||||
<option value="variable_download_expiry"><?php _e( 'Download expiry', 'woocommerce' ); ?></option>
|
||||
</optgroup>
|
||||
<?php do_action( 'woocommerce_variable_product_bulk_edit_actions' ); ?>
|
||||
</select>
|
||||
<a class="button bulk_edit do_variation_action"><?php _e( 'Go', 'woocommerce' ); ?></a>
|
||||
|
||||
<div class="variations-pagenav">
|
||||
<span class="displaying-num"><?php printf( _n( '%s item', '%s items', $variations_count, 'woocommerce' ), $variations_count ); ?></span>
|
||||
<span class="expand-close">
|
||||
(<a href="#" class="expand_all"><?php _e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php _e( 'Close', 'woocommerce' ); ?></a>)
|
||||
</span>
|
||||
<span class="pagination-links">
|
||||
<a class="first-page disabled" title="<?php esc_attr_e( 'Go to the first page', 'woocommerce' ); ?>" href="#">«</a>
|
||||
<a class="prev-page disabled" title="<?php esc_attr_e( 'Go to the previous page', 'woocommerce' ); ?>" href="#">‹</a>
|
||||
<span class="paging-select">
|
||||
<label for="current-page-selector-1" class="screen-reader-text"><?php _e( 'Select Page', 'woocommerce' ); ?></label>
|
||||
<select class="page-selector" id="current-page-selector-1" title="<?php esc_attr_e( 'Current page', 'woocommerce' ); ?>">
|
||||
<?php for ( $i = 1; $i <= $variations_total_pages; $i++ ) : ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
<?php _ex( 'of', 'number of pages', 'woocommerce' ); ?> <span class="total-pages"><?php echo $variations_total_pages; ?></span>
|
||||
</span>
|
||||
<a class="next-page" title="<?php esc_attr_e( 'Go to the next page', 'woocommerce' ); ?>" href="#">›</a>
|
||||
<a class="last-page" title="<?php esc_attr_e( 'Go to the last page', 'woocommerce' ); ?>" href="#">»</a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<div class="woocommerce_variations wc-metaboxes" data-attributes="<?php
|
||||
// esc_attr does not double encode - htmlspecialchars does
|
||||
echo htmlspecialchars( json_encode( $attributes ) );
|
||||
?>" data-total="<?php echo $variations_count; ?>" data-total_pages="<?php echo $variations_total_pages; ?>" data-page="1" data-edited="false">
|
||||
</div>
|
||||
|
||||
<div class="toolbar">
|
||||
<button type="button" class="button-primary save-variation-changes" disabled="disabled"><?php _e( 'Save changes', 'woocommerce' ); ?></button>
|
||||
<button type="button" class="button cancel-variation-changes" disabled="disabled"><?php _e( 'Cancel', 'woocommerce' ); ?></button>
|
||||
|
||||
<div class="variations-pagenav">
|
||||
<span class="displaying-num"><?php printf( _n( '%s item', '%s items', $variations_count, 'woocommerce' ), $variations_count ); ?></span>
|
||||
<span class="expand-close">
|
||||
(<a href="#" class="expand_all"><?php _e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php _e( 'Close', 'woocommerce' ); ?></a>)
|
||||
</span>
|
||||
<span class="pagination-links">
|
||||
<a class="first-page disabled" title="<?php esc_attr_e( 'Go to the first page', 'woocommerce' ); ?>" href="#">«</a>
|
||||
<a class="prev-page disabled" title="<?php esc_attr_e( 'Go to the previous page', 'woocommerce' ); ?>" href="#">‹</a>
|
||||
<span class="paging-select">
|
||||
<label for="current-page-selector-1" class="screen-reader-text"><?php _e( 'Select Page', 'woocommerce' ); ?></label>
|
||||
<select class="page-selector" id="current-page-selector-1" title="<?php esc_attr_e( 'Current page', 'woocommerce' ); ?>">
|
||||
<?php for ( $i = 1; $i <= $variations_total_pages; $i++ ) : ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
<?php _ex( 'of', 'number of pages', 'woocommerce' ); ?> <span class="total-pages"><?php echo $variations_total_pages; ?></span>
|
||||
</span>
|
||||
<a class="next-page" title="<?php esc_attr_e( 'Go to the next page', 'woocommerce' ); ?>" href="#">›</a>
|
||||
<a class="last-page" title="<?php esc_attr_e( 'Go to the last page', 'woocommerce' ); ?>" href="#">»</a>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
</div></div>
|
||||
<?php
|
||||
include( 'views/html-product-data-variations.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -798,7 +159,6 @@ class WC_Meta_Box_Product_Data {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $downloads;
|
||||
}
|
||||
|
||||
|
@ -873,9 +233,9 @@ class WC_Meta_Box_Product_Data {
|
|||
|
||||
$product = new $classname( $post_id );
|
||||
$errors = $product->set_props( array(
|
||||
'sku' => wc_clean( $_POST['_sku'] ),
|
||||
'sku' => isset( $_POST['_sku'] ) ? wc_clean( $_POST['_sku'] ) : null,
|
||||
'purchase_note' => wp_kses_post( stripslashes( $_POST['_purchase_note'] ) ),
|
||||
'downloadable' => isset( $_POST['_downloadable'] ) ,
|
||||
'downloadable' => isset( $_POST['_downloadable'] ),
|
||||
'virtual' => isset( $_POST['_virtual'] ),
|
||||
'tax_status' => wc_clean( $_POST['_tax_status'] ),
|
||||
'tax_class' => wc_clean( $_POST['_tax_class'] ),
|
||||
|
@ -894,7 +254,7 @@ class WC_Meta_Box_Product_Data {
|
|||
'manage_stock' => ! empty( $_POST['_manage_stock'] ),
|
||||
'backorders' => wc_clean( $_POST['_backorders'] ),
|
||||
'stock_status' => wc_clean( $_POST['_stock_status'] ),
|
||||
'stock' => wc_stock_amount( $_POST['_stock'] ),
|
||||
'stock_quantity' => wc_stock_amount( $_POST['_stock'] ),
|
||||
'attributes' => self::prepare_attributes(),
|
||||
'download_limit' => '' === $_POST['_download_limit'] ? '' : absint( $_POST['_download_limit'] ),
|
||||
'download_expiry' => '' === $_POST['_download_expiry'] ? '' : absint( $_POST['_download_expiry'] ),
|
||||
|
@ -903,6 +263,7 @@ class WC_Meta_Box_Product_Data {
|
|||
'product_url' => esc_url_raw( $_POST['_product_url'] ),
|
||||
'button_text' => wc_clean( $_POST['_button_text'] ),
|
||||
'children' => 'grouped' === $product_type ? self::prepare_children() : null,
|
||||
'reviews_allowed' => ! empty( $_POST['_reviews_allowed'] ),
|
||||
) );
|
||||
|
||||
if ( is_wp_error( $errors ) ) {
|
||||
|
@ -911,7 +272,6 @@ class WC_Meta_Box_Product_Data {
|
|||
|
||||
$product->save();
|
||||
|
||||
// Do action for product type
|
||||
do_action( 'woocommerce_process_product_meta_' . $product_type, $post_id );
|
||||
}
|
||||
|
||||
|
@ -1063,7 +423,7 @@ class WC_Meta_Box_Product_Data {
|
|||
wc_update_product_stock( $variation_id, wc_stock_amount( $variable_stock[ $i ] ) );
|
||||
} else {
|
||||
delete_post_meta( $variation_id, '_backorders' );
|
||||
delete_post_meta( $variation_id, '_stock' );
|
||||
wc_update_product_stock( $variation_id, '' );
|
||||
}
|
||||
|
||||
// Only update stock status to user setting if changed by the user, but do so before looking at stock levels at variation level
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<div id="advanced_product_data" class="panel woocommerce_options_panel hidden">
|
||||
|
||||
<div class="options_group hide_if_external">
|
||||
<?php
|
||||
woocommerce_wp_textarea_input( array(
|
||||
'id' => '_purchase_note',
|
||||
'value' => $product_object->get_purchase_note(),
|
||||
'label' => __( 'Purchase note', 'woocommerce' ),
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'Enter an optional note to send the customer after purchase.', 'woocommerce' ),
|
||||
) );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="options_group">
|
||||
<?php
|
||||
woocommerce_wp_text_input( array(
|
||||
'id' => 'menu_order',
|
||||
'value' => $product_object->get_menu_order(),
|
||||
'label' => __( 'Menu order', 'woocommerce' ),
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'Custom ordering position.', 'woocommerce' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'step' => '1',
|
||||
),
|
||||
) );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="options_group reviews">
|
||||
<?php
|
||||
woocommerce_wp_checkbox( array(
|
||||
'id' => '_reviews_allowed',
|
||||
'value' => $product_object->get_reviews_allowed() ? 'open' : 'closed',
|
||||
'label' => __( 'Enable reviews', 'woocommerce' ),
|
||||
'cbvalue' => 'open',
|
||||
) );
|
||||
do_action( 'woocommerce_product_options_reviews' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php do_action( 'woocommerce_product_options_advanced' ); ?>
|
||||
</div>
|
|
@ -0,0 +1,51 @@
|
|||
<div id="product_attributes" class="panel wc-metaboxes-wrapper hidden">
|
||||
<div class="toolbar toolbar-top">
|
||||
<span class="expand-close">
|
||||
<a href="#" class="expand_all"><?php _e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php _e( 'Close', 'woocommerce' ); ?></a>
|
||||
</span>
|
||||
<select name="attribute_taxonomy" class="attribute_taxonomy">
|
||||
<option value=""><?php _e( 'Custom product attribute', 'woocommerce' ); ?></option>
|
||||
<?php
|
||||
global $wc_product_attributes;
|
||||
|
||||
// Array of defined attribute taxonomies
|
||||
$attribute_taxonomies = wc_get_attribute_taxonomies();
|
||||
|
||||
if ( ! empty( $attribute_taxonomies ) ) {
|
||||
foreach ( $attribute_taxonomies as $tax ) {
|
||||
$attribute_taxonomy_name = wc_attribute_taxonomy_name( $tax->attribute_name );
|
||||
$label = $tax->attribute_label ? $tax->attribute_label : $tax->attribute_name;
|
||||
echo '<option value="' . esc_attr( $attribute_taxonomy_name ) . '">' . esc_html( $label ) . '</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<button type="button" class="button add_attribute"><?php _e( 'Add', 'woocommerce' ); ?></button>
|
||||
</div>
|
||||
<div class="product_attributes wc-metaboxes">
|
||||
<?php
|
||||
// Product attributes - taxonomies and custom, ordered, with visibility and variation attributes set
|
||||
$attributes = $product_object->get_attributes();
|
||||
$i = -1;
|
||||
|
||||
foreach ( $attributes as $attribute ) {
|
||||
$i++;
|
||||
$metabox_class = array();
|
||||
|
||||
if ( $attribute->is_taxonomy() ) {
|
||||
$metabox_class[] = 'taxonomy';
|
||||
$metabox_class[] = $attribute->get_name();
|
||||
}
|
||||
|
||||
include( 'html-product-attribute.php' );
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<span class="expand-close">
|
||||
<a href="#" class="expand_all"><?php _e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php _e( 'Close', 'woocommerce' ); ?></a>
|
||||
</span>
|
||||
<button type="button" class="button save_attributes button-primary"><?php _e( 'Save attributes', 'woocommerce' ); ?></button>
|
||||
</div>
|
||||
<?php do_action( 'woocommerce_product_options_attributes' ); ?>
|
||||
</div>
|
|
@ -0,0 +1,173 @@
|
|||
<div id="general_product_data" class="panel woocommerce_options_panel">
|
||||
|
||||
<div class="options_group show_if_external">
|
||||
<?php
|
||||
woocommerce_wp_text_input( array(
|
||||
'id' => '_product_url',
|
||||
'value' => is_callable( array( $product_object, 'get_product_url' ) ) ? $product_object->get_product_url() : '',
|
||||
'label' => __( 'Product URL', 'woocommerce' ),
|
||||
'placeholder' => 'http://',
|
||||
'description' => __( 'Enter the external URL to the product.', 'woocommerce' ),
|
||||
) );
|
||||
|
||||
woocommerce_wp_text_input( array(
|
||||
'id' => '_button_text',
|
||||
'value' => is_callable( array( $product_object, 'get_button_text' ) ) ? $product_object->get_button_text() : '',
|
||||
'label' => __( 'Button text', 'woocommerce' ),
|
||||
'placeholder' => _x( 'Buy product', 'placeholder', 'woocommerce' ),
|
||||
'description' => __( 'This text will be shown on the button linking to the external product.', 'woocommerce' ),
|
||||
) );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="options_group pricing show_if_simple show_if_external hidden">
|
||||
<?php
|
||||
woocommerce_wp_text_input( array(
|
||||
'id' => '_regular_price',
|
||||
'value' => $product_object->get_regular_price(),
|
||||
'label' => __( 'Regular price', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')',
|
||||
'data_type' => 'price',
|
||||
) );
|
||||
|
||||
woocommerce_wp_text_input( array(
|
||||
'id' => '_sale_price',
|
||||
'value' => $product_object->get_sale_price(),
|
||||
'data_type' => 'price',
|
||||
'label' => __( 'Sale price', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')',
|
||||
'description' => '<a href="#" class="sale_schedule">' . __( 'Schedule', 'woocommerce' ) . '</a>',
|
||||
) );
|
||||
|
||||
$sale_price_dates_from = ( $date = $product_object->get_date_on_sale_from() ) ? date_i18n( 'Y-m-d', $date ) : '';
|
||||
$sale_price_dates_to = ( $date = $product_object->get_date_on_sale_to() ) ? date_i18n( 'Y-m-d', $date ) : '';
|
||||
|
||||
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="' . esc_attr( $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="' . esc_attr( $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>' . wc_help_tip( __( 'The sale will end at the beginning of the set date.', 'woocommerce' ) ) . '
|
||||
</p>';
|
||||
|
||||
do_action( 'woocommerce_product_options_pricing' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="options_group show_if_downloadable hidden">
|
||||
<div class="form-field downloadable_files">
|
||||
<label><?php _e( 'Downloadable files', 'woocommerce' ); ?></label>
|
||||
<table class="widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="sort"> </th>
|
||||
<th><?php _e( 'Name', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the name of the download shown to the customer.', 'woocommerce' ) ); ?></th>
|
||||
<th colspan="2"><?php _e( 'File URL', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the URL or absolute path to the file which customers will get access to. URLs entered here should already be encoded.', 'woocommerce' ) ); ?></th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if ( $downloadable_files = $product_object->get_downloads() ) {
|
||||
foreach ( $downloadable_files as $key => $file ) {
|
||||
include( 'html-product-download.php' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="5">
|
||||
<a href="#" class="button insert" data-row="<?php
|
||||
$file = array(
|
||||
'file' => '',
|
||||
'name' => '',
|
||||
);
|
||||
ob_start();
|
||||
include( 'html-product-download.php' );
|
||||
echo esc_attr( ob_get_clean() );
|
||||
?>"><?php _e( 'Add File', 'woocommerce' ); ?></a>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
woocommerce_wp_text_input( array(
|
||||
'id' => '_download_limit', // @todo
|
||||
'label' => __( 'Download limit', 'woocommerce' ),
|
||||
'placeholder' => __( 'Unlimited', 'woocommerce' ),
|
||||
'description' => __( 'Leave blank for unlimited re-downloads.', 'woocommerce' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'step' => '1',
|
||||
'min' => '0',
|
||||
),
|
||||
) );
|
||||
|
||||
woocommerce_wp_text_input( array(
|
||||
'id' => '_download_expiry', // @todo
|
||||
'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',
|
||||
),
|
||||
) );
|
||||
|
||||
woocommerce_wp_select( array(
|
||||
'id' => '_download_type', // @todo
|
||||
'label' => __( 'Download type', 'woocommerce' ),
|
||||
'description' => sprintf( __( 'Choose a download type - this controls the <a href="%s">schema</a>.', 'woocommerce' ), 'http://schema.org/' ),
|
||||
'options' => array(
|
||||
'' => __( 'Standard Product', 'woocommerce' ),
|
||||
'application' => __( 'Application/Software', 'woocommerce' ),
|
||||
'music' => __( 'Music', 'woocommerce' ),
|
||||
),
|
||||
) );
|
||||
|
||||
do_action( 'woocommerce_product_options_downloads' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php if ( wc_tax_enabled() ) : ?>
|
||||
<div class="options_group show_if_simple show_if_external show_if_variable">
|
||||
<?php
|
||||
woocommerce_wp_select( array(
|
||||
'id' => '_tax_status',
|
||||
'value' => $product_object->get_tax_status(),
|
||||
'label' => __( 'Tax status', 'woocommerce' ),
|
||||
'options' => array(
|
||||
'taxable' => __( 'Taxable', 'woocommerce' ),
|
||||
'shipping' => __( 'Shipping only', 'woocommerce' ),
|
||||
'none' => _x( 'None', 'Tax status', 'woocommerce' ),
|
||||
),
|
||||
'desc_tip' => 'true',
|
||||
'description' => __( 'Define whether or not the entire product is taxable, or just the cost of shipping it.', 'woocommerce' ),
|
||||
) );
|
||||
|
||||
$tax_classes = WC_Tax::get_tax_classes();
|
||||
$classes_options = array();
|
||||
$classes_options[''] = __( 'Standard', 'woocommerce' );
|
||||
|
||||
if ( ! empty( $tax_classes ) ) {
|
||||
foreach ( $tax_classes as $class ) {
|
||||
$classes_options[ sanitize_title( $class ) ] = esc_html( $class );
|
||||
}
|
||||
}
|
||||
|
||||
woocommerce_wp_select( array(
|
||||
'id' => '_tax_class',
|
||||
'value' => $product_object->get_tax_class(),
|
||||
'label' => __( 'Tax class', 'woocommerce' ),
|
||||
'options' => $classes_options,
|
||||
'desc_tip' => 'true',
|
||||
'description' => __( 'Choose a tax class for this product. Tax classes are used to apply different tax rates specific to certain types of product.', 'woocommerce' ),
|
||||
) );
|
||||
|
||||
do_action( 'woocommerce_product_options_tax' );
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action( 'woocommerce_product_options_general_product_data' ); ?>
|
||||
</div>
|
|
@ -0,0 +1,94 @@
|
|||
<div id="inventory_product_data" class="panel woocommerce_options_panel hidden">
|
||||
|
||||
<div class="options_group">
|
||||
<?php
|
||||
if ( wc_product_sku_enabled() ) {
|
||||
woocommerce_wp_text_input( array(
|
||||
'id' => '_sku',
|
||||
'value' => $product_object->get_sku(),
|
||||
'label' => '<abbr title="' . __( 'Stock Keeping Unit', 'woocommerce' ) . '">' . __( 'SKU', 'woocommerce' ) . '</abbr>',
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'SKU refers to a Stock-keeping unit, a unique identifier for each distinct product and service that can be purchased.', 'woocommerce' ),
|
||||
) );
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_product_options_sku' );
|
||||
|
||||
if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) {
|
||||
|
||||
woocommerce_wp_checkbox( array(
|
||||
'id' => '_manage_stock',
|
||||
'value' => $product_object->get_manage_stock() ? 'yes' : 'no',
|
||||
'wrapper_class' => 'show_if_simple show_if_variable',
|
||||
'label' => __( 'Manage stock?', 'woocommerce' ),
|
||||
'description' => __( 'Enable stock management at product level', 'woocommerce' ),
|
||||
) );
|
||||
|
||||
do_action( 'woocommerce_product_options_stock' );
|
||||
|
||||
echo '<div class="stock_fields show_if_simple show_if_variable">';
|
||||
|
||||
woocommerce_wp_text_input( array(
|
||||
'id' => '_stock',
|
||||
'value' => $product_object->get_stock_quantity(),
|
||||
'label' => __( 'Stock quantity', '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',
|
||||
),
|
||||
'data_type' => 'stock',
|
||||
) );
|
||||
|
||||
woocommerce_wp_select( array(
|
||||
'id' => '_backorders',
|
||||
'value' => $product_object->get_backorders(),
|
||||
'label' => __( 'Allow backorders?', 'woocommerce' ),
|
||||
'options' => array(
|
||||
'no' => __( 'Do not allow', 'woocommerce' ),
|
||||
'notify' => __( 'Allow, but notify customer', 'woocommerce' ),
|
||||
'yes' => __( 'Allow', 'woocommerce' ),
|
||||
),
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'If managing stock, this controls whether or not backorders are allowed. If enabled, stock quantity can go below 0.', 'woocommerce' ),
|
||||
) );
|
||||
|
||||
do_action( 'woocommerce_product_options_stock_fields' );
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
woocommerce_wp_select( array(
|
||||
'id' => '_stock_status',
|
||||
'value' => $product_object->get_stock_status(),
|
||||
'wrapper_class' => 'hide_if_variable hide_if_external',
|
||||
'label' => __( 'Stock status', 'woocommerce' ),
|
||||
'options' => array(
|
||||
'instock' => __( 'In stock', 'woocommerce' ),
|
||||
'outofstock' => __( 'Out of stock', 'woocommerce' ),
|
||||
),
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ),
|
||||
) );
|
||||
|
||||
do_action( 'woocommerce_product_options_stock_status' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="options_group show_if_simple show_if_variable">
|
||||
<?php
|
||||
woocommerce_wp_checkbox( array(
|
||||
'id' => '_sold_individually',
|
||||
'value' => $product_object->get_sold_individually() ? 'yes' : 'no',
|
||||
'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' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php do_action( 'woocommerce_product_options_inventory_product_data' ); ?>
|
||||
</div>
|
|
@ -0,0 +1,57 @@
|
|||
<div id="linked_product_data" class="panel woocommerce_options_panel hidden">
|
||||
|
||||
<div class="options_group">
|
||||
<p class="form-field">
|
||||
<label for="upsell_ids"><?php _e( 'Up-sells', 'woocommerce' ); ?></label>
|
||||
<input type="hidden" class="wc-product-search" style="width: 50%;" id="upsell_ids" name="upsell_ids" data-placeholder="<?php esc_attr_e( 'Search for a product…', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products" data-multiple="true" data-exclude="<?php echo intval( $post->ID ); ?>" data-selected="<?php
|
||||
$product_ids = $product_object->get_upsell_ids();
|
||||
$json_ids = array();
|
||||
|
||||
foreach ( $product_ids as $product_id ) {
|
||||
$product = wc_get_product( $product_id );
|
||||
if ( is_object( $product ) ) {
|
||||
$json_ids[ $product_id ] = wp_kses_post( html_entity_decode( $product->get_formatted_name(), ENT_QUOTES, get_bloginfo( 'charset' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
echo esc_attr( json_encode( $json_ids ) );
|
||||
?>" value="<?php echo implode( ',', array_keys( $json_ids ) ); ?>" /> <?php echo wc_help_tip( __( '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' ) ); ?>
|
||||
</p>
|
||||
|
||||
<p class="form-field">
|
||||
<label for="crosssell_ids"><?php _e( 'Cross-sells', 'woocommerce' ); ?></label>
|
||||
<input type="hidden" class="wc-product-search" style="width: 50%;" id="crosssell_ids" name="crosssell_ids" data-placeholder="<?php esc_attr_e( 'Search for a product…', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products" data-multiple="true" data-exclude="<?php echo intval( $post->ID ); ?>" data-selected="<?php
|
||||
$product_ids = $product_object->get_cross_sell_ids();
|
||||
$json_ids = array();
|
||||
|
||||
foreach ( $product_ids as $product_id ) {
|
||||
$product = wc_get_product( $product_id );
|
||||
if ( is_object( $product ) ) {
|
||||
$json_ids[ $product_id ] = wp_kses_post( html_entity_decode( $product->get_formatted_name(), ENT_QUOTES, get_bloginfo( 'charset' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
echo esc_attr( json_encode( $json_ids ) );
|
||||
?>" value="<?php echo implode( ',', array_keys( $json_ids ) ); ?>" /> <?php echo wc_help_tip( __( 'Cross-sells are products which you promote in the cart, based on the current product.', 'woocommerce' ) ); ?>
|
||||
</p>
|
||||
|
||||
<p class="form-field show_if_grouped">
|
||||
<label for="grouped_products"><?php _e( 'Grouped products', 'woocommerce' ); ?></label>
|
||||
<input type="hidden" class="wc-product-search" style="width: 50%;" id="grouped_products" name="grouped_products" data-placeholder="<?php esc_attr_e( 'Search for a product…', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products" data-multiple="true" data-exclude="<?php echo intval( $post->ID ); ?>" data-selected="<?php
|
||||
$product_ids = $product_object->get_children();
|
||||
$json_ids = array();
|
||||
|
||||
foreach ( $product_ids as $product_id ) {
|
||||
$product = wc_get_product( $product_id );
|
||||
if ( is_object( $product ) ) {
|
||||
$json_ids[ $product_id ] = wp_kses_post( html_entity_decode( $product->get_formatted_name(), ENT_QUOTES, get_bloginfo( 'charset' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
echo esc_attr( json_encode( $json_ids ) );
|
||||
?>" value="<?php echo implode( ',', array_keys( $json_ids ) ); ?>" /> <?php echo wc_help_tip( __( 'This lets you choose which products are part of this group.', 'woocommerce' ) ); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php do_action( 'woocommerce_product_options_related' ); ?>
|
||||
</div>
|
|
@ -0,0 +1,45 @@
|
|||
<div class="panel-wrap product_data">
|
||||
|
||||
<span class="type_box hidden"> —
|
||||
<label for="product-type">
|
||||
<select id="product-type" name="product-type">
|
||||
<optgroup label="<?php esc_attr_e( 'Product Type', 'woocommerce' ); ?>">
|
||||
<?php foreach ( wc_get_product_types() as $value => $label ) : ?>
|
||||
<option value="<?php echo esc_attr( $value ); ?>" <?php echo selected( $product_object->get_type(), $value, false ); ?>><?php echo esc_html( $label ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<?php foreach ( self::get_product_type_options() as $key => $option ) :
|
||||
if ( $thepostid ) {
|
||||
$selected_value = is_callable( $product_object, "is_$key" ) ? $product_object->{"is_$key"}() : get_post_meta( $post->ID, '_' . $key, true );
|
||||
} else {
|
||||
$selected_value = isset( $option['default'] ) ? $option['default'] : 'no';
|
||||
}
|
||||
?>
|
||||
<label for="<?php echo esc_attr( $option['id'] ); ?>" class="<?php echo esc_attr( $option['wrapper_class'] ); ?> tips" data-tip="<?php echo esc_attr( $option['description'] ); ?>">
|
||||
<?php echo esc_html( $option['label'] ); ?>:
|
||||
<input type="checkbox" name="<?php echo esc_attr( $option['id'] ); ?>" id="<?php echo esc_attr( $option['id'] ); ?>" <?php echo checked( $selected_value, 'yes', false ); ?> />
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</span>
|
||||
|
||||
<ul class="product_data_tabs wc-tabs">
|
||||
<?php foreach ( self::get_product_data_tabs() as $key => $tab ) : ?>
|
||||
<li class="<?php echo $key; ?>_options <?php echo $key; ?>_tab <?php echo implode( ' ' , (array) $tab['class'] ); ?>">
|
||||
<a href="#<?php echo $tab['target']; ?>"><?php echo esc_html( $tab['label'] ); ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php do_action( 'woocommerce_product_write_panel_tabs' ); ?>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
self::output_tabs();
|
||||
self::output_variations();
|
||||
do_action( 'woocommerce_product_data_panels' );
|
||||
wc_do_deprecated_action( 'woocommerce_product_write_panels', array(), '2.6', 'Use woocommerce_product_data_panels action instead.' );
|
||||
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
|
||||
?>
|
||||
<div class="clear"></div>
|
||||
</div>
|
|
@ -0,0 +1,53 @@
|
|||
<div id="shipping_product_data" class="panel woocommerce_options_panel hidden">
|
||||
<div class="options_group">
|
||||
<?php
|
||||
if ( wc_product_weight_enabled() ) {
|
||||
woocommerce_wp_text_input( array(
|
||||
'id' => '_weight',
|
||||
'value' => $product_object->get_weight(),
|
||||
'label' => __( 'Weight', 'woocommerce' ) . ' (' . get_option( 'woocommerce_weight_unit' ) . ')',
|
||||
'placeholder' => wc_format_localized_decimal( 0 ),
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'Weight in decimal form', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'data_type' => 'decimal',
|
||||
) );
|
||||
}
|
||||
|
||||
if ( wc_product_dimensions_enabled() ) {
|
||||
?><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 esc_attr_e( 'Length', 'woocommerce' ); ?>" class="input-text wc_input_decimal" size="6" type="text" name="_length" value="<?php echo esc_attr( wc_format_localized_decimal( $product_object->get_length() ) ); ?>" />
|
||||
<input placeholder="<?php esc_attr_e( 'Width', 'woocommerce' ); ?>" class="input-text wc_input_decimal" size="6" type="text" name="_width" value="<?php echo esc_attr( wc_format_localized_decimal( $product_object->get_width() ) ); ?>" />
|
||||
<input placeholder="<?php esc_attr_e( 'Height', 'woocommerce' ); ?>" class="input-text wc_input_decimal last" size="6" type="text" name="_height" value="<?php echo esc_attr( wc_format_localized_decimal( $product_object->get_height() ) ); ?>" />
|
||||
</span>
|
||||
<?php echo wc_help_tip( __( 'LxWxH in decimal form', 'woocommerce' ) ); ?>
|
||||
</p><?php
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_product_options_dimensions' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="options_group">
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'product_shipping_class',
|
||||
'hide_empty' => 0,
|
||||
'show_option_none' => __( 'No shipping class', 'woocommerce' ),
|
||||
'name' => 'product_shipping_class',
|
||||
'id' => 'product_shipping_class',
|
||||
'selected' => $product_object->get_shipping_class_id(),
|
||||
'class' => 'select short',
|
||||
);
|
||||
?><p class="form-field dimensions_field">
|
||||
<label for="product_shipping_class"><?php _e( 'Shipping class', 'woocommerce' ); ?></label>
|
||||
<?php wp_dropdown_categories( $args ); ?>
|
||||
<?php echo wc_help_tip( __( 'Shipping classes are used by certain shipping methods to group similar products.', 'woocommerce' ) ); ?>
|
||||
</p><?php
|
||||
|
||||
do_action( 'woocommerce_product_options_shipping' );
|
||||
?>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,136 @@
|
|||
<div id="variable_product_options" class="panel wc-metaboxes-wrapper hidden">
|
||||
<div id="variable_product_options_inner">
|
||||
|
||||
<?php if ( ! count( $variation_attributes ) ) : ?>
|
||||
|
||||
<div id="message" class="inline notice woocommerce-message">
|
||||
<p><?php _e( 'Before you can add a variation you need to add some variation attributes on the <strong>Attributes</strong> tab.', 'woocommerce' ); ?></p>
|
||||
<p><a class="button-primary" href="<?php echo esc_url( apply_filters( 'woocommerce_docs_url', 'https://docs.woocommerce.com/document/variable-product/', 'product-variations' ) ); ?>" target="_blank"><?php _e( 'Learn more', 'woocommerce' ); ?></a></p>
|
||||
</div>
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<div class="toolbar toolbar-variations-defaults">
|
||||
<div class="variations-defaults">
|
||||
<strong><?php _e( 'Default Form Values', 'woocommerce' ); ?>: <?php echo wc_help_tip( __( 'These are the attributes that will be pre-selected on the frontend.', 'woocommerce' ) ); ?></strong>
|
||||
<?php
|
||||
foreach ( $variation_attributes as $attribute ) {
|
||||
$selected_value = isset( $default_attributes[ sanitize_title( $attribute->get_name() ) ] ) ? $default_attributes[ sanitize_title( $attribute->get_name() ) ] : '';
|
||||
?>
|
||||
<select name="default_attribute_<?php echo sanitize_title( $attribute->get_name() ); ?>" data-current="<?php echo esc_attr( $selected_value ); ?>">
|
||||
<option value=""><?php echo esc_html( sprintf( __( 'No default %s…', 'woocommerce' ), wc_attribute_label( $attribute->get_name() ) ) ); ?></option>
|
||||
<?php if ( $attribute->is_taxonomy() ) : ?>
|
||||
<?php foreach ( $attribute->get_terms() as $option ) : ?>
|
||||
<option <?php selected( $selected_value, $option->slug ); ?> value="<?php echo esc_attr( $option->slug ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option->name ) ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<?php foreach ( $attribute->get_options() as $option ) : ?>
|
||||
<option <?php selected( $selected_value, $option ); ?> value="<?php echo esc_attr( $option ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<div class="toolbar toolbar-top">
|
||||
<select id="field_to_edit" class="variation_actions">
|
||||
<option data-global="true" value="add_variation"><?php _e( 'Add variation', 'woocommerce' ); ?></option>
|
||||
<option data-global="true" value="link_all_variations"><?php _e( 'Create variations from all attributes', 'woocommerce' ); ?></option>
|
||||
<option value="delete_all"><?php _e( 'Delete all variations', 'woocommerce' ); ?></option>
|
||||
<optgroup label="<?php esc_attr_e( 'Status', 'woocommerce' ); ?>">
|
||||
<option value="toggle_enabled"><?php _e( 'Toggle "Enabled"', 'woocommerce' ); ?></option>
|
||||
<option value="toggle_downloadable"><?php _e( 'Toggle "Downloadable"', 'woocommerce' ); ?></option>
|
||||
<option value="toggle_virtual"><?php _e( 'Toggle "Virtual"', 'woocommerce' ); ?></option>
|
||||
</optgroup>
|
||||
<optgroup label="<?php esc_attr_e( 'Pricing', 'woocommerce' ); ?>">
|
||||
<option value="variable_regular_price"><?php _e( 'Set regular prices', 'woocommerce' ); ?></option>
|
||||
<option value="variable_regular_price_increase"><?php _e( 'Increase regular prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
|
||||
<option value="variable_regular_price_decrease"><?php _e( 'Decrease regular prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
|
||||
<option value="variable_sale_price"><?php _e( 'Set sale prices', 'woocommerce' ); ?></option>
|
||||
<option value="variable_sale_price_increase"><?php _e( 'Increase sale prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
|
||||
<option value="variable_sale_price_decrease"><?php _e( 'Decrease sale prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
|
||||
<option value="variable_sale_schedule"><?php _e( 'Set scheduled sale dates', 'woocommerce' ); ?></option>
|
||||
</optgroup>
|
||||
<optgroup label="<?php esc_attr_e( 'Inventory', 'woocommerce' ); ?>">
|
||||
<option value="toggle_manage_stock"><?php _e( 'Toggle "Manage stock"', 'woocommerce' ); ?></option>
|
||||
<option value="variable_stock"><?php _e( 'Stock', 'woocommerce' ); ?></option>
|
||||
</optgroup>
|
||||
<optgroup label="<?php esc_attr_e( 'Shipping', 'woocommerce' ); ?>">
|
||||
<option value="variable_length"><?php _e( 'Length', 'woocommerce' ); ?></option>
|
||||
<option value="variable_width"><?php _e( 'Width', 'woocommerce' ); ?></option>
|
||||
<option value="variable_height"><?php _e( 'Height', 'woocommerce' ); ?></option>
|
||||
<option value="variable_weight"><?php _e( 'Weight', 'woocommerce' ); ?></option>
|
||||
</optgroup>
|
||||
<optgroup label="<?php esc_attr_e( 'Downloadable products', 'woocommerce' ); ?>">
|
||||
<option value="variable_download_limit"><?php _e( 'Download limit', 'woocommerce' ); ?></option>
|
||||
<option value="variable_download_expiry"><?php _e( 'Download expiry', 'woocommerce' ); ?></option>
|
||||
</optgroup>
|
||||
<?php do_action( 'woocommerce_variable_product_bulk_edit_actions' ); ?>
|
||||
</select>
|
||||
<a class="button bulk_edit do_variation_action"><?php _e( 'Go', 'woocommerce' ); ?></a>
|
||||
|
||||
<div class="variations-pagenav">
|
||||
<span class="displaying-num"><?php printf( _n( '%s item', '%s items', $variations_count, 'woocommerce' ), $variations_count ); ?></span>
|
||||
<span class="expand-close">
|
||||
(<a href="#" class="expand_all"><?php _e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php _e( 'Close', 'woocommerce' ); ?></a>)
|
||||
</span>
|
||||
<span class="pagination-links">
|
||||
<a class="first-page disabled" title="<?php esc_attr_e( 'Go to the first page', 'woocommerce' ); ?>" href="#">«</a>
|
||||
<a class="prev-page disabled" title="<?php esc_attr_e( 'Go to the previous page', 'woocommerce' ); ?>" href="#">‹</a>
|
||||
<span class="paging-select">
|
||||
<label for="current-page-selector-1" class="screen-reader-text"><?php _e( 'Select Page', 'woocommerce' ); ?></label>
|
||||
<select class="page-selector" id="current-page-selector-1" title="<?php esc_attr_e( 'Current page', 'woocommerce' ); ?>">
|
||||
<?php for ( $i = 1; $i <= $variations_total_pages; $i++ ) : ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
<?php _ex( 'of', 'number of pages', 'woocommerce' ); ?> <span class="total-pages"><?php echo $variations_total_pages; ?></span>
|
||||
</span>
|
||||
<a class="next-page" title="<?php esc_attr_e( 'Go to the next page', 'woocommerce' ); ?>" href="#">›</a>
|
||||
<a class="last-page" title="<?php esc_attr_e( 'Go to the last page', 'woocommerce' ); ?>" href="#">»</a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<div class="woocommerce_variations wc-metaboxes" data-attributes="<?php
|
||||
// esc_attr does not double encode - htmlspecialchars does
|
||||
echo htmlspecialchars( json_encode( wc_list_pluck( $variation_attributes, 'get_data' ) ) );
|
||||
?>" data-total="<?php echo $variations_count; ?>" data-total_pages="<?php echo $variations_total_pages; ?>" data-page="1" data-edited="false">
|
||||
</div>
|
||||
|
||||
<div class="toolbar">
|
||||
<button type="button" class="button-primary save-variation-changes" disabled="disabled"><?php _e( 'Save changes', 'woocommerce' ); ?></button>
|
||||
<button type="button" class="button cancel-variation-changes" disabled="disabled"><?php _e( 'Cancel', 'woocommerce' ); ?></button>
|
||||
|
||||
<div class="variations-pagenav">
|
||||
<span class="displaying-num"><?php printf( _n( '%s item', '%s items', $variations_count, 'woocommerce' ), $variations_count ); ?></span>
|
||||
<span class="expand-close">
|
||||
(<a href="#" class="expand_all"><?php _e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php _e( 'Close', 'woocommerce' ); ?></a>)
|
||||
</span>
|
||||
<span class="pagination-links">
|
||||
<a class="first-page disabled" title="<?php esc_attr_e( 'Go to the first page', 'woocommerce' ); ?>" href="#">«</a>
|
||||
<a class="prev-page disabled" title="<?php esc_attr_e( 'Go to the previous page', 'woocommerce' ); ?>" href="#">‹</a>
|
||||
<span class="paging-select">
|
||||
<label for="current-page-selector-1" class="screen-reader-text"><?php _e( 'Select Page', 'woocommerce' ); ?></label>
|
||||
<select class="page-selector" id="current-page-selector-1" title="<?php esc_attr_e( 'Current page', 'woocommerce' ); ?>">
|
||||
<?php for ( $i = 1; $i <= $variations_total_pages; $i++ ) : ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
<?php _ex( 'of', 'number of pages', 'woocommerce' ); ?> <span class="total-pages"><?php echo $variations_total_pages; ?></span>
|
||||
</span>
|
||||
<a class="next-page" title="<?php esc_attr_e( 'Go to the next page', 'woocommerce' ); ?>" href="#">›</a>
|
||||
<a class="last-page" title="<?php esc_attr_e( 'Go to the last page', 'woocommerce' ); ?>" href="#">»</a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
|
@ -601,7 +601,7 @@ class WC_AJAX {
|
|||
}
|
||||
|
||||
/**
|
||||
* Add variation via ajax function.
|
||||
* Add variation via ajax function. @todo CRUD
|
||||
*/
|
||||
public static function add_variation() {
|
||||
|
||||
|
@ -744,7 +744,7 @@ class WC_AJAX {
|
|||
}
|
||||
|
||||
/**
|
||||
* Link all variations via ajax function.
|
||||
* Link all variations via ajax function. @todo CRUD
|
||||
*/
|
||||
public static function link_all_variations() {
|
||||
|
||||
|
@ -2142,7 +2142,7 @@ class WC_AJAX {
|
|||
}
|
||||
|
||||
/**
|
||||
* Save variations via AJAX.
|
||||
* Save variations via AJAX. @todo CRUD
|
||||
*/
|
||||
public static function save_variations() {
|
||||
ob_start();
|
||||
|
@ -2191,7 +2191,7 @@ class WC_AJAX {
|
|||
}
|
||||
|
||||
/**
|
||||
* Bulk action - Toggle Enabled.
|
||||
* Bulk action - Toggle Enabled. @todo CRUD
|
||||
* @access private
|
||||
* @used-by bulk_edit_variations
|
||||
* @param array $variations
|
||||
|
|
|
@ -77,6 +77,19 @@ class WC_Product_Attribute implements ArrayAccess {
|
|||
return $terms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all data for this object.
|
||||
* @return array
|
||||
*/
|
||||
public function get_data() {
|
||||
return array_merge( $this->data, array(
|
||||
'is_visible' => $this->get_visible() ? 1 : 0,
|
||||
'is_variation' => $this->get_variation() ? 1 : 0,
|
||||
'is_taxonomy' => $this->is_taxonomy() ? 1 : 0,
|
||||
'value' => $this->is_taxonomy() ? '' : wc_implode_text_attributes( $this->get_options() ),
|
||||
) );
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Setters
|
||||
|
|
|
@ -1433,3 +1433,45 @@ function wc_maybe_store_user_agent( $user_login, $user ) {
|
|||
}
|
||||
}
|
||||
add_action( 'wp_login', 'wc_maybe_store_user_agent', 10, 2 );
|
||||
|
||||
/**
|
||||
* Based on wp_list_pluck, this calls a method instead of returning a property.
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @param array $list List of objects or arrays
|
||||
* @param int|string $callback_or_field Callback method from the object to place instead of the entire object
|
||||
* @param int|string $index_key Optional. Field from the object to use as keys for the new array.
|
||||
* Default null.
|
||||
* @return array Array of values.
|
||||
*/
|
||||
function wc_list_pluck( $list, $callback_or_field, $index_key = null ) {
|
||||
// Use wp_list_pluck if this isn't a callback
|
||||
$first_el = current( $list );
|
||||
if ( ! is_object( $first_el ) || ! is_callable( array( $first_el, $callback_or_field ) ) ) {
|
||||
return wp_list_pluck( $list, $callback_or_field, $index_key );
|
||||
}
|
||||
if ( ! $index_key ) {
|
||||
/*
|
||||
* This is simple. Could at some point wrap array_column()
|
||||
* if we knew we had an array of arrays.
|
||||
*/
|
||||
foreach ( $list as $key => $value ) {
|
||||
$list[ $key ] = $value->{$callback_or_field}();
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/*
|
||||
* When index_key is not set for a particular item, push the value
|
||||
* to the end of the stack. This is how array_column() behaves.
|
||||
*/
|
||||
$newlist = array();
|
||||
foreach ( $list as $value ) {
|
||||
if ( isset( $value->$index_key ) ) {
|
||||
$newlist[ $value->$index_key ] = $value->{$callback_or_field}();
|
||||
} else {
|
||||
$newlist[] = $value->{$callback_or_field}();
|
||||
}
|
||||
}
|
||||
return $newlist;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue