• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP WC_Admin_Meta_Boxes类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: save

 /**
  * Save meta box data
  */
 public static function save($post_id, $post)
 {
     global $wpdb;
     // Ensure coupon code is correctly formatted
     $post->post_title = apply_filters('woocommerce_coupon_code', $post->post_title);
     $wpdb->update($wpdb->posts, array('post_title' => $post->post_title), array('ID' => $post_id));
     // Check for dupe coupons
     $coupon_found = $wpdb->get_var($wpdb->prepare("\n\t\t\tSELECT {$wpdb->posts}.ID\n\t\t\tFROM {$wpdb->posts}\n\t\t\tWHERE {$wpdb->posts}.post_type = 'shop_coupon'\n\t\t\tAND {$wpdb->posts}.post_status = 'publish'\n\t\t\tAND {$wpdb->posts}.post_title = '%s'\n\t\t\tAND {$wpdb->posts}.ID != %s\n\t\t ", $post->post_title, $post_id));
     if ($coupon_found) {
         WC_Admin_Meta_Boxes::add_error(__('Coupon code already exists - customers will use the latest coupon with this code.', 'woocommerce'));
     }
     // Add/Replace data to array
     $type = wc_clean($_POST['discount_type']);
     $amount = wc_format_decimal($_POST['coupon_amount']);
     $usage_limit = empty($_POST['usage_limit']) ? '' : absint($_POST['usage_limit']);
     $usage_limit_per_user = empty($_POST['usage_limit_per_user']) ? '' : absint($_POST['usage_limit_per_user']);
     $limit_usage_to_x_items = empty($_POST['limit_usage_to_x_items']) ? '' : absint($_POST['limit_usage_to_x_items']);
     $individual_use = isset($_POST['individual_use']) ? 'yes' : 'no';
     $expiry_date = wc_clean($_POST['expiry_date']);
     $apply_before_tax = isset($_POST['apply_before_tax']) ? 'yes' : 'no';
     $free_shipping = isset($_POST['free_shipping']) ? 'yes' : 'no';
     $exclude_sale_items = isset($_POST['exclude_sale_items']) ? 'yes' : 'no';
     $minimum_amount = wc_format_decimal($_POST['minimum_amount']);
     $maximum_amount = wc_format_decimal($_POST['maximum_amount']);
     $customer_email = array_filter(array_map('trim', explode(',', wc_clean($_POST['customer_email']))));
     if (isset($_POST['product_ids'])) {
         $product_ids = implode(',', array_filter(array_map('intval', (array) $_POST['product_ids'])));
     } else {
         $product_ids = '';
     }
     if (isset($_POST['exclude_product_ids'])) {
         $exclude_product_ids = implode(',', array_filter(array_map('intval', (array) $_POST['exclude_product_ids'])));
     } else {
         $exclude_product_ids = '';
     }
     $product_categories = isset($_POST['product_categories']) ? array_map('intval', $_POST['product_categories']) : array();
     $exclude_product_categories = isset($_POST['exclude_product_categories']) ? array_map('intval', $_POST['exclude_product_categories']) : array();
     // Save
     update_post_meta($post_id, 'discount_type', $type);
     update_post_meta($post_id, 'coupon_amount', $amount);
     update_post_meta($post_id, 'individual_use', $individual_use);
     update_post_meta($post_id, 'product_ids', $product_ids);
     update_post_meta($post_id, 'exclude_product_ids', $exclude_product_ids);
     update_post_meta($post_id, 'usage_limit', $usage_limit);
     update_post_meta($post_id, 'usage_limit_per_user', $usage_limit_per_user);
     update_post_meta($post_id, 'limit_usage_to_x_items', $limit_usage_to_x_items);
     update_post_meta($post_id, 'expiry_date', $expiry_date);
     update_post_meta($post_id, 'apply_before_tax', $apply_before_tax);
     update_post_meta($post_id, 'free_shipping', $free_shipping);
     update_post_meta($post_id, 'exclude_sale_items', $exclude_sale_items);
     update_post_meta($post_id, 'product_categories', $product_categories);
     update_post_meta($post_id, 'exclude_product_categories', $exclude_product_categories);
     update_post_meta($post_id, 'minimum_amount', $minimum_amount);
     update_post_meta($post_id, 'maximum_amount', $maximum_amount);
     update_post_meta($post_id, 'customer_email', $customer_email);
     do_action('woocommerce_coupon_options_save', $post_id);
 }
开发者ID:anagio,项目名称:woocommerce,代码行数:60,代码来源:class-wc-meta-box-coupon-data.php


示例17: save

 /**
  * Save meta box data
  */
 public static function save($post_id, $post)
 {
     global $wpdb;
     // Add any default post meta
     add_post_meta($post_id, 'total_sales', '0', true);
     // Get types
     $product_type = empty($_POST['product-type']) ? 'simple' : sanitize_title(stripslashes($_POST['product-type']));
     $is_downloadable = isset($_POST['_downloadable']) ? 'yes' : 'no';
     $is_virtual = isset($_POST['_virtual']) ? 'yes' : 'no';
     // Product type + Downloadable/Virtual
     wp_set_object_terms($post_id, $product_type, 'product_type');
     update_post_meta($post_id, '_downloadable', $is_downloadable);
     update_post_meta($post_id, '_virtual', $is_virtual);
     // Update post meta
     if (isset($_POST['_regular_price'])) {
         update_post_meta($post_id, '_regular_price', $_POST['_regular_price'] === '' ? '' : wc_format_decimal($_POST['_regular_price']));
     }
     if (isset($_POST['_sale_price'])) {
         update_post_meta($post_id, '_sale_price', $_POST['_sale_price'] === '' ? '' : wc_format_decimal($_POST['_sale_price']));
     }
     if (isset($_POST['_tax_status'])) {
         update_post_meta($post_id, '_tax_status', stripslashes($_POST['_tax_status']));
     }
     if (isset($_POST['_tax_class'])) {
         update_post_meta($post_id, '_tax_class', stripslashes($_POST['_tax_class']));
     }
     if (isset($_POST['_visibility'])) {
         update_post_meta($post_id, '_visibility', stripslashes($_POST['_visibility']));
     }
     if (isset($_POST['_purchase_note'])) {
         update_post_meta($post_id, '_purchase_note', stripslashes($_POST['_purchase_note']));
     }
     update_post_meta($post_id, '_featured', isset($_POST['_featured']) ? 'yes' : 'no');
     // Dimensions
     if ($is_virtual == 'no') {
         if (isset($_POST['_weight'])) {
             update_post_meta($post_id, '_weight', $_POST['_weight'] === '' ? '' : wc_format_decimal($_POST['_weight']));
         }
         if (isset($_POST['_length'])) {
             update_post_meta($post_id, '_length', $_POST['_length'] === '' ? '' : wc_format_decimal($_POST['_length']));
         }
         if (isset($_POST['_width'])) {
             update_post_meta($post_id, '_width', $_POST['_width'] === '' ? '' : wc_format_decimal($_POST['_width']));
         }
         if (isset($_POST['_height'])) {
             update_post_meta($post_id, '_height', $_POST['_height'] === '' ? '' : wc_format_decimal($_POST['_height']));
         }
     } else {
         update_post_meta($post_id, '_weight', '');
         update_post_meta($post_id, '_length', '');
         update_post_meta($post_id, '_width', '');
         update_post_meta($post_id, '_height', '');
     }
     // Save shipping class
     $product_shipping_class = $_POST['product_shipping_class'] > 0 && $product_type != 'external' ? absint($_POST['product_shipping_class']) : '';
     wp_set_object_terms($post_id, $product_shipping_class, 'product_shipping_class');
     // Unique SKU
     $sku = get_post_meta($post_id, '_sku', true);
     $new_sku = wc_clean(stripslashes($_POST['_sku']));
     if ($new_sku == '') {
         update_post_meta($post_id, '_sku', '');
     } elseif ($new_sku !== $sku) {
         if (!empty($new_sku)) {
             if ($wpdb->get_var($wpdb->prepare("\n\t\t\t\t\t\tSELECT {$wpdb->posts}.ID\n\t\t\t\t\t    FROM {$wpdb->posts}\n\t\t\t\t\t    LEFT JOIN {$wpdb->postmeta} ON ({$wpdb->posts}.ID = {$wpdb->postmeta}.post_id)\n\t\t\t\t\t    WHERE {$wpdb->posts}.post_type = 'product'\n\t\t\t\t\t    AND {$wpdb->posts}.post_status = 'publish'\n\t\t\t\t\t    AND {$wpdb->postmeta}.meta_key = '_sku' AND {$wpdb->postmeta}.meta_value = '%s'\n\t\t\t\t\t ", $new_sku))) {
                 WC_Admin_Meta_Boxes::add_error(__('Product SKU must be unique.', 'woocommerce'));
             } else {
                 update_post_meta($post_id, '_sku', $new_sku);
             }
         } else {
             update_post_meta($post_id, '_sku', '');
         }
     }
     // Save Attributes
     $attributes = array();
     if (isset($_POST['attribute_names']) && isset($_POST['attribute_values'])) {
         $attribute_names = $_POST['attribute_names'];
         $attribute_values = $_POST['attribute_values'];
         if (isset($_POST['attribute_visibility'])) {
             $attribute_visibility = $_POST['attribute_visibility'];
         }
         if (isset($_POST['attribute_variation'])) {
             $attribute_variation = $_POST['attribute_variation'];
         }
         $attribute_is_taxonomy = $_POST['attribute_is_taxonomy'];
         $attribute_position = $_POST['attribute_position'];
         $attribute_names_count = sizeof($attribute_names);
         for ($i = 0; $i < $attribute_names_count; $i++) {
             if (!$attribute_names[$i]) {
                 continue;
             }
             $is_visible = isset($attribute_visibility[$i]) ? 1 : 0;
             $is_variation = isset($attribute_variation[$i]) ? 1 : 0;
             $is_taxonomy = $attribute_is_taxonomy[$i] ? 1 : 0;
             if ($is_taxonomy) {
                 if (isset($attribute_values[$i])) {
                     // Select based attributes - Format values (posted values are slugs)
                     if (is_array($attribute_values[$i])) {
//.........这里部分代码省略.........
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:101,代码来源:class-wc-meta-box-product-data.php


示例18: process_product_meta

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP WC_Admin_Notices类代码示例发布时间:2022-05-23
下一篇:
PHP WC_AJAX类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap