Example #1
0
function zen_get_products_quantity_min_units_display($product_id, $include_break = true, $shopping_cart_msg = false)
{
    $check_min = zen_get_products_quantity_order_min($product_id);
    $check_units = zen_get_products_quantity_order_units($product_id);
    $the_min_units = '';
    if ($check_min != 1 or $check_units != 1) {
        if ($check_min != 1) {
            $the_min_units .= PRODUCTS_QUANTITY_MIN_TEXT_LISTING . ' ' . $check_min;
        }
        if ($check_units != 1) {
            $the_min_units .= ($the_min_units ? ' ' : '') . PRODUCTS_QUANTITY_UNIT_TEXT_LISTING . ' ' . $check_units;
        }
        if (($check_min > 0 or $check_units > 0) and !zen_get_products_quantity_mixed($product_id)) {
            if ($include_break == true) {
                $the_min_units .= '<br />' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_OFF : TEXT_PRODUCTS_MIX_OFF_SHOPPING_CART);
            } else {
                $the_min_units .= '&nbsp;&nbsp;' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_OFF : TEXT_PRODUCTS_MIX_OFF_SHOPPING_CART);
            }
        } else {
            if ($include_break == true) {
                $the_min_units .= '<br />' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_ON : TEXT_PRODUCTS_MIX_ON_SHOPPING_CART);
            } else {
                $the_min_units .= '&nbsp;&nbsp;' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_ON : TEXT_PRODUCTS_MIX_ON_SHOPPING_CART);
            }
        }
    }
    // quantity max
    $check_max = zen_get_products_quantity_order_max($product_id);
    if ($check_max != 0) {
        if ($include_break == true) {
            $the_min_units .= ($the_min_units != '' ? '<br />' : '') . PRODUCTS_QUANTITY_MAX_TEXT_LISTING . '&nbsp;' . $check_max;
        } else {
            $the_min_units .= ($the_min_units != '' ? '&nbsp;&nbsp;' : '') . PRODUCTS_QUANTITY_MAX_TEXT_LISTING . '&nbsp;' . $check_max;
        }
    }
    return $the_min_units;
}
 /**
  * Method to handle cart Action - update product
  *
  * @param string forward destination
  * @param url parameters
  */
 function actionUpdateProduct($goto, $parameters)
 {
     global $messageStack;
     if ($this->display_debug_messages) {
         $messageStack->add_session('header', 'FUNCTION ' . __FUNCTION__, 'caution');
     }
     for ($i = 0, $n = sizeof($_POST['products_id']); $i < $n; $i++) {
         $adjust_max = 'false';
         if ($_POST['cart_quantity'][$i] == '') {
             $_POST['cart_quantity'][$i] = 0;
         }
         if (!is_numeric($_POST['cart_quantity'][$i]) || $_POST['cart_quantity'][$i] < 0) {
             // adjust quantity when not a value
             $chk_link = '<a href="' . zen_href_link(zen_get_info_page($_POST['products_id'][$i]), 'cPath=' . zen_get_generated_category_path_rev(zen_get_products_category_id($_POST['products_id'][$i])) . '&products_id=' . $_POST['products_id'][$i]) . '">' . zen_get_products_name($_POST['products_id'][$i]) . '</a>';
             $messageStack->add_session('header', ERROR_CORRECTIONS_HEADING . ERROR_PRODUCT_QUANTITY_UNITS_SHOPPING_CART . $chk_link . ' ' . PRODUCTS_ORDER_QTY_TEXT . zen_output_string_protected($_POST['cart_quantity'][$i]), 'caution');
             $_POST['cart_quantity'][$i] = 0;
             continue;
         }
         if (in_array($_POST['products_id'][$i], is_array($_POST['cart_delete']) ? $_POST['cart_delete'] : array()) or $_POST['cart_quantity'][$i] == 0) {
             $this->remove($_POST['products_id'][$i]);
         } else {
             $add_max = zen_get_products_quantity_order_max($_POST['products_id'][$i]);
             // maximum allowed
             $cart_qty = $this->in_cart_mixed($_POST['products_id'][$i]);
             // total currently in cart
             if ($this->display_debug_messages) {
                 $messageStack->add_session('header', 'FUNCTION ' . __FUNCTION__ . ' Products_id: ' . $_POST['products_id'][$i] . ' cart_qty: ' . $cart_qty . ' <br>', 'caution');
             }
             $new_qty = $_POST['cart_quantity'][$i];
             // new quantity
             $current_qty = $this->get_quantity($_POST['products_id'][$i]);
             // how many currently in cart for attribute
             $chk_mixed = zen_get_products_quantity_mixed($_POST['products_id'][$i]);
             // use mixed
             $new_qty = $this->adjust_quantity($new_qty, $_POST['products_id'][$i], 'shopping_cart');
             // bof: adjust new quantity to be same as current in stock
             $chk_current_qty = zen_get_products_stock($_POST['products_id'][$i]);
             if (STOCK_ALLOW_CHECKOUT == 'false' && $new_qty > $chk_current_qty) {
                 $new_qty = $chk_current_qty;
                 $messageStack->add_session('shopping_cart', ($this->display_debug_messages ? 'FUNCTION ' . __FUNCTION__ . ': ' : '') . WARNING_PRODUCT_QUANTITY_ADJUSTED . zen_get_products_name($_POST['products_id'][$i]), 'caution');
             }
             // eof: adjust new quantity to be same as current in stock
             if (($add_max == 1 and $cart_qty == 1) && $new_qty != $cart_qty) {
                 // do not add
                 $adjust_max = 'true';
             } else {
                 if ($add_max != 0) {
                     // bof: adjust new quantity to be same as current in stock
                     if (STOCK_ALLOW_CHECKOUT == 'false' && $new_qty + $cart_qty > $chk_current_qty) {
                         $adjust_new_qty = 'true';
                         $alter_qty = $chk_current_qty - $cart_qty;
                         $new_qty = $alter_qty > 0 ? $alter_qty : 0;
                         $messageStack->add_session('shopping_cart', ($this->display_debug_messages ? 'FUNCTION ' . __FUNCTION__ . ': ' : '') . WARNING_PRODUCT_QUANTITY_ADJUSTED . zen_get_products_name($_POST['products_id'][$i]), 'caution');
                     }
                     // eof: adjust new quantity to be same as current in stock
                     // adjust quantity if needed
                     switch (true) {
                         case $new_qty == $current_qty:
                             // no change
                             $adjust_max = 'false';
                             $new_qty = $current_qty;
                             break;
                         case $new_qty > $add_max && $chk_mixed == false:
                             $adjust_max = 'true';
                             $new_qty = $add_max;
                             break;
                         case $add_max - $cart_qty + $new_qty >= $add_max && $new_qty > $add_max && $chk_mixed == true:
                             $adjust_max = 'true';
                             $requested_qty = $new_qty;
                             $new_qty = $current_qty;
                             break;
                         case $cart_qty + $new_qty - $current_qty > $add_max && $chk_mixed == true:
                             $adjust_max = 'true';
                             $requested_qty = $new_qty;
                             $new_qty = $current_qty;
                             break;
                         default:
                             $adjust_max = 'false';
                     }
                     $attributes = $_POST['id'][$_POST['products_id'][$i]] ? $_POST['id'][$_POST['products_id'][$i]] : '';
                     $this->add_cart($_POST['products_id'][$i], $new_qty, $attributes, false);
                 } else {
                     // adjust minimum and units
                     $attributes = $_POST['id'][$_POST['products_id'][$i]] ? $_POST['id'][$_POST['products_id'][$i]] : '';
                     $this->add_cart($_POST['products_id'][$i], $new_qty, $attributes, false);
                 }
             }
             if ($adjust_max == 'true') {
                 if ($this->display_debug_messages) {
                     $messageStack->add_session('header', 'FUNCTION ' . __FUNCTION__ . '<br>' . ERROR_MAXIMUM_QTY . zen_get_products_name($_POST['products_id'][$i]) . '<br>requested_qty: ' . $requested_qty . ' current_qty: ' . $current_qty, 'caution');
                 }
                 $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($_POST['products_id'][$i]), 'caution');
             } else {
                 // display message if all is good and not on shopping_cart page
                 if (DISPLAY_CART == 'false' && $_GET['main_page'] != FILENAME_SHOPPING_CART && $messageStack->size('shopping_cart') == 0) {
                     $messageStack->add_session('header', ($this->display_debug_messages ? 'FUNCTION ' . __FUNCTION__ . ': ' : '') . SUCCESS_ADDED_TO_CART_PRODUCTS, 'success');
                 } else {
                     if ($_GET['main_page'] != FILENAME_SHOPPING_CART) {
                         zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
                     }
                 }
             }
         }
     }
     zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters)));
 }
 /**
  * Method to handle cart Action - update product
  *
  * @param string forward destination
  * @param url parameters
  */
 function actionUpdateProduct($goto, $parameters)
 {
     global $messageStack;
     for ($i = 0, $n = sizeof($_POST['products_id']); $i < $n; $i++) {
         $adjust_max = 'false';
         if ($_POST['cart_quantity'][$i] == '') {
             $_POST['cart_quantity'][$i] = 0;
         }
         if (!is_numeric($_POST['cart_quantity'][$i]) || $_POST['cart_quantity'][$i] < 0) {
             $messageStack->add_session('header', ERROR_CORRECTIONS_HEADING . ERROR_PRODUCT_QUANTITY_UNITS_SHOPPING_CART . zen_get_products_name($_POST['products_id'][$i]) . ' ' . PRODUCTS_ORDER_QTY_TEXT . zen_output_string_protected($_POST['cart_quantity'][$i]), 'error');
             continue;
         }
         if (in_array($_POST['products_id'][$i], is_array($_POST['cart_delete']) ? $_POST['cart_delete'] : array()) or $_POST['cart_quantity'][$i] == 0) {
             $this->remove($_POST['products_id'][$i]);
         } else {
             $add_max = zen_get_products_quantity_order_max($_POST['products_id'][$i]);
             // maximum allowed
             $cart_qty = $this->in_cart_mixed($_POST['products_id'][$i]);
             // total currently in cart
             //$messageStack->add_session('header', 'actionUpdateProduct Products_id: ' . $_POST['products_id'] . ' qty: ' . $cart_qty . ' <br>', 'caution');
             $new_qty = $_POST['cart_quantity'][$i];
             // new quantity
             $current_qty = $this->get_quantity($_POST['products_id'][$i]);
             // how many currently in cart for attribute
             $chk_mixed = zen_get_products_quantity_mixed($_POST['products_id'][$i]);
             // use mixed
             //echo 'I SEE actionUpdateProduct: ' . $_POST['products_id'] . ' ' . $_POST['products_id'][$i] . '<br>';
             $new_qty = $this->adjust_quantity($new_qty, $_POST['products_id'][$i], 'shopping_cart');
             //die('I see Update Cart: ' . $_POST['products_id'][$i] . ' add qty: ' . $add_max . ' - cart qty: ' . $cart_qty . ' - newqty: ' . $new_qty);
             if (($add_max == 1 and $cart_qty == 1) && $new_qty != $cart_qty) {
                 // do not add
                 $adjust_max = 'true';
             } else {
                 if ($add_max != 0) {
                     //$messageStack->add_session('shopping_cart', 'PROCESSING MAX: Update Cart chk_mixed false: ' . $_POST['products_id'][$i] . ' add max: ' . $add_max . ' - cart qty: ' . $cart_qty . ' - newqty: ' . $new_qty . ' current_quantity: ' . $current_qty, 'warning');
                     // adjust quantity if needed
                     //          if ($add_max != 0 && $new_qty > $current_qty && ($cart_quantity - $current_qty + $new_qty) != 0 && (($cart_quantity - $current_qty + $new_qty) + $cart_qty > $add_max)) {
                     switch (true) {
                         case $new_qty == $current_qty:
                             // no change
                             //$messageStack->add_session('shopping_cart', 'I see NEW=CURRENT Update Cart chk_mixed false: ' . $_POST['products_id'][$i] . ' add max: ' . $add_max . ' - cart qty: ' . $cart_qty . ' - newqty: ' . $new_qty . ' current_quantity: ' . $current_qty, 'warning');
                             $adjust_max = 'false';
                             $new_qty = $current_qty;
                             break;
                         case $new_qty > $add_max && $chk_mixed == false:
                             //$messageStack->add_session('shopping_cart', 'I see Update Cart chk_mixed false: ' . $_POST['products_id'][$i] . ' add max: ' . $add_max . ' - cart qty: ' . $cart_qty . ' - newqty: ' . $new_qty . ' something: ' . $something_qty, 'warning');
                             $adjust_max = 'true';
                             $new_qty = $add_max;
                             break;
                         case $add_max - $cart_qty + $new_qty >= $add_max && $new_qty > $add_max && $chk_mixed == true:
                             //$messageStack->add_session('shopping_cart', 'I see NEW > ADD Update Cart chk_mixed true: ' . $_POST['products_id'][$i] . ' add max: ' . $add_max . ' - cart qty: ' . $cart_qty . ' + newqty: ' . $new_qty, 'warning');
                             $adjust_max = 'true';
                             $requested_qty = $new_qty;
                             $new_qty = $current_qty;
                             break;
                         case $cart_qty + $new_qty - $current_qty > $add_max && $chk_mixed == true:
                             //$messageStack->add_session('shopping_cart', 'I see CART + NEW - CURRENT > ADD Update Cart chk_mixed true: ' . $_POST['products_id'][$i] . ' add max: ' . $add_max . ' - cart qty: ' . $cart_qty . ' + newqty: ' . $new_qty . ' current_qty: ' . $current_qty, 'warning');
                             $adjust_max = 'true';
                             $requested_qty = $new_qty;
                             $new_qty = $current_qty;
                             break;
                         default:
                             //$messageStack->add_session('shopping_cart', 'I see DEFAULT Cart - TURN OFF<br>: ' . $_POST['products_id'][$i] . ' add max: ' . $add_max . ' - cart qty: ' . $cart_qty . ' + newqty: ' . $new_qty . '<br>' . 'current: ' . $current_qty, 'warning');
                             $adjust_max = 'false';
                     }
                     $attributes = $_POST['id'][$_POST['products_id'][$i]] ? $_POST['id'][$_POST['products_id'][$i]] : '';
                     $this->add_cart($_POST['products_id'][$i], $new_qty, $attributes, false);
                 } else {
                     // adjust minimum and units
                     $attributes = $_POST['id'][$_POST['products_id'][$i]] ? $_POST['id'][$_POST['products_id'][$i]] : '';
                     $this->add_cart($_POST['products_id'][$i], $new_qty, $attributes, false);
                 }
             }
             if ($adjust_max == 'true') {
                 //          $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . ' A: - ' . zen_get_products_name($_POST['products_id'][$i]), 'caution');
                 //$messageStack->add_session('shopping_cart', 'actionUpdateProduct<br>' . ERROR_MAXIMUM_QTY . zen_get_products_name($_POST['products_id'][$i]) . '<br>Requested: ' . $requested_qty . ' current: ' . $current_qty , 'caution');
                 $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($_POST['products_id'][$i]), 'caution');
             } else {
                 // display message if all is good and not on shopping_cart page
                 if (DISPLAY_CART == 'false' && $_GET['main_page'] != FILENAME_SHOPPING_CART) {
                     $messageStack->add_session('header', SUCCESS_ADDED_TO_CART_PRODUCT, 'success');
                 }
             }
         }
     }
     zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters)));
 }
Example #4
0
 /**
  * Method to handle cart Action - update product
  *
  * @param string forward destination
  * @param url parameters
  */
 public function actionUpdateProduct($goto, $parameters)
 {
     $products_id = $this->getRequest()->request->get('products_id');
     for ($i = 0, $n = sizeof($products_id); $i < $n; $i++) {
         $adjust_max = 'false';
         if ($_POST['cart_quantity'][$i] == '') {
             $_POST['cart_quantity'][$i] = 0;
         }
         if (!is_numeric($_POST['cart_quantity'][$i]) || $_POST['cart_quantity'][$i] < 0) {
             $this->getMessageStack()->add_session('header', ERROR_CORRECTIONS_HEADING . ERROR_PRODUCT_QUANTITY_UNITS_SHOPPING_CART . zen_get_products_name($products_id[$i]) . ' ' . PRODUCTS_ORDER_QTY_TEXT . zen_output_string_protected($_POST['cart_quantity'][$i]), 'error');
             continue;
         }
         if (in_array($products_id[$i], isset($_POST['cart_delete']) && is_array($_POST['cart_delete']) ? $_POST['cart_delete'] : array()) or $_POST['cart_quantity'][$i] == 0) {
             $this->remove($products_id[$i]);
         } else {
             $add_max = zen_get_products_quantity_order_max($products_id[$i]);
             // maximum allowed
             $cart_qty = $this->in_cart_mixed($products_id[$i]);
             // total currently in cart
             $new_qty = $_POST['cart_quantity'][$i];
             // new quantity
             $current_qty = $this->get_quantity($products_id[$i]);
             // how many currently in cart for attribute
             $chk_mixed = zen_get_products_quantity_mixed($products_id[$i]);
             // use mixed
             $new_qty = $this->adjust_quantity($new_qty, $products_id[$i], 'shopping_cart');
             if (($add_max == 1 and $cart_qty == 1) && $new_qty != $cart_qty) {
                 // do not add
                 $adjust_max = 'true';
             } else {
                 if ($add_max != 0) {
                     // adjust quantity if needed
                     switch (true) {
                         case $new_qty == $current_qty:
                             // no change
                             $adjust_max = 'false';
                             $new_qty = $current_qty;
                             break;
                         case $new_qty > $add_max && $chk_mixed == false:
                             $adjust_max = 'true';
                             $new_qty = $add_max;
                             break;
                         case $add_max - $cart_qty + $new_qty >= $add_max && $new_qty > $add_max && $chk_mixed == true:
                             $adjust_max = 'true';
                             $requested_qty = $new_qty;
                             $new_qty = $current_qty;
                             break;
                         case $cart_qty + $new_qty - $current_qty > $add_max && $chk_mixed == true:
                             $adjust_max = 'true';
                             $requested_qty = $new_qty;
                             $new_qty = $current_qty;
                             break;
                         default:
                             $adjust_max = 'false';
                     }
                 }
                 // adjust minimum and units
                 $attributes = '';
                 if (isset($_POST['id'][$products_id[$i]])) {
                     $attributes = $_POST['id'][$products_id[$i]];
                 }
                 $this->add_cart($products_id[$i], $new_qty, $attributes, false);
             }
             if ($adjust_max == 'true') {
                 $this->getMessageStack()->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($products_id[$i]), 'caution');
             } else {
                 // display message if all is good and not on shopping_cart page
                 if (DISPLAY_CART == 'false' && $this->getMainPage() != 'shopping_cart') {
                     $this->getMessageStack()->add_session('header', SUCCESS_ADDED_TO_CART_PRODUCT, 'success');
                 }
             }
         }
     }
     zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters)));
 }
 }
 if ($_SESSION['cart']->display_debug_messages) {
     $messageStack->add_session('header', 'FUNCTION ' . __FUNCTION__ . ' Products_id: ' . $_POST['products_id'][$i] . ' cart_qty: ' . $cart_qty . ' <br>', 'caution');
 }
 $new_qty = $_POST['cart_quantity'][$i];
 // new quantity
 $current_qty = $_SESSION['cart']->get_quantity($_POST['products_id'][$i]);
 // how many currently in cart for attribute
 if ($productIsSBA[$i] && (PRODINFO_ATTRIBUTE_PLUGIN_MULTI == 'single_dropdown' || PRODINFO_ATTRIBUTE_PLUGIN_MULTI == 'single_radioset') && (PRODINFO_ATTRIBUTE_DYNAMIC_STATUS == '1' || PRODINFO_ATTRIBUTE_DYNAMIC_STATUS == '2')) {
     /* Breakdown the attributes into individual attributes to then be able to 
      * feed them into the applicable section(s).
      * 
      */
 }
 // how many currently in cart for attribute
 $chk_mixed = zen_get_products_quantity_mixed($_POST['products_id'][$i]);
 // use mixed
 if ($productIsSBA[$i] && (PRODINFO_ATTRIBUTE_PLUGIN_MULTI == 'single_dropdown' || PRODINFO_ATTRIBUTE_PLUGIN_MULTI == 'single_radioset') && (PRODINFO_ATTRIBUTE_DYNAMIC_STATUS == '1' || PRODINFO_ATTRIBUTE_DYNAMIC_STATUS == '2')) {
     /* Breakdown the attributes into individual attributes to then be able to 
      * feed them into the applicable section(s).
      * 
      */
 }
 $new_qty = $_SESSION['cart']->adjust_quantity($new_qty, $_POST['products_id'][$i], 'shopping_cart');
 // bof: adjust new quantity to be same as current in stock
 // Mine          $chk_current_qty = zen_get_products_stock($_POST['products_id'][$i]);
 //          if (!$productIsSBA[$i]) {
 //            $chk_current_qty = zen_get_products_stock($_POST['products_id'][$i]);
 //          } else {
 if ($productIsSBA[$i] && (PRODINFO_ATTRIBUTE_PLUGIN_MULTI == 'single_dropdown' || PRODINFO_ATTRIBUTE_PLUGIN_MULTI == 'single_radioset') && (PRODINFO_ATTRIBUTE_DYNAMIC_STATUS == '1' || PRODINFO_ATTRIBUTE_DYNAMIC_STATUS == '2')) {
     /* Breakdown the attributes into individual attributes to then be able to