当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Admin_Meta_Boxes类代码示例

本文整理汇总了PHP中WC_Admin_Meta_Boxes的典型用法代码示例。如果您正苦于以下问题:PHP WC_Admin_Meta_Boxes类的具体用法?PHP WC_Admin_Meta_Boxes怎么用?PHP WC_Admin_Meta_Boxes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了WC_Admin_Meta_Boxes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wc_redirects__wc_admin_process_product_meta

function wc_redirects__wc_admin_process_product_meta($post_id)
{
    if (isset($_POST[WC_REDIRECTS__REDIRECTION_TYPE_META_NAME])) {
        $value = $_POST[WC_REDIRECTS__REDIRECTION_TYPE_META_NAME];
        $is_valid = false;
        if ($value === '') {
            $is_valid = true;
        } else {
            foreach (wc_redirects__get_valid_redirection_types() as $registration_type) {
                if ($value === $registration_type['name']) {
                    $is_valid = true;
                    break;
                }
            }
        }
        if (!$is_valid) {
            WC_Admin_Meta_Boxes::add_error(__('The selected Redirection Type is not valid.', 'wc_redirects'));
            return;
        }
        if ($value === '') {
            delete_post_meta($post_id, WC_REDIRECTS__REDIRECTION_TYPE_META_NAME);
        } else {
            update_post_meta($post_id, WC_REDIRECTS__REDIRECTION_TYPE_META_NAME, $value);
        }
    }
}
开发者ID:BurlesonBrad,项目名称:woocommerce-redirects,代码行数:26,代码来源:woocommerce-redirects-wc-admin.php

示例2: process_product_meta

 /**
  * Save subscription options.
  *
  * @param  int  $post_id
  * @return void
  */
 public static function process_product_meta($post_id)
 {
     // Get type.
     $product_type = empty($_POST['product-type']) ? 'simple' : sanitize_title(stripslashes($_POST['product-type']));
     $supported_types = WCS_ATT()->get_supported_product_types();
     if (in_array($product_type, $supported_types)) {
         // Save one time shipping option.
         update_post_meta($post_id, '_subscription_one_time_shipping', stripslashes(isset($_POST['_subscription_one_time_shipping']) ? 'yes' : 'no'));
         // Save subscription scheme options.
         if (isset($_POST['wcsatt_schemes'])) {
             $posted_schemes = stripslashes_deep($_POST['wcsatt_schemes']);
             $unique_schemes = array();
             foreach ($posted_schemes as $posted_scheme) {
                 // Copy variable type fields.
                 if ('variable' === $product_type) {
                     if (isset($posted_scheme['subscription_regular_price_variable'])) {
                         $posted_scheme['subscription_regular_price'] = $posted_scheme['subscription_regular_price_variable'];
                     }
                     if (isset($posted_scheme['subscription_sale_price_variable'])) {
                         $posted_scheme['subscription_sale_price'] = $posted_scheme['subscription_sale_price_variable'];
                     }
                     if (isset($posted_scheme['subscription_discount_variable'])) {
                         $posted_scheme['subscription_discount'] = $posted_scheme['subscription_discount_variable'];
                     }
                     if (isset($posted_scheme['subscription_pricing_method_variable'])) {
                         $posted_scheme['subscription_pricing_method'] = $posted_scheme['subscription_pricing_method_variable'];
                     }
                 }
                 // Format subscription prices.
                 if (isset($posted_scheme['subscription_regular_price'])) {
                     $posted_scheme['subscription_regular_price'] = $posted_scheme['subscription_regular_price'] === '' ? '' : wc_format_decimal($posted_scheme['subscription_regular_price']);
                 }
                 if (isset($posted_scheme['subscription_sale_price'])) {
                     $posted_scheme['subscription_sale_price'] = $posted_scheme['subscription_sale_price'] === '' ? '' : wc_format_decimal($posted_scheme['subscription_sale_price']);
                 }
                 if ('' !== $posted_scheme['subscription_sale_price']) {
                     $posted_scheme['subscription_price'] = $posted_scheme['subscription_sale_price'];
                 } else {
                     $posted_scheme['subscription_price'] = $posted_scheme['subscription_regular_price'] === '' ? '' : $posted_scheme['subscription_regular_price'];
                 }
                 // Format subscription discount.
                 if (isset($posted_scheme['subscription_discount'])) {
                     if (is_numeric($posted_scheme['subscription_discount'])) {
                         $discount = (double) wc_format_decimal($posted_scheme['subscription_discount']);
                         if ($discount < 0 || $discount > 100) {
                             WC_Admin_Meta_Boxes::add_error(__('Please enter positive subscription discount values, between 0-100.', WCS_ATT::TEXT_DOMAIN));
                             $posted_scheme['subscription_discount'] = '';
                         } else {
                             $posted_scheme['subscription_discount'] = $discount;
                         }
                     } else {
                         $posted_scheme['subscription_discount'] = '';
                     }
                 } else {
                     $posted_scheme['subscription_discount'] = '';
                 }
                 // Validate price override method.
                 if (isset($posted_scheme['subscription_pricing_method']) && $posted_scheme['subscription_pricing_method'] === 'override') {
                     if ($posted_scheme['subscription_price'] === '' && $posted_scheme['subscription_regular_price'] === '') {
                         $posted_scheme['subscription_pricing_method'] = 'inherit';
                     }
                 } else {
                     $posted_scheme['subscription_pricing_method'] = 'inherit';
                 }
                 // Construct scheme id.
                 $scheme_id = $posted_scheme['subscription_period_interval'] . '_' . $posted_scheme['subscription_period'] . '_' . $posted_scheme['subscription_length'];
                 $unique_schemes[$scheme_id] = $posted_scheme;
                 $unique_schemes[$scheme_id]['id'] = $scheme_id;
             }
             update_post_meta($post_id, '_wcsatt_schemes', $unique_schemes);
         } else {
             delete_post_meta($post_id, '_wcsatt_schemes');
         }
         // Save default status.
         if (isset($_POST['_wcsatt_default_status'])) {
             update_post_meta($post_id, '_wcsatt_default_status', stripslashes($_POST['_wcsatt_default_status']));
         }
         // Save one-time status.
         $force_subscription = isset($_POST['_wcsatt_force_subscription']) ? 'yes' : 'no';
         update_post_meta($post_id, '_wcsatt_force_subscription', $force_subscription);
         // Set regular price as ZERO should the shop owner forget.
         // This helps make WooCommerce think it's still available for purchase.
         if ('yes' === $force_subscription && empty($_POST['_regular_price'])) {
             update_post_meta($post_id, '_regular_price', wc_format_decimal(0));
             update_post_meta($post_id, '_price', wc_format_decimal(0));
         }
         // Save prompt.
         if (!empty($_POST['_wcsatt_subscription_prompt'])) {
             $prompt = wp_kses_post(stripslashes($_POST['_wcsatt_subscription_prompt']));
             update_post_meta($post_id, '_wcsatt_subscription_prompt', $prompt);
         } else {
             delete_post_meta($post_id, '_wcsatt_subscription_prompt');
         }
     } else {
//.........这里部分代码省略.........
开发者ID:seb86,项目名称:woocommerce-subscribe-to-all-the-things,代码行数:101,代码来源:class-wcsatt-admin.php

示例3: save

 /**
  * Save meta box data.
  *
  * @param int $post_id
  * @param WP_Post $post
  */
 public static function save($post_id, $post)
 {
     global $wpdb;
     // Check for dupe coupons
     $coupon_code = apply_filters('woocommerce_coupon_code', $post->post_title);
     $id_from_code = wc_get_coupon_id_by_code($coupon_code, $post_id);
     if ($id_from_code) {
         WC_Admin_Meta_Boxes::add_error(__('Coupon code already exists - customers will use the latest coupon with this code.', 'woocommerce'));
     }
     $coupon = new WC_Coupon($post_id);
     $coupon->set_props(array('code' => $post->post_title, 'discount_type' => wc_clean($_POST['discount_type']), 'amount' => wc_format_decimal($_POST['coupon_amount']), 'date_expires' => wc_clean($_POST['expiry_date']), 'individual_use' => isset($_POST['individual_use']), 'product_ids' => array_filter(array_map('intval', explode(',', $_POST['product_ids']))), 'excluded_product_ids' => array_filter(array_map('intval', explode(',', $_POST['exclude_product_ids']))), 'usage_limit' => absint($_POST['usage_limit']), 'usage_limit_per_user' => absint($_POST['usage_limit_per_user']), 'limit_usage_to_x_items' => absint($_POST['limit_usage_to_x_items']), 'free_shipping' => isset($_POST['free_shipping']), 'product_categories' => array_filter(array_map('intval', (array) $_POST['product_categories'])), 'excluded_product_categories' => array_filter(array_map('intval', (array) $_POST['exclude_product_categories'])), 'exclude_sale_items' => isset($_POST['exclude_sale_items']), 'minimum_amount' => wc_format_decimal($_POST['minimum_amount']), 'maximum_amount' => wc_format_decimal($_POST['maximum_amount']), 'email_restrictions' => array_filter(array_map('trim', explode(',', wc_clean($_POST['customer_email']))))));
     $coupon->save();
     do_action('woocommerce_coupon_options_save', $post_id);
 }
开发者ID:johnulist,项目名称:woocommerce,代码行数:20,代码来源:class-wc-meta-box-coupon-data.php

示例4: save_variations

 /**
  * Save variations via AJAX
  */
 public static function save_variations()
 {
     ob_start();
     check_ajax_referer('save-variations', 'security');
     // Check permissions again and make sure we have what we need
     if (!current_user_can('edit_products') || empty($_POST) || empty($_POST['product_id'])) {
         die(-1);
     }
     // Remove previous meta box errors
     WC_Admin_Meta_Boxes::$meta_box_errors = array();
     $product_id = absint($_POST['product_id']);
     WC_Meta_Box_Product_Data::save_variations($product_id, get_post($product_id));
     do_action('woocommerce_ajax_save_product_variations', $product_id);
     // Clear cache/transients
     wc_delete_product_transients($product_id);
     if ($errors = WC_Admin_Meta_Boxes::$meta_box_errors) {
         echo '<div class="error notice is-dismissible">';
         foreach ($errors as $error) {
             echo '<p>' . wp_kses_post($error) . '</p>';
         }
         echo '<button type="button" class="notice-dismiss"><span class="screen-reader-text">' . __('Dismiss this notice.', 'woocommerce') . '</span></button>';
         echo '</div>';
         delete_option('woocommerce_meta_box_errors');
     }
     die;
 }
开发者ID:kythanbao,项目名称:woocommerce,代码行数:29,代码来源:class-wc-ajax.php

示例5: save_errors

 /**
  * Compatibility function to use the new WC_Admin_Meta_Boxes class for the save_errors() function
  *
  * @since 1.0-1
  * @return old save_errors function or new class
  */
 public static function save_errors()
 {
     if (self::is_wc_version_gte_2_1()) {
         WC_Admin_Meta_Boxes::save_errors();
     } else {
         woocommerce_meta_boxes_save_errors();
     }
 }
开发者ID:AndyA,项目名称:River,代码行数:14,代码来源:class-wc-swatches-compatibility.php

示例6: save_variations

 /**
  * Save meta box data.
  *
  * @param int $post_id
  * @param WP_Post $post
  */
 public static function save_variations($post_id, $post)
 {
     if (isset($_POST['variable_post_id'])) {
         $parent = wc_get_product($post_id);
         $max_loop = max(array_keys($_POST['variable_post_id']));
         $data_store = $parent->get_data_store();
         $data_store->sort_all_product_variations($parent->get_id());
         for ($i = 0; $i <= $max_loop; $i++) {
             if (!isset($_POST['variable_post_id'][$i])) {
                 continue;
             }
             $variation_id = absint($_POST['variable_post_id'][$i]);
             $variation = new WC_Product_Variation($variation_id);
             $errors = $variation->set_props(array('status' => isset($_POST['variable_enabled'][$i]) ? 'publish' : 'private', 'menu_order' => wc_clean($_POST['variation_menu_order'][$i]), 'regular_price' => wc_clean($_POST['variable_regular_price'][$i]), 'sale_price' => wc_clean($_POST['variable_sale_price'][$i]), 'virtual' => isset($_POST['variable_is_virtual'][$i]), 'downloadable' => isset($_POST['variable_is_downloadable'][$i]), 'date_on_sale_from' => wc_clean($_POST['variable_sale_price_dates_from'][$i]), 'date_on_sale_to' => wc_clean($_POST['variable_sale_price_dates_to'][$i]), 'description' => wp_kses_post(wc_sanitize_textarea($_POST['variable_description'][$i])), 'download_limit' => wc_clean($_POST['variable_download_limit'][$i]), 'download_expiry' => wc_clean($_POST['variable_download_expiry'][$i]), 'downloads' => self::prepare_downloads(isset($_POST['_wc_variation_file_names'][$variation_id]) ? $_POST['_wc_variation_file_names'][$variation_id] : array(), isset($_POST['_wc_variation_file_urls'][$variation_id]) ? $_POST['_wc_variation_file_urls'][$variation_id] : array(), isset($_POST['_wc_variation_file_hashes'][$variation_id]) ? $_POST['_wc_variation_file_hashes'][$variation_id] : array()), 'manage_stock' => isset($_POST['variable_manage_stock'][$i]), 'stock_quantity' => wc_clean($_POST['variable_stock'][$i]), 'backorders' => wc_clean($_POST['variable_backorders'][$i]), 'stock_status' => wc_clean($_POST['variable_stock_status'][$i]), 'image_id' => wc_clean($_POST['upload_image_id'][$i]), 'attributes' => self::prepare_set_attributes($parent->get_attributes(), 'attribute_', $i), 'sku' => isset($_POST['variable_sku'][$i]) ? wc_clean($_POST['variable_sku'][$i]) : '', 'weight' => isset($_POST['variable_weight'][$i]) ? wc_clean($_POST['variable_weight'][$i]) : '', 'length' => isset($_POST['variable_length'][$i]) ? wc_clean($_POST['variable_length'][$i]) : '', 'width' => isset($_POST['variable_width'][$i]) ? wc_clean($_POST['variable_width'][$i]) : '', 'height' => isset($_POST['variable_height'][$i]) ? wc_clean($_POST['variable_height'][$i]) : '', 'shipping_class_id' => wc_clean($_POST['variable_shipping_class'][$i]), 'tax_class' => wc_clean($_POST['variable_tax_class'][$i])));
             if (is_wp_error($errors)) {
                 WC_Admin_Meta_Boxes::add_error($errors->get_error_message());
             }
             $variation->save();
             do_action('woocommerce_save_product_variation', $variation_id, $i);
         }
     }
 }
开发者ID:shivapoudel,项目名称:woocommerce,代码行数:28,代码来源:class-wc-meta-box-product-data.php

示例7: sync

 /**
  * Sync the variable product with it's children.
  */
 public static function sync($product_id)
 {
     global $wpdb;
     $children = get_posts(array('post_parent' => $product_id, 'posts_per_page' => -1, 'post_type' => 'product_variation', 'fields' => 'ids', 'post_status' => 'publish'));
     // No published variations - product won't be purchasable.
     if (!$children) {
         update_post_meta($product_id, '_price', '');
         delete_transient('wc_products_onsale');
         if (is_admin() && 'publish' === get_post_status($product_id)) {
             WC_Admin_Meta_Boxes::add_error(__('This variable product has no active variations. Add or enable variations to allow this product to be purchased.', 'woocommerce'));
         }
         // Loop the variations
     } else {
         // Set the variable product to be virtual/downloadable if all children are virtual/downloadable
         foreach (array('_downloadable', '_virtual') as $meta_key) {
             $all_variations_yes = true;
             foreach ($children as $child_id) {
                 if ('yes' != get_post_meta($child_id, $meta_key, true)) {
                     $all_variations_yes = false;
                     break;
                 }
             }
             update_post_meta($product_id, $meta_key, true === $all_variations_yes ? 'yes' : 'no');
         }
         // Main active prices
         $min_price = null;
         $max_price = null;
         $min_price_id = null;
         $max_price_id = null;
         // Regular prices
         $min_regular_price = null;
         $max_regular_price = null;
         $min_regular_price_id = null;
         $max_regular_price_id = null;
         // Sale prices
         $min_sale_price = null;
         $max_sale_price = null;
         $min_sale_price_id = null;
         $max_sale_price_id = null;
         foreach (array('price', 'regular_price', 'sale_price') as $price_type) {
             foreach ($children as $child_id) {
                 $child_price = get_post_meta($child_id, '_' . $price_type, true);
                 // Skip non-priced variations
                 if ($child_price === '') {
                     continue;
                 }
                 // Skip hidden variations
                 if ('yes' === get_option('woocommerce_hide_out_of_stock_items')) {
                     $stock = get_post_meta($child_id, '_stock', true);
                     if ($stock !== "" && $stock <= get_option('woocommerce_notify_no_stock_amount')) {
                         continue;
                     }
                 }
                 // Find min price
                 if (is_null(${"min_{$price_type}"}) || $child_price < ${"min_{$price_type}"}) {
                     ${"min_{$price_type}"} = $child_price;
                     ${"min_{$price_type}_id"} = $child_id;
                 }
                 // Find max price
                 if ($child_price > ${"max_{$price_type}"}) {
                     ${"max_{$price_type}"} = $child_price;
                     ${"max_{$price_type}_id"} = $child_id;
                 }
             }
             // Store prices
             update_post_meta($product_id, '_min_variation_' . $price_type, ${"min_{$price_type}"});
             update_post_meta($product_id, '_max_variation_' . $price_type, ${"max_{$price_type}"});
             // Store ids
             update_post_meta($product_id, '_min_' . $price_type . '_variation_id', ${"min_{$price_type}_id"});
             update_post_meta($product_id, '_max_' . $price_type . '_variation_id', ${"max_{$price_type}_id"});
         }
         // Sync _price meta
         delete_post_meta($product_id, '_price');
         add_post_meta($product_id, '_price', $min_price, false);
         add_post_meta($product_id, '_price', $max_price, false);
         delete_transient('wc_products_onsale');
         // Sync attributes
         self::sync_attributes($product_id, $children);
         do_action('woocommerce_variable_product_sync', $product_id, $children);
     }
 }
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:84,代码来源:class-wc-product-variable.php

示例8: sync

 /**
  * Sync the variable product with it's children
  */
 public static function sync($product_id)
 {
     global $wpdb;
     $children = get_posts(array('post_parent' => $product_id, 'posts_per_page' => -1, 'post_type' => 'product_variation', 'fields' => 'ids', 'post_status' => 'publish'));
     // No published variations - update parent post status. Use $wpdb to prevent endless loop on save_post hooks.
     if (!$children && get_post_status($product_id) == 'publish') {
         $wpdb->update($wpdb->posts, array('post_status' => 'draft'), array('ID' => $product_id));
         if (is_admin()) {
             WC_Admin_Meta_Boxes::add_error(__('This variable product has no active variations so cannot be published. Changing status to draft.', 'woocommerce'));
         }
         // Loop the variations
     } else {
         // Set the variable product to be virtual/downloadable if all children are virtual/downloadable
         foreach (array('_downloadable', '_virtual') as $meta_key) {
             $all_variations_yes = true;
             foreach ($children as $child_id) {
                 if ('yes' != get_post_meta($child_id, $meta_key, true)) {
                     $all_variations_yes = false;
                     break;
                 }
             }
             update_post_meta($product_id, $meta_key, true === $all_variations_yes ? 'yes' : 'no');
         }
         // Main active prices
         $min_price = null;
         $max_price = null;
         $min_price_id = null;
         $max_price_id = null;
         // Regular prices
         $min_regular_price = null;
         $max_regular_price = null;
         $min_regular_price_id = null;
         $max_regular_price_id = null;
         // Sale prices
         $min_sale_price = null;
         $max_sale_price = null;
         $min_sale_price_id = null;
         $max_sale_price_id = null;
         foreach (array('price', 'regular_price', 'sale_price') as $price_type) {
             foreach ($children as $child_id) {
                 $child_price = get_post_meta($child_id, '_' . $price_type, true);
                 // Skip non-priced variations
                 if ($child_price === '') {
                     continue;
                 }
                 // Skip hidden variations
                 if ('yes' === get_option('woocommerce_hide_out_of_stock_items')) {
                     $stock = get_post_meta($child_id, '_stock', true);
                     if ($stock !== "" && $stock <= get_option('woocommerce_notify_no_stock_amount')) {
                         continue;
                     }
                 }
                 // Find min price
                 if (is_null(${"min_{$price_type}"}) || $child_price < ${"min_{$price_type}"}) {
                     ${"min_{$price_type}"} = $child_price;
                     ${"min_{$price_type}_id"} = $child_id;
                 }
                 // Find max price
                 if ($child_price > ${"max_{$price_type}"}) {
                     ${"max_{$price_type}"} = $child_price;
                     ${"max_{$price_type}_id"} = $child_id;
                 }
             }
             // Store prices
             update_post_meta($product_id, '_min_variation_' . $price_type, ${"min_{$price_type}"});
             update_post_meta($product_id, '_max_variation_' . $price_type, ${"max_{$price_type}"});
             // Store ids
             update_post_meta($product_id, '_min_' . $price_type . '_variation_id', ${"min_{$price_type}_id"});
             update_post_meta($product_id, '_max_' . $price_type . '_variation_id', ${"max_{$price_type}_id"});
         }
         // The VARIABLE PRODUCT price should equal the min price of any type
         update_post_meta($product_id, '_price', $min_price);
         delete_transient('wc_products_onsale');
         // Sync attributes
         self::sync_attributes($product_id, $children);
         do_action('woocommerce_variable_product_sync', $product_id, $children);
     }
 }
开发者ID:EstefanoCruz,项目名称:woocommerce,代码行数:81,代码来源:class-wc-product-variable.php

示例9: sync

 /**
  * Sync the variable product with it's children
  */
 public static function sync($product_id)
 {
     global $wpdb;
     $children = get_posts(array('post_parent' => $product_id, 'posts_per_page' => -1, 'post_type' => 'product_variation', 'fields' => 'ids', 'post_status' => 'publish'));
     // No published variations - update parent post status. Use $wpdb to prevent endless loop on save_post hooks.
     if (!$children && get_post_status($product_id) == 'publish') {
         $wpdb->update($wpdb->posts, array('post_status' => 'draft'), array('ID' => $product_id));
         if (is_admin()) {
             WC_Admin_Meta_Boxes::add_error(__('This variable product has no active variations so cannot be published. Changing status to draft.', 'woocommerce'));
         }
         // Loop the variations
     } else {
         $min_price = null;
         $max_price = null;
         $min_price_id = null;
         $max_price_id = null;
         foreach ($children as $child) {
             $child_price = get_post_meta($child, '_price', true);
             if ($child_price === '') {
                 continue;
             }
             if ($child_price > $max_price) {
                 $max_price = $child_price;
                 $max_price_id = $child;
             }
             if (is_null($min_price) || $child_price < $min_price) {
                 $min_price = $child_price;
                 $min_price_id = $child;
             }
         }
         // Store prices
         update_post_meta($product_id, '_price', $min_price);
         update_post_meta($product_id, '_min_variation_price', $min_price);
         update_post_meta($product_id, '_max_variation_price', $max_price);
         // Store IDS
         update_post_meta($product_id, '_min_price_variation_id', $min_price_id);
         update_post_meta($product_id, '_max_price_variation_id', $max_price_id);
         do_action('woocommerce_variable_product_sync', $product_id, $children);
         wc_delete_product_transients($product_id);
     }
 }
开发者ID:hoonio,项目名称:PhoneAfrika,代码行数:44,代码来源:class-wc-product-variable.php

示例10: add_admin_error

 /**
  * Add and return admin errors.
  *
  * @param  string $error
  * @return string
  */
 private function add_admin_error($error)
 {
     WC_Admin_Meta_Boxes::add_error($error);
     return $error;
 }
开发者ID:ajay786singh,项目名称:viriditas-1,代码行数:11,代码来源:class-wc-cp-admin.php

示例11: add_admin_error

 /**
  * Add admin errors.
  *
  * @param  string $error
  * @return string
  */
 public function add_admin_error($error)
 {
     WC_Admin_Meta_Boxes::add_error($error);
 }
开发者ID:ajay786singh,项目名称:viriditas-1,代码行数:10,代码来源:class-wc-pb-admin.php

示例12: easy_booking_save_variation_booking_options

 public function easy_booking_save_variation_booking_options($variation_id, $i)
 {
     $is_bookable = isset($_POST['_var_booking_option'][$i]) ? 'yes' : '';
     $data = array('booking_min' => $_POST['_var_booking_min'][$i], 'booking_max' => $_POST['_var_booking_max'][$i], 'first_available_date' => $_POST['_var_first_available_date'][$i]);
     foreach ($data as $name => $value) {
         switch ($value) {
             case '':
                 ${$name} = '';
                 break;
             case 0:
                 ${$name} = '0';
                 break;
             default:
                 ${$name} = absint($value);
                 break;
         }
     }
     if ($booking_min != 0 && $booking_max != 0 && $booking_min > $booking_max) {
         WC_Admin_Meta_Boxes::add_error(__('Minimum booking duration must be inferior to maximum booking duration', 'easy_booking'));
     } else {
         update_post_meta($variation_id, '_booking_min', $booking_min);
         update_post_meta($variation_id, '_booking_max', $booking_max);
     }
     update_post_meta($variation_id, '_first_available_date', $first_available_date);
     update_post_meta($variation_id, '_booking_option', $is_bookable);
 }
开发者ID:noikiy,项目名称:woocommerce-easy-booking-system,代码行数:26,代码来源:class-wceb-product-settings.php

示例13: get_storedfiles

 /**
  * return a list of available storedfiles
  */
 public function get_storedfiles()
 {
     if (is_null($this->storedfiles)) {
         // check of er een connectie is
         if (!$this->connected) {
             return false;
         }
         // Set authentication
         $args = array('reject_unsafe_urls' => false, 'headers' => array('Authorization' => 'Basic ' . base64_encode($this->contractname . ':' . $this->contractpassword)));
         $url = str_replace('ACCOUNTKEY', $this->accountkey, WC_BooXtream::listepubfilesurl) . '?limit=0';
         $response = wp_safe_remote_get($url, $args);
         if (is_array($response) && 200 === $response['response']['code']) {
             $result = json_decode($response['body']);
             if (is_object($result) && isset($result->message->response)) {
                 $this->storedfiles = array('' => __('Select an e-book', 'woocommerce_booxtream'));
                 foreach ($result->message->response as $file) {
                     if (isset($file->StoredFileKey)) {
                         $this->storedfiles[$file->StoredFileKey] = $file->FileName;
                     }
                 }
                 /*
                  * Save storedfiles
                  */
                 update_option($this->plugin_id . $this->id . '_storedfiles', $this->storedfiles);
             } else {
                 WC_Admin_Meta_Boxes::add_error(__('Could not retrieve list of stored files', 'woocommerce_booxtream'));
                 return false;
             }
         } else {
             WC_Admin_Meta_Boxes::add_error(__('Could not retrieve list of stored files', 'woocommerce_booxtream'));
             return false;
         }
     }
     return $this->storedfiles;
 }
开发者ID:BooXtream,项目名称:BooXtream-WooCommerce,代码行数:38,代码来源:class-wc-booxtream-integration.php

示例14: save_variations

 /**
  * Save variations via AJAX.
  */
 public static function save_variations()
 {
     ob_start();
     check_ajax_referer('save-variations', 'security');
     // Check permissions again and make sure we have what we need
     if (!current_user_can('edit_products') || empty($_POST) || empty($_POST['product_id'])) {
         die(-1);
     }
     // Remove previous meta box errors
     WC_Admin_Meta_Boxes::$meta_box_errors = array();
     $product_id = absint($_POST['product_id']);
     $product_type = empty($_POST['product-type']) ? 'simple' : sanitize_title(stripslashes($_POST['product-type']));
     $product_type_terms = wp_get_object_terms($product_id, 'product_type');
     // If the product type hasn't been set or it has changed, update it before saving variations
     if (empty($product_type_terms) || $product_type !== sanitize_title(current($product_type_terms)->name)) {
         wp_set_object_terms($product_id, $product_type, 'product_type');
     }
     WC_Meta_Box_Product_Data::save_variations($product_id, get_post($product_id));
     do_action('woocommerce_ajax_save_product_variations', $product_id);
     // Clear cache/transients
     wc_delete_product_transients($product_id);
     if ($errors = WC_Admin_Meta_Boxes::$meta_box_errors) {
         echo '<div class="error notice is-dismissible">';
         foreach ($errors as $error) {
             echo '<p>' . wp_kses_post($error) . '</p>';
         }
         echo '<button type="button" class="notice-dismiss"><span class="screen-reader-text">' . __('Dismiss this notice.', 'woocommerce') . '</span></button>';
         echo '</div>';
         delete_option('woocommerce_meta_box_errors');
     }
     die;
 }
开发者ID:tronsha,项目名称:woocommerce,代码行数:35,代码来源:class-wc-ajax.php

示例15: process_meta

 /**
  * Process, verify and save product data
  * @param  int 	$post_id
  * @return void
  */
 public static function process_meta($post_id)
 {
     // Min container size
     $min_qty = intval(get_post_meta($post_id, '_mnm_container_size', true));
     // Max container size
     $max_qty = isset($_POST['mnm_max_container_size']) ? intval(wc_clean($_POST['mnm_max_container_size'])) : $min_qty;
     if ($max_qty > 0 && $min_qty > $max_qty) {
         $max_qty = $min_qty;
         WC_Admin_Meta_Boxes::add_error(__('The maximum Mix & Match container size cannot be smaller than the minimum container size.', 'woocommerce-mix-and-match-min-max-quantities'));
     }
     update_post_meta($post_id, '_mnm_max_container_size', $max_qty);
     return $post_id;
 }
开发者ID:unsub,项目名称:woocommerce-mix-and-match-min-max,代码行数:18,代码来源:woocommerce-mix-and-match-min-max-quantities.php


注:本文中的WC_Admin_Meta_Boxes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。