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


PHP obj::get_total_quantity方法代码示例

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


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

示例1: validate_container

 /**
  * Validate container against our minimum quantity requirement
  *
  * @param bool $passed
  * @param obj $mnm_stock
  * @param obj $product
  * @return void
  */
 public static function validate_container($passed, $mnm_stock, $product)
 {
     $total_items_in_container = $mnm_stock->get_total_quantity();
     $min_qty = intval(get_post_meta($product->id, '_mnm_container_size', true));
     $max_qty = get_post_meta($product->id, '_mnm_max_container_size', true);
     // if a max quantity exists and is not equal to the min quantity we have a non-fixed container size
     if (false !== $max_qty && $min_qty != intval($max_qty)) {
         $min_qty = $min_qty > 0 ? $min_qty : 1;
         $max_qty = intval($max_qty);
         // validate that an unlimited container is in min/max range & build a specific error message
         if ($max_qty > 0 && $min_qty > 0 && ($total_items_in_container > $max_qty || $total_items_in_container < $min_qty)) {
             $message = $total_items_in_container > $max_qty ? __('You have selected too many items.', 'woocommerce-mix-and-match-min-max-quantities') : __('You have selected too few items.', 'woocommerce-mix-and-match-min-max-quantities');
             $message .= '  ' . sprintf(__('Please choose between %d and %d items for &quot;%s&quot;.', 'woocommerce-mix-and-match-min-max-quantities'), $min_qty, $max_qty, $product->get_title());
             wc_add_notice($message, 'error');
             $passed = false;
         } else {
             if ($min_qty > 0 && $total_items_in_container < $min_qty) {
                 wc_add_notice(sprintf(__('Please choose at least %d items for &quot;%s&quot;.', 'woocommerce-mix-and-match-min-max-quantities'), $min_qty, $product->get_title()), 'error');
                 $passed = false;
             }
         }
     }
     return $passed;
 }
开发者ID:unsub,项目名称:woocommerce-mix-and-match-min-max,代码行数:32,代码来源:woocommerce-mix-and-match-min-max-quantities.php

示例2: validate_container

 /**
  * Validate container against our minimum quantity requirement
  *
  * @param bool $passed
  * @param obj $mnm_stock
  * @param obj $product
  * @return void
  */
 public static function validate_container($error_message, $mnm_stock, $product)
 {
     $total_items_in_container = $mnm_stock->get_total_quantity();
     $min_qty = $product->get_container_size();
     $max_qty = self::get_max_container_size($product);
     // if a max quantity exists and is not equal to the min quantity we have a non-fixed container size
     if ($min_qty != $max_qty) {
         // reset the error message
         $error_message = false;
         // min_container_size is always at least 1, because the container can't be empty
         $min_qty = $min_qty > 0 ? $min_qty : 1;
         // validate that a container is in min/max range & build a specific error message
         if ($max_qty > 0 && $min_qty > 0 && ($total_items_in_container > $max_qty || $total_items_in_container < $min_qty)) {
             $error_message = $total_items_in_container > $max_qty ? __('You have selected too many items.', 'woocommerce-mix-and-match-min-max-quantities') : __('You have selected too few items.', 'woocommerce-mix-and-match-min-max-quantities');
             $error_message .= '  ' . sprintf(__('Please choose between %d and %d items for &quot;%s&quot;.', 'woocommerce-mix-and-match-min-max-quantities'), $min_qty, $max_qty, $product->get_title());
         } else {
             if ($min_qty > 0 && $total_items_in_container < $min_qty) {
                 $error_message = sprintf(_n('Please choose at least %d item for &quot;%s&quot;.', 'Please choose at least %d items for &quot;%s&quot;.', $min_qty, 'woocommerce-mix-and-match-min-max-quantities'), $min_qty, $product->get_title());
             }
         }
     }
     return $error_message;
 }
开发者ID:helgatheviking,项目名称:woocommerce-mix-and-match-min-max,代码行数:31,代码来源:woocommerce-mix-and-match-min-max-quantities.php


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