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

PHP wc_delete_product_transients函数代码示例

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

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



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

示例1: clear_transients

 /**
  * Clear the product/shop transients cache.
  *
  * ## EXAMPLES
  *
  *     wp wc tool clear_transients
  *
  * @since 2.5.0
  */
 public function clear_transients($args, $assoc_args)
 {
     wc_delete_product_transients();
     wc_delete_shop_order_transients();
     WC_Cache_Helper::get_transient_version('shipping', true);
     WP_CLI::success('Product transients and shop order transients were cleared.');
 }
开发者ID:bitoncoin,项目名称:woocommerce,代码行数:16,代码来源:class-wc-cli-tool.php


示例2: save

 /**
  * Save Meta Box
  *
  * The function to be called to save the meta box options.
  *
  * @param   $post_id object the current product id
  * @param   $post object the current product
  * @since   1.0.0
  * @author  Alberto Ruggiero
  * @return  void
  */
 public static function save($post_id, $post)
 {
     global $wpdb;
     $product_type = empty($_POST['product-type']) ? 'simple' : sanitize_title(stripslashes($_POST['product-type']));
     $catalog_mode = isset($_POST['_ywctm_exclude_catalog_mode']) ? 'yes' : 'no';
     $hide_price = isset($_POST['_ywctm_exclude_hide_price']) ? 'yes' : 'no';
     update_post_meta($post_id, '_ywctm_exclude_catalog_mode', $catalog_mode);
     update_post_meta($post_id, '_ywctm_exclude_hide_price', $hide_price);
     do_action('woocommerce_process_product_meta_' . $product_type, $post_id);
     // Clear cache/transients
     wc_delete_product_transients($post_id);
 }
开发者ID:GolgoSoft,项目名称:KeenerWP,代码行数:23,代码来源:class-ywctm-meta-box.php


示例3: grouped_product_sync

 /**
  * Sync grouped products with the children lowest price (so they can be sorted by price accurately).
  *
  * @access public
  * @return void
  */
 public function grouped_product_sync()
 {
     global $wpdb, $woocommerce;
     if (!$this->get_parent()) {
         return;
     }
     $children_by_price = get_posts(array('post_parent' => $this->get_parent(), 'orderby' => 'meta_value_num', 'order' => 'asc', 'meta_key' => '_price', 'posts_per_page' => 1, 'post_type' => 'product', 'fields' => 'ids'));
     if ($children_by_price) {
         foreach ($children_by_price as $child) {
             $child_price = get_post_meta($child, '_price', true);
             update_post_meta($this->get_parent(), '_price', $child_price);
         }
     }
     wc_delete_product_transients($this->id);
 }
开发者ID:chhavinav,项目名称:fr.ilovejuice,代码行数:21,代码来源:class-wc-product-simple.php


示例4: test_wc_delete_product_transients

 /**
  * Test wc_delete_product_transients()
  *
  * @since 2.4
  */
 public function test_wc_delete_product_transients()
 {
     // Create product
     $product = \WC_Helper_Product::create_simple_product();
     update_post_meta($product->id, '_regular_price', wc_format_decimal(10));
     update_post_meta($product->id, '_price', wc_format_decimal(5));
     update_post_meta($product->id, '_sale_price', wc_format_decimal(5));
     update_post_meta($product->id, '_featured', 'yes');
     wc_get_product_ids_on_sale();
     // Creates the transient for on sale products
     wc_get_featured_product_ids();
     // Creates the transient for featured products
     wc_delete_product_transients();
     $this->assertFalse(get_transient('wc_products_onsale'));
     $this->assertFalse(get_transient('wc_featured_products'));
     \WC_Helper_Product::delete_product($product->id);
 }
开发者ID:nightbook,项目名称:woocommerce,代码行数:22,代码来源:functions.php


示例5: save

 /**
  * Save the settings
  */
 public static function save()
 {
     global $current_section, $current_tab;
     if (empty($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], 'woocommerce-settings')) {
         die(__('Action failed. Please refresh the page and retry.', 'woocommerce'));
     }
     // Trigger actions
     do_action('woocommerce_settings_save_' . $current_tab);
     do_action('woocommerce_update_options_' . $current_tab);
     do_action('woocommerce_update_options');
     // Clear any unwanted data
     wc_delete_product_transients();
     delete_transient('woocommerce_cache_excluded_uris');
     self::add_message(__('Your settings have been saved.', 'woocommerce'));
     self::check_download_folder_protection();
     // Re-add endpoints and flush rules
     WC()->query->init_query_vars();
     WC()->query->add_endpoints();
     flush_rewrite_rules();
     do_action('woocommerce_settings_saved');
 }
开发者ID:prosenjit-itobuz,项目名称:nutraperfect,代码行数:24,代码来源:class-wc-admin-settings.php


示例6: save


//.........这里部分代码省略.........
         } else {
             update_post_meta($post_id, '_price', $_POST['_regular_price'] === '' ? '' : wc_format_decimal($_POST['_regular_price']));
         }
         if ('' !== $_POST['_sale_price'] && $date_from && strtotime($date_from) <= strtotime('NOW', current_time('timestamp'))) {
             update_post_meta($post_id, '_price', wc_format_decimal($_POST['_sale_price']));
         }
         if ($date_to && strtotime($date_to) < strtotime('NOW', current_time('timestamp'))) {
             update_post_meta($post_id, '_price', $_POST['_regular_price'] === '' ? '' : wc_format_decimal($_POST['_regular_price']));
             update_post_meta($post_id, '_sale_price_dates_from', '');
             update_post_meta($post_id, '_sale_price_dates_to', '');
         }
     }
     // Update parent if grouped so price sorting works and stays in sync with the cheapest child
     if ($post->post_parent > 0 || 'grouped' == $product_type || $_POST['previous_parent_id'] > 0) {
         $clear_parent_ids = array();
         if ($post->post_parent > 0) {
             $clear_parent_ids[] = $post->post_parent;
         }
         if ('grouped' == $product_type) {
             $clear_parent_ids[] = $post_id;
         }
         if ($_POST['previous_parent_id'] > 0) {
             $clear_parent_ids[] = absint($_POST['previous_parent_id']);
         }
         if (!empty($clear_parent_ids)) {
             foreach ($clear_parent_ids as $clear_id) {
                 $children_by_price = get_posts(array('post_parent' => $clear_id, 'orderby' => 'meta_value_num', 'order' => 'asc', 'meta_key' => '_price', 'posts_per_page' => 1, 'post_type' => 'product', 'fields' => 'ids'));
                 if ($children_by_price) {
                     foreach ($children_by_price as $child) {
                         $child_price = get_post_meta($child, '_price', true);
                         update_post_meta($clear_id, '_price', $child_price);
                     }
                 }
                 wc_delete_product_transients($clear_id);
             }
         }
     }
     // Sold Individually
     if (!empty($_POST['_sold_individually'])) {
         update_post_meta($post_id, '_sold_individually', 'yes');
     } else {
         update_post_meta($post_id, '_sold_individually', '');
     }
     // Stock Data
     if ('yes' === get_option('woocommerce_manage_stock')) {
         $manage_stock = 'no';
         $backorders = 'no';
         $stock_status = wc_clean($_POST['_stock_status']);
         if ('external' === $product_type) {
             $stock_status = 'instock';
         } elseif ('variable' === $product_type) {
             // Stock status is always determined by children so sync later
             $stock_status = '';
             if (!empty($_POST['_manage_stock'])) {
                 $manage_stock = 'yes';
                 $backorders = wc_clean($_POST['_backorders']);
             }
         } elseif ('grouped' !== $product_type && !empty($_POST['_manage_stock'])) {
             $manage_stock = 'yes';
             $backorders = wc_clean($_POST['_backorders']);
         }
         update_post_meta($post_id, '_manage_stock', $manage_stock);
         update_post_meta($post_id, '_backorders', $backorders);
         if ($stock_status) {
             wc_update_product_stock_status($post_id, $stock_status);
         }
开发者ID:WordCommerce,项目名称:woocommerce,代码行数:67,代码来源:class-wc-meta-box-product-data.php


示例7: trs2_clear_transients

 /**
  *
  */
 public function trs2_clear_transients()
 {
     global $woocommerce;
     if (is_checkout()) {
         wc_delete_product_transients();
     }
 }
开发者ID:LinguaFrancaXXI,项目名称:wc-vendors,代码行数:10,代码来源:class-shipping.php


示例8: link_all_variations


//.........这里部分代码省略.........
             continue;
         }
         $attribute_field_name = 'attribute_' . sanitize_title($attribute['name']);
         if ($attribute['is_taxonomy']) {
             $options = wc_get_product_terms($post_id, $attribute['name'], array('fields' => 'slugs'));
         } else {
             $options = explode(WC_DELIMITER, $attribute['value']);
         }
         $options = array_map('sanitize_title', array_map('trim', $options));
         $variations[$attribute_field_name] = $options;
     }
     // Quit out if none were found
     if (sizeof($variations) == 0) {
         die;
     }
     // Get existing variations so we don't create duplicates
     $available_variations = array();
     foreach ($_product->get_children() as $child_id) {
         $child = $_product->get_child($child_id);
         if (!empty($child->variation_id)) {
             $available_variations[] = $child->get_variation_attributes();
         }
     }
     // Created posts will all have the following data
     $variation_post_data = array('post_title' => 'Product #' . $post_id . ' Variation', 'post_content' => '', 'post_status' => 'publish', 'post_author' => get_current_user_id(), 'post_parent' => $post_id, 'post_type' => 'product_variation');
     // Now find all combinations and create posts
     if (!function_exists('array_cartesian')) {
         /**
          * @param array $input
          * @return array
          */
         function array_cartesian($input)
         {
             $result = array();
             while (list($key, $values) = each($input)) {
                 // If a sub-array is empty, it doesn't affect the cartesian product
                 if (empty($values)) {
                     continue;
                 }
                 // Special case: seeding the product array with the values from the first sub-array
                 if (empty($result)) {
                     foreach ($values as $value) {
                         $result[] = array($key => $value);
                     }
                 } else {
                     // Second and subsequent input sub-arrays work like this:
                     //   1. In each existing array inside $product, add an item with
                     //      key == $key and value == first item in input sub-array
                     //   2. Then, for each remaining item in current input sub-array,
                     //      add a copy of each existing array inside $product with
                     //      key == $key and value == first item in current input sub-array
                     // Store all items to be added to $product here; adding them on the spot
                     // inside the foreach will result in an infinite loop
                     $append = array();
                     foreach ($result as &$product) {
                         // Do step 1 above. array_shift is not the most efficient, but it
                         // allows us to iterate over the rest of the items with a simple
                         // foreach, making the code short and familiar.
                         $product[$key] = array_shift($values);
                         // $product is by reference (that's why the key we added above
                         // will appear in the end result), so make a copy of it here
                         $copy = $product;
                         // Do step 2 above.
                         foreach ($values as $item) {
                             $copy[$key] = $item;
                             $append[] = $copy;
                         }
                         // Undo the side effecst of array_shift
                         array_unshift($values, $product[$key]);
                     }
                     // Out of the foreach, we can add to $results now
                     $result = array_merge($result, $append);
                 }
             }
             return $result;
         }
     }
     $variation_ids = array();
     $added = 0;
     $possible_variations = array_cartesian($variations);
     foreach ($possible_variations as $variation) {
         // Check if variation already exists
         if (in_array($variation, $available_variations)) {
             continue;
         }
         $variation_id = wp_insert_post($variation_post_data);
         $variation_ids[] = $variation_id;
         foreach ($variation as $key => $value) {
             update_post_meta($variation_id, $key, $value);
         }
         $added++;
         do_action('product_variation_linked', $variation_id);
         if ($added > WC_MAX_LINKED_VARIATIONS) {
             break;
         }
     }
     wc_delete_product_transients($post_id);
     echo $added;
     die;
 }
开发者ID:chhavinav,项目名称:fr.ilovejuice,代码行数:101,代码来源:class-wc-ajax.php


示例9: update

 /**
  * Update one or more products.
  *
  * ## OPTIONS
  *
  * <id>
  * : Product ID
  *
  * --<field>=<value>
  * : One or more fields to update.
  *
  * ## AVAILABLE_FIELDS
  *
  * For more fields, see: wp wc product create --help
  *
  * ## EXAMPLES
  *
  *     wp wc product update 123 --title="New Product Title" --description="New description"
  *
  * @since 2.5.0
  */
 public function update($args, $assoc_args)
 {
     try {
         $id = $args[0];
         $data = apply_filters('woocommerce_cli_update_product_data', $this->unflatten_array($assoc_args));
         // Product title.
         if (isset($data['title'])) {
             wp_update_post(array('ID' => $id, 'post_title' => wc_clean($data['title'])));
         }
         // Product name (slug).
         if (isset($data['name'])) {
             wp_update_post(array('ID' => $id, 'post_name' => sanitize_title($data['name'])));
         }
         // Product status.
         if (isset($data['status'])) {
             wp_update_post(array('ID' => $id, 'post_status' => wc_clean($data['status'])));
         }
         // Product short description.
         if (isset($data['short_description'])) {
             // Enable short description html tags.
             $post_excerpt = isset($data['enable_html_short_description']) && true === $data['enable_html_short_description'] ? $data['short_description'] : wc_clean($data['short_description']);
             wp_update_post(array('ID' => $id, 'post_excerpt' => $post_excerpt));
         }
         // Product description.
         if (isset($data['description'])) {
             // Enable description html tags.
             $post_content = isset($data['enable_html_description']) && true === $data['enable_html_description'] ? $data['description'] : wc_clean($data['description']);
             wp_update_post(array('ID' => $id, 'post_content' => $post_content));
         }
         // Validate the product type
         if (isset($data['type']) && !in_array(wc_clean($data['type']), array_keys(wc_get_product_types()))) {
             throw new WC_CLI_Exception('woocommerce_cli_invalid_product_type', sprintf(__('Invalid product type - the product type must be any of these: %s', 'woocommerce'), implode(', ', array_keys(wc_get_product_types()))));
         }
         // Check for featured/gallery images, upload it and set it
         if (isset($data['images'])) {
             $this->save_product_images($id, $data['images']);
         }
         // Save product meta fields
         $this->save_product_meta($id, $data);
         // Save variations
         if (isset($data['type']) && 'variable' == $data['type'] && isset($data['variations']) && is_array($data['variations'])) {
             $this->save_variations($id, $data);
         }
         do_action('woocommerce_cli_update_product', $id, $data);
         // Clear cache/transients
         wc_delete_product_transients($id);
         WP_CLI::success("Updated product {$id}.");
     } catch (WC_CLI_Exception $e) {
         WP_CLI::error($e->getMessage());
     }
 }
开发者ID:rahul13bhati,项目名称:woocommerce,代码行数:72,代码来源:class-wc-cli-product.php


示例10: delete_product

 /**
  * Delete a product.
  *
  * @since 2.2
  * @param int $id the product ID.
  * @param bool $force true to permanently delete order, false to move to trash.
  * @return array
  */
 public function delete_product($id, $force = false)
 {
     $id = $this->validate_request($id, 'product', 'delete');
     if (is_wp_error($id)) {
         return $id;
     }
     do_action('woocommerce_api_delete_product', $id, $this);
     // If we're forcing, then delete permanently.
     if ($force) {
         $child_product_variations = get_children('post_parent=' . $id . '&post_type=product_variation');
         if (!empty($child_product_variations)) {
             foreach ($child_product_variations as $child) {
                 wp_delete_post($child->ID, true);
             }
         }
         $child_products = get_children('post_parent=' . $id . '&post_type=product');
         if (!empty($child_products)) {
             foreach ($child_products as $child) {
                 $child_post = array();
                 $child_post['ID'] = $child->ID;
                 $child_post['post_parent'] = 0;
                 wp_update_post($child_post);
             }
         }
         $result = wp_delete_post($id, true);
     } else {
         $result = wp_trash_post($id);
     }
     if (!$result) {
         return new WP_Error('woocommerce_api_cannot_delete_product', sprintf(__('This %s cannot be deleted', 'woocommerce'), 'product'), array('status' => 500));
     }
     // Delete parent product transients.
     if ($parent_id = wp_get_post_parent_id($id)) {
         wc_delete_product_transients($parent_id);
     }
     if ($force) {
         return array('message' => sprintf(__('Permanently deleted %s', 'woocommerce'), 'product'));
     } else {
         $this->server->send_status('202');
         return array('message' => sprintf(__('Deleted %s', 'woocommerce'), 'product'));
     }
 }
开发者ID:johnulist,项目名称:woocommerce,代码行数:50,代码来源:class-wc-api-products.php


示例11: save

 public function save()
 {
     //save the post
     $this->body = apply_filters('woocsv_product_before_body', $this->body, $this->new);
     $this->meta = apply_filters('woocsv_product_before_meta', $this->meta, $this->new);
     $post_id = wp_insert_post($this->body);
     $this->body['ID'] = $post_id;
     do_action('woocsv_before_save', $this);
     do_action('woocsv_product_after_body_save');
     // fixed bug with if condition
     wp_set_object_terms($post_id, $this->product_type, 'product_type', false);
     do_action('woocsv_product_before_meta_save');
     //save the meta
     foreach ($this->meta as $key => $value) {
         update_post_meta($post_id, $key, $value);
     }
     do_action('woocsv_product_before_tags_save');
     //save tags
     if ($this->tags) {
         $this->saveTags($post_id);
     }
     do_action('woocsv_product_before_categorie_save');
     //save categories
     if (!empty($this->categories)) {
         $this->saveCategories($post_id);
     }
     do_action('woocsv_product_before_images_save');
     /* !--deprecated */
     if ($this->images) {
         $this->saveImages($post_id);
     }
     // added empty() else it overrrides the above function)
     if (!empty($this->featuredImage)) {
         $this->saveFeaturedImage();
     }
     if (!empty($this->productGallery)) {
         $this->saveProductGallery();
     }
     do_action('woocsv_product_before_shipping_save');
     if ($this->shippingClass) {
         $this->saveShippingClass();
     }
     do_action('woocsv_after_save', $this);
     /* !version 2.0.4 */
     if (function_exists('wc_delete_product_transients')) {
         wc_delete_product_transients($post_id);
     }
     //and return the ID
     return $post_id;
 }
开发者ID:natelaclaire,项目名称:woocommerce-csvimport,代码行数:50,代码来源:class-woocsv-product.php


示例12: dokan_process_product_meta


//.........这里部分代码省略.........
    // Sold Individuall
    if (!empty($_POST['_sold_individually'])) {
        update_post_meta($post_id, '_sold_individually', 'yes');
    } else {
        update_post_meta($post_id, '_sold_individually', '');
    }
    // Stock Data
    if (get_option('woocommerce_manage_stock') == 'yes') {
        if (!empty($_POST['_manage_stock'])) {
            // Manage stock
            update_post_meta($post_id, '_stock', (int) $_POST['_stock']);
            update_post_meta($post_id, '_stock_status', stripslashes($_POST['_stock_status']));
            update_post_meta($post_id, '_backorders', stripslashes($_POST['_backorders']));
            update_post_meta($post_id, '_manage_stock', 'yes');
            // Check stock level
            if ($product_type !== 'variable' && $_POST['_backorders'] == 'no' && (int) $_POST['_stock'] < 1) {
                update_post_meta($post_id, '_stock_status', 'outofstock');
            }
        } else {
            // Don't manage stock
            update_post_meta($post_id, '_stock', '');
            update_post_meta($post_id, '_stock_status', stripslashes($_POST['_stock_status']));
            update_post_meta($post_id, '_backorders', stripslashes($_POST['_backorders']));
            update_post_meta($post_id, '_manage_stock', 'no');
        }
    } else {
        update_post_meta($post_id, '_stock_status', stripslashes($_POST['_stock_status']));
    }
    // Upsells
    if (isset($_POST['upsell_ids'])) {
        $upsells = array();
        $ids = $_POST['upsell_ids'];
        foreach ($ids as $id) {
            if ($id && $id > 0) {
                $upsells[] = $id;
            }
        }
        update_post_meta($post_id, '_upsell_ids', $upsells);
    } else {
        delete_post_meta($post_id, '_upsell_ids');
    }
    // Cross sells
    if (isset($_POST['crosssell_ids'])) {
        $crosssells = array();
        $ids = $_POST['crosssell_ids'];
        foreach ($ids as $id) {
            if ($id && $id > 0) {
                $crosssells[] = $id;
            }
        }
        update_post_meta($post_id, '_crosssell_ids', $crosssells);
    } else {
        delete_post_meta($post_id, '_crosssell_ids');
    }
    // Downloadable options
    if ($is_downloadable == 'yes') {
        $_download_limit = absint($_POST['_download_limit']);
        if (!$_download_limit) {
            $_download_limit = '';
        }
        // 0 or blank = unlimited
        $_download_expiry = absint($_POST['_download_expiry']);
        if (!$_download_expiry) {
            $_download_expiry = '';
        }
        // 0 or blank = unlimited
        // file paths will be stored in an array keyed off md5(file path)
        if (isset($_POST['_wc_file_urls'])) {
            $files = array();
            $file_names = isset($_POST['_wc_file_names']) ? array_map('wc_clean', $_POST['_wc_file_names']) : array();
            $file_urls = isset($_POST['_wc_file_urls']) ? array_map('esc_url_raw', array_map('trim', $_POST['_wc_file_urls'])) : array();
            $file_url_size = sizeof($file_urls);
            for ($i = 0; $i < $file_url_size; $i++) {
                if (!empty($file_urls[$i])) {
                    $files[md5($file_urls[$i])] = array('name' => $file_names[$i], 'file' => $file_urls[$i]);
                }
            }
            // grant permission to any newly added files on any existing orders for this product prior to saving
            do_action('woocommerce_process_product_file_download_paths', $post_id, 0, $files);
            update_post_meta($post_id, '_downloadable_files', $files);
        }
        update_post_meta($post_id, '_download_limit', $_download_limit);
        update_post_meta($post_id, '_download_expiry', $_download_expiry);
        if (isset($_POST['_download_limit'])) {
            update_post_meta($post_id, '_download_limit', esc_attr($_download_limit));
        }
        if (isset($_POST['_download_expiry'])) {
            update_post_meta($post_id, '_download_expiry', esc_attr($_download_expiry));
        }
    }
    // Save variations
    if ($product_type == 'variable') {
        dokan_save_variations($post_id);
    }
    // Do action for product type
    do_action('woocommerce_process_product_meta_' . $product_type, $post_id);
    do_action('dokan_process_product_meta', $post_id);
    // Clear cache/transients
    wc_delete_product_transients($post_id);
}
开发者ID:amirkchetu,项目名称:dokan,代码行数:101,代码来源:wc-functions.php


示例13: execute_tool

 /**
  * Actually executes a a tool.
  *
  * @param  string $tool
  * @return array
  */
 public function execute_tool($tool)
 {
     global $wpdb;
     $ran = true;
     switch ($tool) {
         case 'clear_transients':
             wc_delete_product_transients();
             wc_delete_shop_order_transients();
             WC_Cache_Helper::get_transient_version('shipping', true);
             $message = __('Product Transients Cleared', 'woocommerce');
             break;
         case 'clear_expired_transients':
             /*
              * Deletes all expired transients. The multi-table delete syntax is used.
              * to delete the transient record from table a, and the corresponding.
              * transient_timeout record from table b.
              *
              * Based on code inside core's upgrade_network() function.
              */
             $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\n\t\t\t\t\tWHERE a.option_name LIKE %s\n\t\t\t\t\tAND a.option_name NOT LIKE %s\n\t\t\t\t\tAND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )\n\t\t\t\t\tAND b.option_value < %d";
             $rows = $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_transient_') . '%', $wpdb->esc_like('_transient_timeout_') . '%', time()));
             $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\n\t\t\t\t\tWHERE a.option_name LIKE %s\n\t\t\t\t\tAND a.option_name NOT LIKE %s\n\t\t\t\t\tAND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )\n\t\t\t\t\tAND b.option_value < %d";
             $rows2 = $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_site_transient_') . '%', $wpdb->esc_like('_site_transient_timeout_') . '%', time()));
             $message = sprintf(__('%d Transients Rows Cleared', 'woocommerce'), $rows + $rows2);
             break;
         case 'reset_roles':
             // Remove then re-add caps and roles
             WC_Install::remove_roles();
             WC_Install::create_roles();
             $message = __('Roles successfully reset', 'woocommerce');
             break;
         case 'recount_terms':
             $product_cats = get_terms('product_cat', array('hide_empty' => false, 'fields' => 'id=>parent'));
             _wc_term_recount($product_cats, get_taxonomy('product_cat'), true, false);
             $product_tags = get_terms('product_tag', array('hide_empty' => false, 'fields' => 'id=>parent'));
             _wc_term_recount($product_tags, get_taxonomy('product_tag'), true, false);
             $message = __('Terms successfully recounted', 'woocommerce');
             break;
         case 'clear_sessions':
             $wpdb->query("TRUNCATE {$wpdb->prefix}woocommerce_sessions");
             wp_cache_flush();
             $message = __('Sessions successfully cleared', 'woocommerce');
             break;
         case 'install_pages':
             WC_Install::create_pages();
             return __('All missing WooCommerce pages was installed successfully.', 'woocommerce');
             break;
         case 'delete_taxes':
             $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rates;");
             $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rate_locations;");
             WC_Cache_Helper::incr_cache_prefix('taxes');
             $message = __('Tax rates successfully deleted', 'woocommerce');
             break;
         case 'reset_tracking':
             delete_option('woocommerce_allow_tracking');
             WC_Admin_Notices::add_notice('tracking');
             $message = __('Usage tracking settings successfully reset.', 'woocommerce');
             break;
         default:
             $tools = $this->get_tools();
             if (isset($tools[$tool]['callback'])) {
                 $callback = $tools[$tool]['callback'];
                 $return = call_user_func($callback);
                 if ($return === false) {
                     $callback_string = is_array($callback) ? get_class($callback[0]) . '::' . $callback[1] : $callback;
                     $ran = false;
                     $message = sprintf(__('There was an error calling %s', 'woocommerce'), $callback_string);
                 } else {
                     $message = __('Tool ran.', 'woocommerce');
                 }
             } else {
                 $ran = false;
                 $message = __('There was an error calling this tool. There is no callback present.', 'woocommerce');
             }
             break;
     }
     return array('success' => $ran, 'message' => $message);
 }
开发者ID:tlovett1,项目名称:woocommerce,代码行数:84,代码来源:class-wc-rest-system-status-tools-controller.php


示例14: run_inventory_cron_job

 /**
  * Fetches inventory from fortnox and updates WooCommerce inventory
  *
  * @return string
  */
 public function run_inventory_cron_job()
 {
     include_once "class-fortnox3-api.php";
     $options = get_option('woocommerce_fortnox_general_settings');
     if (!isset($options['activate-fortnox-products-sync'])) {
         return;
     }
     //Init API
     $apiInterface = new WCF_API();
     if (!$apiInterface->create_api_validation_request()) {
         return $this->ERROR_API_KEY;
     }
     if ($apiInterface->has_error) {
         return $this->ERROR_LOGIN;
     }
     //fetch all articles
     $articles = $apiInterface->get_inventory();
     $pf = new WC_Product_Factory();
     $product = null;
     include_once "class-fortnox3-product-xml.php";
     foreach ($articles as $article) {
         //Query DB for id by SKU
         $args = array('post_type' => array('product', 'product_variation'), 'orderby' => 'id', 'meta_key' => '_sku', 'meta_value' => $article['ArticleNumber']);
         $query = new WP_Query($args);
         if ($query->post_count == 1) {
             $product = $pf->get_product($query->posts[0]->ID);
         } else {
             $article = null;
             continue;
         }
         if (!$product || null === $product) {
             $product = null;
             $article = null;
             continue;
         }
         if ($product instanceof WC_Product_Variation) {
             if ($product->parent == '') {
                 $product = null;
                 $article = null;
                 continue;
             }
         }
         if ($product instanceof WC_Product_Variable) {
             $this->update_product_inventory($product, null);
         } else {
             $this->update_product_inventory($product, $article['QuantityInStock']);
         }
         wc_delete_product_transients($product->id);
         $product = null;
     }
     $articles = null;
     return "Lager uppdaterat";
 }
开发者ID:NoviumDesign,项目名称:polefitness,代码行数:58,代码来源:class-woo-fortnox-controller.php


示例15: bulk_and_quick_edit_save_post

 /**
  * Quick and bulk edit saving
  *
  * @access public
  * @param int $post_id
  * @param WP_Post $post
  * @return int
  */
 public function bulk_and_quick_edit_save_post($post_id, $post)
 {
     // If this is an autosave, our form has not been submitted, so we don't want to do anything.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     // Don't save revisions and autosaves
     if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) {
         return $post_id;
     }
     // Check post type is product
     if ($post->post_type != 'product') {
         return $post_id;
     }
     // Check user permission
     if (!current_user_can('edit_post', $post_id)) {
         return $post_id;
     }
     // Check nonces
     if (!isset($_REQUEST['woocommerce_quick_edit_nonce']) && !isset($_REQUEST['woocommerce_bulk_edit_nonce'])) {
         return $post_id;
     }
     if (isset($_REQUEST['woocommerce_quick_edit_nonce']) && !wp_verify_nonce($_REQUEST['woocommerce_quick_edit_nonce'], 'woocommerce_quick_edit_nonce')) {
         return $post_id;
     }
     if (isset($_REQUEST['woocommerce_bulk_edit_nonce']) && !wp_verify_nonce($_REQUEST['woocommerce_bulk_edit_nonce'], 'woocommerce_bulk_edit_nonce')) {
         return $post_id;
     }
     // Get the product and save
     $product = get_product($post);
     if (!empty($_REQUEST['woocommerce_quick_edit'])) {
         $this->quick_edit_save($post_id, $product);
     } else {
         $this->bulk_edit_save($post_id, $product);
     }
     // Clear transient
     wc_delete_product_transients($post_id);
     return $post_id;
 }
开发者ID:donwea,项目名称:nhap.org,代码行数:47,代码来源:class-wc-admin-cpt-product.php


示例16: dokan_process_product_meta


//.........这里部分代码省略.........
        update_post_meta($post_id, '_sale_price_dates_from', strtotime('NOW', current_time('timestamp')));
    }
    // Update price if on sale
    if ('' !== $_POST['_sale_price'] && '' == $date_to && '' == $date_from) {
        update_post_meta($post_id, '_price', wc_format_decimal($_POST['_sale_price']));
    } else {
        update_post_meta($post_id, '_price', $_POST['_regular_price'] === '' ? '' : wc_format_decimal($_POST['_regular_price']));
    }
    if ('' !== $_POST['_sale_price'] && $date_from && strtotime($date_from) < strtotime('NOW', current_time('timestamp'))) {
        update_post_meta($post_id, '_price', wc_format_decimal($_POST['_sale_price']));
    }
    if ($date_to && strtotime($date_to) < strtotime('NOW', current_time('timestamp'))) {
        update_post_meta($post_id, '_price', $_POST['_regular_price'] === '' ? '' : wc_format_decimal($_POST['_regular_price']));
        update_post_meta($post_id, '_sale_price_dates_from', '');
        update_post_meta($post_id, '_sale_price_dates_to', '');
    }
    // reset price is discounted checkbox was not checked
    if (!isset($_POST['_discounted_price'])) {
        update_post_meta($post_id, '_price', wc_format_decimal($_POST['_regular_price']));
        update_post_meta($post_id, '_regular_price', wc_format_decimal($_POST['_regular_price']));
        update_post_meta($post_id, '_sale_price', '');
    }
    // Sold Individuall
    if (isset($_POST['_sold_individually'])) {
        update_post_meta($post_id, '_sold_individually', 'yes');
    } else {
        update_post_meta($post_id, '_sold_individually', '');
    }
    // Stock Data
    if (get_option('woocommerce_manage_stock') == 'yes') {
        if (!empty($_POST['_manage_stock'])) {
            // Manage stock
            update_post_meta($post_id, '_stock', (int) $_POST['_stock']);
            update_post_meta($post_id, '_stock_status', stripslashes($_POST['_stock_status']));
            update_post_meta($post_id, '_backorders', stripslashes($_POST['_backorders']));
            update_post_meta($post_id, '_manage_stock', 'yes');
            // Check stock level
            if ($product_type !== 'variable' && $_POST['_backorders'] == 'no' && (int) $_POST['_stock'] < 1) {
                update_post_meta($post_id, '_stock_status', 'outofstock');
            }
        } else {
            // Don't manage stock
            update_post_meta($post_id, '_stock', '');
            update_post_meta($post_id, '_stock_status', stripslashes($_POST['_stock_status']));
            update_post_meta($post_id, '_backorders', stripslashes($_POST['_backorders']));
            update_post_meta($post_id, '_manage_stock', 'no');
        }
    } else {
        update_post_meta($post_id, '_stock_status', stripslashes($_POST['_stock_status']));
    }
    // Upsells
    if (isset($_POST['upsell_ids'])) {
        $upsells = array();
        $ids = $_POST['upsell_ids'];
        foreach ($ids as $id) {
            if ($id && $id > 0) {
                $upsells[] = $id;
            }
        }
        update_post_meta($post_id, '_upsell_ids', $upsells);
    } else {
        delete_post_meta($post_id, '_upsell_ids');
    }
    // Cross sells
    if (isset($_POST['crosssell_ids'])) {
        $crosssells = array();
        $ids = $_POST['crosssell_ids'];
        foreach ($ids as $id) {
            if ($id && $id > 0) {
                $crosssells[] = $id;
            }
        }
        update_post_meta($post_id, '_crosssell_ids', $crosssells);
    } else {
        delete_post_meta($post_id, '_crosssell_ids');
    }
    // Downloadable options
    if ($is_downloadable == 'yes') {
        // file paths will be stored in an array keyed off md5(file path)
        if (isset($_POST['_wc_file_urls'])) {
            $files = array();
            $file_names = isset($_POST['_wc_file_names']) ? array_map('wc_clean', $_POST['_wc_file_names']) : array();
            $file_urls = isset($_POST['_wc_file_urls']) ? array_map('esc_url_raw', array_map('trim', $_POST['_wc_file_urls'])) : array();
            $file_url_size = sizeof($file_urls);
            for ($i = 0; $i < $file_url_size; $i++) {
                if (!empty($file_urls[$i])) {
                    $files[md5($file_urls[$i])] = array('name' => $file_names[$i], 'file' => $file_urls[$i]);
                }
            }
            // grant permission to any newly added files on any existing orders for this product prior to saving
            do_action('woocommerce_process_product_file_download_paths', $post_id, 0, $files);
            update_post_meta($post_id, '_downloadable_files', $files);
        }
    }
    // Do action for product type
    do_action('woocommerce_process_product_meta_simple', $post_id);
    do_action('dokan_process_product_meta', $post_id);
    // Clear cache/transients
    wc_delete_product_transients($post_id);
}
开发者ID:nuwe1,项目名称:dokan-lite,代码行数:101,代码来源:wc-functions.php


示例17: delete_post

 /**
  * Removes variations etc belonging to a deleted post, and clears transients
  *
  * @param mixed $id ID of post being deleted
  */
 public function delete_post($id)
 {
     global $woocommerce, $wpdb;
     if (!current_user_can('delete_posts')) {
         return;
     }
     if ($id > 0) {
         $post_type = get_post_type($id);
         switch ($post_type) {
             case 'product':
                 $child_product_variations = get_children('post_parent=' . $id . '&post_type=product_variation');
                 if (!empty($child_product_variations)) {
                     foreach ($child_product_variations as $child) {
                         wp_delete_post($child->ID, true);
                     }
                 }
                 $child_products = get_children('post_parent=' . $id . '&post_type=product');
                 if (!empty($child_products)) {
                     foreach ($child_products as $child) {
                         $child_post = array();
                         $child_post['ID'] = $child->ID;
                         $child_post['post_parent'] = 0;
                         wp_update_post($child_post);
                     }
                 }
                 if ($parent_id = wp_get_post_parent_id($id)) {
                     wc_delete_product_transients($parent_id);
                 }
                 break;
             case 'product_variation':
                 wc_delete_product_transients(wp_get_post_parent_id($id));
                 break;
             case 'shop_order':
                 $refunds = $wpdb->get_results($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'shop_order_refund' AND post_parent = %d", $id));
                 if (!is_null($refunds)) {
                     foreach ($refunds as $refund) {
                         wp_delete_post($refund->ID, true);
                     }
                 }
                 break;
         }
     }
 }
开发者ID:vkolova,项目名称:bgscena,代码行数:48,代码来源:class-wc-admin-post-types.php


示例18: wc_delete_product_transients

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wc_delete_shop_order_transients函数代码示例发布时间:2022-05-23
下一篇:
PHP wc_delete_order_item函数代码示例发布时间: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