handle package reference
This commit is contained in:
@@ -32,6 +32,9 @@ class Wiaas_Package {
|
|||||||
|
|
||||||
$data = self::_append_country_info($data, $package, $request);
|
$data = self::_append_country_info($data, $package, $request);
|
||||||
|
|
||||||
|
// append package reference field
|
||||||
|
$data['reference'] = ! empty($data['tags']) ? $data['tags'][0]['name'] : '';
|
||||||
|
|
||||||
if (isset($request['id'])) {
|
if (isset($request['id'])) {
|
||||||
$data = self::_append_package_prices($data, $package, $request);
|
$data = self::_append_package_prices($data, $package, $request);
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ class Wiaas_Product {
|
|||||||
require_once dirname( __FILE__ ) . '/product/class-wiaas-product-supplier.php';
|
require_once dirname( __FILE__ ) . '/product/class-wiaas-product-supplier.php';
|
||||||
|
|
||||||
add_filter('woocommerce_register_post_type_product', array(__CLASS__, 'manage_product_settings'));
|
add_filter('woocommerce_register_post_type_product', array(__CLASS__, 'manage_product_settings'));
|
||||||
|
|
||||||
|
add_filter('woocommerce_taxonomy_args_product_tag', array(__CLASS__, 'manage_tags_as_references'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,7 +18,7 @@ class Wiaas_Product {
|
|||||||
*
|
*
|
||||||
* @param $args
|
* @param $args
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function manage_product_settings($args) {
|
public static function manage_product_settings($args) {
|
||||||
|
|
||||||
@@ -34,6 +36,37 @@ class Wiaas_Product {
|
|||||||
$args['supports'] = array( 'title', 'thumbnail' );
|
$args['supports'] = array( 'title', 'thumbnail' );
|
||||||
|
|
||||||
|
|
||||||
|
return $args;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide default metabox for product tags
|
||||||
|
* @param $args
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function manage_tags_as_references($args) {
|
||||||
|
// hide metabox
|
||||||
|
$args['meta_box_cb'] = false;
|
||||||
|
|
||||||
|
// update labels
|
||||||
|
$args['labels'] = array(
|
||||||
|
'name' => __( 'Product references', 'wiaas' ),
|
||||||
|
'singular_name' => __( 'Reference', 'wiaas' ),
|
||||||
|
'menu_name' => _x( 'References', 'Admin menu name', 'wiaas' ),
|
||||||
|
'search_items' => __( 'Search references', 'wiaas' ),
|
||||||
|
'all_items' => __( 'All references', 'wiaas' ),
|
||||||
|
'edit_item' => __( 'Edit reference', 'wiaas' ),
|
||||||
|
'update_item' => __( 'Update reference', 'wiaas' ),
|
||||||
|
'add_new_item' => __( 'Add new reference', 'wiaas' ),
|
||||||
|
'new_item_name' => __( 'New reference name', 'wiaas' ),
|
||||||
|
'popular_items' => __( 'Popular references', 'wiaas' ),
|
||||||
|
'separate_items_with_commas' => __( 'Separate references with commas', 'wiaas' ),
|
||||||
|
'add_or_remove_items' => __( 'Add or remove references', 'wiaas' ),
|
||||||
|
'choose_from_most_used' => __( 'Choose from the most used references', 'wiaas' ),
|
||||||
|
'not_found' => __( 'No references found', 'wiaas' ),
|
||||||
|
);
|
||||||
|
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ function extractGroups(wcPackageGroups) {
|
|||||||
export const fromWCPackage = wcPackage => {
|
export const fromWCPackage = wcPackage => {
|
||||||
return {
|
return {
|
||||||
id: wcPackage.id,
|
id: wcPackage.id,
|
||||||
reference: wcPackage.slug,
|
reference: wcPackage.reference,
|
||||||
image: wcPackage.images[0].src || DEFAULT_PACKAGE_IMG,
|
image: wcPackage.images[0].src || DEFAULT_PACKAGE_IMG,
|
||||||
hasImage: !!wcPackage.images.length,
|
hasImage: !!wcPackage.images.length,
|
||||||
name: wcPackage.name,
|
name: wcPackage.name,
|
||||||
|
|||||||
Reference in New Issue
Block a user