handle package reference

This commit is contained in:
Almira Krdzic
2018-10-18 13:10:55 +02:00
parent 76e9b10235
commit 1ed7310994
3 changed files with 38 additions and 2 deletions

View File

@@ -32,6 +32,9 @@ class Wiaas_Package {
$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'])) {
$data = self::_append_package_prices($data, $package, $request);

View File

@@ -7,6 +7,8 @@ class Wiaas_Product {
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_taxonomy_args_product_tag', array(__CLASS__, 'manage_tags_as_references'));
}
/**
@@ -16,7 +18,7 @@ class Wiaas_Product {
*
* @param $args
*
* @return mixed
* @return array
*/
public static function manage_product_settings($args) {
@@ -34,6 +36,37 @@ class Wiaas_Product {
$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;
}
}

View File

@@ -43,7 +43,7 @@ function extractGroups(wcPackageGroups) {
export const fromWCPackage = wcPackage => {
return {
id: wcPackage.id,
reference: wcPackage.slug,
reference: wcPackage.reference,
image: wcPackage.images[0].src || DEFAULT_PACKAGE_IMG,
hasImage: !!wcPackage.images.length,
name: wcPackage.name,