Zen Cart Logo
Forums / Addon Templates / Support Thread: Checkbox Textbox Icon Addon for Listings

Support Thread: Checkbox Textbox Icon Addon for Listings

Views: 26,281

Results 41 to 49 of 49
29 Dec 2018, 9:50 PM
#41
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Support Thread: Checkbox Textbox Icon Addon for Listings

linuxguy2:

Here is the newly generated shopping_cart class method to support this plugin... I haven't tested it, but the code looks right The two modifications are commented:

  /**
   * Method to handle cart Action - multiple add products
   *
   * @param string forward destination
   * @param url parameters
   * @todo change while loop to a foreach
   */
  function actionMultipleAddProduct($goto, $parameters) {
    global $messageStack;
    if ($this->display_debug_messages) $messageStack->add_session('header', 'FUNCTION ' . __FUNCTION__, 'caution');

    $addCount = 0;
    if (is_array($_POST['products_id']) && sizeof($_POST['products_id']) > 0) {
      // Begin mc12345678 Checkbox/TextBox 1 of 2
      if ($_POST['check_text_active'] == true) {
        $multiAddCheck = true;
      } else {
        $multiAddCheck = false;
      }
      // End mc12345678 Checkbox/TextBox 1 of 2
//echo '<pre>'; echo var_dump($_POST['products_id']); echo '</pre>';
      $products_list = $_POST['products_id'];
      foreach($products_list as $key => $val) {
        $prodId = preg_replace('/[^0-9a-f:.]/', '', $key);
        // Begin mc12345678 Checkbox/TextBox 2 of 2
        if (
            (
              defined('PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == '1'
             )
            && $multiAddCheck == true
            ) {
          
          foreach($_POST['products_id2'] as $key2 => $val2) {
            if ($key == $key2) {
              if (is_numeric($val) && $val > 0) 
              {
                $adjust_max = false;
                $qty = $val;
                $add_max = zen_get_products_quantity_order_max($prodId);
                $cart_qty = $this->in_cart_mixed($prodId);
                $new_qty = $this->adjust_quantity($qty, $prodId, 'shopping_cart');
                
                if (($add_max == 1 and $cart_qty == 1)) {
                  // do not add
                  $adjust_max= 'true';
                } else {
                  // adjust quantity if needed
                  if ((($new_qty + $cart_qty > $add_max) and $add_max != 0)) {
                    $adjust_max= 'true';
                    $new_qty = $add_max - $cart_qty;
                  }
                  $this->add_cart($prodId, $this->get_quantity($prodId)+($new_qty));
                  $addCount++;
                }
                if ($adjust_max == 'true') {
                  if ($this->display_debug_messages) $messageStack->add_session('header', 'FUNCTION ' . __FUNCTION__ . '<br>' . ERROR_MAXIMUM_QTY . zen_get_products_name($prodId), 'caution');
                  $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($prodId), 'caution');
                }
              }
              break; /*Add product, otherwise don't add */ 
              
            }
          }
        } elseif (is_numeric($val) && $val > 0) {
          // End mc12345678 Checkbox/TextBox 2 of 2
          $adjust_max = false;
          $qty = $val;
          $add_max = zen_get_products_quantity_order_max($prodId);
          $cart_qty = $this->in_cart_mixed($prodId);
          $new_qty = $this->adjust_quantity($qty, $prodId, 'shopping_cart');

// bof: adjust new quantity to be same as current in stock
          $chk_current_qty = zen_get_products_stock($prodId);
          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($prodId), 'caution');
          }
// eof: adjust new quantity to be same as current in stock

          if (($add_max == 1 and $cart_qty == 1)) {
            // do not add
            $adjust_max= 'true';
          } else {
// 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($prodId), 'caution');
            }
// eof: adjust new quantity to be same as current in stock
            // adjust quantity if needed
            if ((($new_qty + $cart_qty > $add_max) and $add_max != 0)) {
              $adjust_max= 'true';
              $new_qty = $add_max - $cart_qty;
            }
            $this->add_cart($prodId, $this->get_quantity($prodId)+($new_qty));
            $addCount++;
          }
          if ($adjust_max == 'true') {
            if ($this->display_debug_messages) $messageStack->add_session('header', 'FUNCTION ' . __FUNCTION__ . '<br>' . ERROR_MAXIMUM_QTY . zen_get_products_name($prodId), 'caution');
            $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($prodId), 'caution');
          }
        }
        if (!is_numeric($val) || $val < 0) {
          // adjust quantity when not a value
          $chk_link = '<a href="' . zen_href_link(zen_get_info_page($prodId), 'cPath=' . (zen_get_generated_category_path_rev(zen_get_products_category_id($prodId))) . '&products_id=' . $prodId) . '">' . zen_get_products_name($prodId) . '</a>';
          $messageStack->add_session('header', ERROR_CORRECTIONS_HEADING . ERROR_PRODUCT_QUANTITY_UNITS_SHOPPING_CART . $chk_link . ' ' . PRODUCTS_ORDER_QTY_TEXT . zen_output_string_protected($val), 'caution');
          $val = 0;
        }
      }
// display message if all is good and not on shopping_cart page
      if (($addCount && 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 (DISPLAY_CART == 'false') {
          zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
        }
      }
      zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters)));
    }
  }
30 Dec 2018, 11:35 PM
#42
linuxguy2 avatar

linuxguy2

Zen Follower

Join Date:
Sep 2013
Location:
Texas
Posts:
315
Plugin Contributions:
0

Re: Support Thread: Checkbox Textbox Icon Addon for Listings

mc12345678:

linuxguy2:

Here is the newly generated shopping_cart class method to support this plugin... I haven't tested it, but the code looks right The two modifications are commented:

/**

  • Method to handle cart Action - multiple add products
  • @param string forward destination
  • @param url parameters
  • @todo change while loop to a foreach
    */
    function actionMultipleAddProduct($goto, $parameters) {
    global $messageStack;
    if ($this->display_debug_messages) $messageStack->add_session('header', 'FUNCTION ' . FUNCTION, 'caution');
$addCount = 0;
if (is_array($_POST['products_id']) && sizeof($_POST['products_id']) > 0) {

// Begin mc12345678 Checkbox/TextBox 1 of 2
if ($_POST['check_text_active'] == true) {
$multiAddCheck = true;
} else {
$multiAddCheck = false;
}

// End mc12345678 Checkbox/TextBox 1 of 2
//echo '<pre>'; echo var_dump($_POST['products_id']); echo '</pre>';
$products_list = $_POST['products_id'];
foreach($products_list as $key => $val) {
$prodId = preg_replace('/[^0-9a-f:.]/', '', $key);
// Begin mc12345678 Checkbox/TextBox 2 of 2
if (
(
defined('PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE == '1'
|| defined('PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE == '1'
|| defined('PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE == '1'
|| defined('PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == '1'
)
&& $multiAddCheck == true
) {

      foreach($_POST['products_id2'] as $key2 => $val2) {
        if ($key == $key2) {
          if (is_numeric($val) && $val > 0) 
          {
            $adjust_max = false;
            $qty = $val;
            $add_max = zen_get_products_quantity_order_max($prodId);
            $cart_qty = $this->in_cart_mixed($prodId);
            $new_qty = $this->adjust_quantity($qty, $prodId, 'shopping_cart');
            
            if (($add_max == 1 and $cart_qty == 1)) {
              // do not add
              $adjust_max= 'true';
            } else {
              // adjust quantity if needed
              if ((($new_qty + $cart_qty > $add_max) and $add_max != 0)) {
                $adjust_max= 'true';
                $new_qty = $add_max - $cart_qty;
              }
              $this->add_cart($prodId, $this->get_quantity($prodId)+($new_qty));
              $addCount++;
            }
            if ($adjust_max == 'true') {
              if ($this->display_debug_messages) $messageStack->add_session('header', 'FUNCTION ' . __FUNCTION__ . '<br>' . ERROR_MAXIMUM_QTY . zen_get_products_name($prodId), 'caution');
              $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($prodId), 'caution');
            }
          }
          break; /*Add product, otherwise don't add */ 
          
        }
      }
    } elseif (is_numeric($val) && $val > 0) {
      // End mc12345678 Checkbox/TextBox 2 of 2
      $adjust_max = false;
      $qty = $val;
      $add_max = zen_get_products_quantity_order_max($prodId);
      $cart_qty = $this->in_cart_mixed($prodId);
      $new_qty = $this->adjust_quantity($qty, $prodId, 'shopping_cart');

// bof: adjust new quantity to be same as current in stock
$chk_current_qty = zen_get_products_stock($prodId);
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($prodId), 'caution');
}
// eof: adjust new quantity to be same as current in stock

      if (($add_max == 1 and $cart_qty == 1)) {
        // do not add
        $adjust_max= 'true';
      } else {

// 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($prodId), 'caution');
}
// eof: adjust new quantity to be same as current in stock
// adjust quantity if needed
if ((($new_qty + $cart_qty > $add_max) and $add_max != 0)) {
$adjust_max= 'true';
$new_qty = $add_max - $cart_qty;
}
$this->add_cart($prodId, $this->get_quantity($prodId)+($new_qty));
$addCount++;
}
if ($adjust_max == 'true') {
if ($this->display_debug_messages) $messageStack->add_session('header', 'FUNCTION ' . FUNCTION . '<br>' . ERROR_MAXIMUM_QTY . zen_get_products_name($prodId), 'caution');
$messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($prodId), 'caution');
}
}
if (!is_numeric($val) || $val < 0) {
// adjust quantity when not a value
$chk_link = '<a href="' . zen_href_link(zen_get_info_page($prodId), 'cPath=' . (zen_get_generated_category_path_rev(zen_get_products_category_id($prodId))) . '&products_id=' . $prodId) . '">' . zen_get_products_name($prodId) . '</a>';
$messageStack->add_session('header', ERROR_CORRECTIONS_HEADING . ERROR_PRODUCT_QUANTITY_UNITS_SHOPPING_CART . $chk_link . ' ' . PRODUCTS_ORDER_QTY_TEXT . zen_output_string_protected($val), 'caution');
$val = 0;
}
}
// display message if all is good and not on shopping_cart page
if (($addCount && 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 (DISPLAY_CART == 'false') {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
}
}
zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters)));
}
}


Thanks, I'll check it out later today or tomorrow.
1 Jan 2019, 7:54 PM
#43
linuxguy2 avatar

linuxguy2

Zen Follower

Join Date:
Sep 2013
Location:
Texas
Posts:
315
Plugin Contributions:
0

Re: Support Thread: Checkbox Textbox Icon Addon for Listings

linuxguy2:

Thanks, I'll check it out later today or tomorrow.

zen-cart-v1.5.6-12102018 (Responsive_classic)
Apache Version 2.4.34
PHP Version 7.1
MySQL Version 10.2.18-MariaDB
Plugins:
ColumnGridLayout_for_155f
CheckBoxTextBoxIconV1.0.3 (modified)
one_page_checkout-2.0.5
extra_field_on_customer_sign_up_0
purchase_order_basic_v1_1b
EasyPopulate-4.master-ZC

mc12345678,

Merged with ZC v1.5.6 shopping_cart class code and works with this Warning.
(same Warning with PHP 7.2)

[01-Jan-2019 19:25:21 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/pcsnnets/public_html/tp156/includes/classes/shopping_cart.php on line 2082
CODE AT 2082:  foreach($_POST['products_id2'] as $key2 => $val2) {

Does appear to have removed the (true) vs. ('true') workaround required in post on 8 Oct 2018, 08:20 PM.
Will test further.

Thank You Very Much for your time and expertise!

Should I create a new thread elsewhere of my post of 13 Nov 2018, 11:00 AM. (or should it be moved )

1 Jan 2019, 8:07 PM
#44
linuxguy2 avatar

linuxguy2

Zen Follower

Join Date:
Sep 2013
Location:
Texas
Posts:
315
Plugin Contributions:
0

Re: Support Thread: Checkbox Textbox Icon Addon for Listings

linuxguy2:

zen-cart-v1.5.6-12102018 (Responsive_classic)
Apache Version 2.4.34
PHP Version 7.1
MySQL Version 10.2.18-MariaDB
Plugins:
ColumnGridLayout_for_155f
CheckBoxTextBoxIconV1.0.3 (modified)
one_page_checkout-2.0.5
extra_field_on_customer_sign_up_0
purchase_order_basic_v1_1b
EasyPopulate-4.master-ZC

mc12345678,

Merged with ZC v1.5.6 shopping_cart class code and works with this Warning.
(same Warning with PHP 7.2)

[01-Jan-2019 19:25:21 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/pcsnnets/public_html/tp156/includes/classes/shopping_cart.php on line 2082
CODE AT 2082: foreach($_POST['products_id2'] as $key2 => $val2) {

> 
> Does appear to have removed the (true) vs. ('true') workaround required in post on 8 Oct 2018, 08:20 PM.
> Will test further.
> 
> Thank You Very Much for your time and expertise!
> 
> Should I create a new thread elsewhere of my post of 13 Nov 2018, 11:00 AM.  (or should it be moved )

Link to merged file:
linuxguy2.com/ShoppingCart.html
25 Feb 2019, 6:15 PM
#45
linuxguy2 avatar

linuxguy2

Zen Follower

Join Date:
Sep 2013
Location:
Texas
Posts:
315
Plugin Contributions:
0

Re: Support Thread: Checkbox Textbox Icon Addon for Listings

MC12345678
I resolved all the other issues but do have one more warning I'd like to get rid of.
The cart functions Ok but if I click "Add Multiple to Cart" without selecting a product I get the warning shown at the end of this post. I guess "products_id2" always expects a value.
Good news is No products are added.

Line 2092 in shopping_cart.php below is highlighted in red.

This warning occurrs with or without the 'true' mod in

home/pcs/public_html/19/includes/modules/product_listing.php  

if ((PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == true)) {
        echo zen_draw_hidden_field('check_text_active', 'true'); 
    }
	/*End mc12345678 Added for checkbox/textbox Plug-In */

home/pcs/public_html/19/includes/classes/shopping_cart.php

   * Method to handle cart Action - multiple add products
   *
   * @param string forward destination
   * @param url parameters
   * @todo change while loop to a foreach
   */
  function actionMultipleAddProduct($goto, $parameters) {
    global $messageStack;
    if ($this->display_debug_messages) $messageStack->add_session('header', 'FUNCTION ' . __FUNCTION__, 'caution');

    $addCount = 0;
    if (is_array($_POST['products_id']) && sizeof($_POST['products_id']) > 0) {

    // Begin mc12345678 Checkbox/TextBox 1 of 2
      if ($_POST['check_text_active'] == true) {
        $multiAddCheck = true;
      } else {
        $multiAddCheck = false;
      }
      // End mc12345678 Checkbox/TextBox 1 of 2

//echo '<pre>'; echo var_dump($_POST['products_id']); echo '</pre>';
      $products_list = $_POST['products_id'];
      foreach($products_list as $key => $val) {
        $prodId = preg_replace('/[^0-9a-f:.]/', '', $key);

        // Begin mc12345678 Checkbox/TextBox 2 of 2
        if (
            (
              defined('PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == '1'
             )
            && $multiAddCheck == true
            ) {
          
          foreach($_POST['products_id2'] as $key2 => $val2) {
            if ($key == $key2) {
              if (is_numeric($val) && $val > 0) 
              {
                $adjust_max = false;
                $qty = $val;
                $add_max = zen_get_products_quantity_order_max($prodId);
                $cart_qty = $this->in_cart_mixed($prodId);
                $new_qty = $this->adjust_quantity($qty, $prodId, 'shopping_cart');
                
                if (($add_max == 1 and $cart_qty == 1)) {
                  // do not add
                  $adjust_max= 'true';
                } else {
                  // adjust quantity if needed
                  if ((($new_qty + $cart_qty > $add_max) and $add_max != 0)) {
                    $adjust_max= 'true';
                    $new_qty = $add_max - $cart_qty;
                  }
                  $this->add_cart($prodId, $this->get_quantity($prodId)+($new_qty));
                  $addCount++;
                }
                if ($adjust_max == 'true') {
                  if ($this->display_debug_messages) $messageStack->add_session('header', 'FUNCTION ' . __FUNCTION__ . '<br>' . ERROR_MAXIMUM_QTY . zen_get_products_name($prodId), 'caution');
                  $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($prodId), 'caution');
                }
              }
              break; /*Add product, otherwise don't add */ 
              
            }
          }
        } elseif (is_numeric($val) && $val > 0) {
          // End mc12345678 Checkbox/TextBox 2 of 2
        
          $adjust_max = false;
          $qty = $val;
          $add_max = zen_get_products_quantity_order_max($prodId);
          $cart_qty = $this->in_cart_mixed($prodId);
          $new_qty = $this->adjust_quantity($qty, $prodId, 'shopping_cart');

Warning:

[25-Feb-2019 17:35:18 UTC] Request URI: /19/index.php?main_page=index&cPath=5&sort=20a&action=multiple_products_add_product, IP address: 76.182.229.147
#1  shoppingCart->actionMultipleAddProduct() called at [/home/pcs/public_html/19/includes/main_cart_actions.php:55]
#2  require(/home/pcs/public_html/19/includes/main_cart_actions.php) called at [/home/pcs/public_html/19/includes/init_includes/init_cart_handler.php:44]
#3  require(/home/pcs/public_html/19/includes/init_includes/init_cart_handler.php) called at [/home/pcs/public_html/19/includes/autoload_func.php:48]
#4  require(/home/pc/public_html/19/includes/autoload_func.php) called at [/home/pcs/public_html/19/includes/application_top.php:170]
#5  require(/home/pcs/public_html/19/includes/application_top.php) called at [/home/pcs/public_html/19/index.php:26]
--> PHP Warning: Invalid argument supplied for foreach() in /home/pcs/public_html/19/includes/classes/shopping_cart.php on line 2092.
25 Feb 2019, 6:30 PM
#46
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Support Thread: Checkbox Textbox Icon Addon for Listings

linuxguy2:

MC12345678
I resolved all the other issues but do have one more warning I'd like to get rid of.
The cart functions Ok but if I click "Add Multiple to Cart" without selecting a product I get the warning shown at the end of this post. I guess "products_id2" always expects a value.
Good news is No products are added.

Line 2092 in shopping_cart.php below is highlighted in red.

This warning occurrs with or without the 'true' mod in

home/pcs/public_html/19/includes/modules/product_listing.php

if ((PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == true)) {
echo zen_draw_hidden_field('check_text_active', 'true');
}
/*End mc12345678 Added for checkbox/textbox Plug-In */

> 
> home/pcs/public_html/19/includes/classes/shopping_cart.php
> ```
   * Method to handle cart Action - multiple add products
   *
   * @param string forward destination
   * @param url parameters
   * @todo change while loop to a foreach
   */
  function actionMultipleAddProduct($goto, $parameters) {
    global $messageStack;
    if ($this->display_debug_messages) $messageStack->add_session('header', 'FUNCTION ' . __FUNCTION__, 'caution');

    $addCount = 0;
    if (is_array($_POST['products_id']) && sizeof($_POST['products_id']) > 0) {

    // Begin mc12345678 Checkbox/TextBox 1 of 2
      if ($_POST['check_text_active'] == true) {
        $multiAddCheck = true;
      } else {
        $multiAddCheck = false;
      }
      // End mc12345678 Checkbox/TextBox 1 of 2

//echo '<pre>'; echo var_dump($_POST['products_id']); echo '</pre>';
      $products_list = $_POST['products_id'];
      foreach($products_list as $key => $val) {
        $prodId = preg_replace('/[^0-9a-f:.]/', '', $key);

        // Begin mc12345678 Checkbox/TextBox 2 of 2
        if (
            (
              defined('PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == '1'
             )
            && $multiAddCheck == true
            ) {
          
          foreach($_POST['products_id2'] as $key2 => $val2) {
            if ($key == $key2) {
              if (is_numeric($val) && $val > 0) 
              {
                $adjust_max = false;
                $qty = $val;
                $add_max = zen_get_products_quantity_order_max($prodId);
                $cart_qty = $this->in_cart_mixed($prodId);
                $new_qty = $this->adjust_quantity($qty, $prodId, 'shopping_cart');
                
                if (($add_max == 1 and $cart_qty == 1)) {
                  // do not add
                  $adjust_max= 'true';
                } else {
                  // adjust quantity if needed
                  if ((($new_qty + $cart_qty > $add_max) and $add_max != 0)) {
                    $adjust_max= 'true';
                    $new_qty = $add_max - $cart_qty;
                  }
                  $this->add_cart($prodId, $this->get_quantity($prodId)+($new_qty));
                  $addCount++;
                }
                if ($adjust_max == 'true') {
                  if ($this->display_debug_messages) $messageStack->add_session('header', 'FUNCTION ' . __FUNCTION__ . '<br>' . ERROR_MAXIMUM_QTY . zen_get_products_name($prodId), 'caution');
                  $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($prodId), 'caution');
                }
              }
              break; /*Add product, otherwise don't add */ 
              
            }
          }
        } elseif (is_numeric($val) && $val > 0) {
          // End mc12345678 Checkbox/TextBox 2 of 2
        
          $adjust_max = false;
          $qty = $val;
          $add_max = zen_get_products_quantity_order_max($prodId);
          $cart_qty = $this->in_cart_mixed($prodId);
          $new_qty = $this->adjust_quantity($qty, $prodId, 'shopping_cart');

Warning:

[25-Feb-2019 17:35:18 UTC] Request URI: /19/index.php?main_page=index&cPath=5&sort=20a&action=multiple_products_add_product, IP address: 76.182.229.147
#1 shoppingCart->actionMultipleAddProduct() called at [/home/pcs/public_html/19/includes/main_cart_actions.php:55]
#2 require(/home/pcs/public_html/19/includes/main_cart_actions.php) called at [/home/pcs/public_html/19/includes/init_includes/init_cart_handler.php:44]
#3 require(/home/pcs/public_html/19/includes/init_includes/init_cart_handler.php) called at [/home/pcs/public_html/19/includes/autoload_func.php:48]
#4 require(/home/pc/public_html/19/includes/autoload_func.php) called at [/home/pcs/public_html/19/includes/application_top.php:170]
#5 require(/home/pcs/public_html/19/includes/application_top.php) called at [/home/pcs/public_html/19/index.php:26]
--> PHP Warning: Invalid argument supplied for foreach() in /home/pcs/public_html/19/includes/classes/shopping_cart.php on line 2092.

Change this portion from:
   // Begin mc12345678 Checkbox/TextBox 2 of 2
    if (
        (
          defined('PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == '1'
         )
        && $multiAddCheck == true
        ) {

To:
   // Begin mc12345678 Checkbox/TextBox 2 of 2
    if (
        !empty($_POST['products_id2']) &&
        (
          defined('PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == '1'
         )
        && $multiAddCheck == true
        ) {
25 Feb 2019, 7:28 PM
#47
linuxguy2 avatar

linuxguy2

Zen Follower

Join Date:
Sep 2013
Location:
Texas
Posts:
315
Plugin Contributions:
0

Re: Support Thread: Checkbox Textbox Icon Addon for Listings

mc12345678:

Change this portion from:

   // Begin mc12345678 Checkbox/TextBox 2 of 2
    if (
        (
          defined('PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == '1'
         )
        && $multiAddCheck == true
        ) {
> 
> To:
> ```
       // Begin mc12345678 Checkbox/TextBox 2 of 2
        if (
            !empty($_POST['products_id2']) &&
            (
              defined('PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == '1'
             )
            && $multiAddCheck == true
            ) {

That tweak causes the old problem where it adds everything in the product listing whether its' checked or unchecked.
Tested switching the 'true' to true in "product_listing.php" but no joy.
BTW
Here's my Admin settings

Display Product Add to Cart Button (0=off; 1=on; 2=on with Qty Box per Product; 3=on with Adj per Product)	3
Display Multiple Products Qty Box Status and Set Button Location	3 
Display Check Box and Text Box for Checkout	1 
Display Check Box for Checkout	0	
Display Cart Quantity (0 - None, 1 - Greater than 0, 2 - Always)	0
25 Feb 2019, 9:17 PM
#48
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Support Thread: Checkbox Textbox Icon Addon for Listings

mc12345678:

Change this portion from:

   // Begin mc12345678 Checkbox/TextBox 2 of 2
    if (
        (
          defined('PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == '1'
         )
        && $multiAddCheck == true
        ) {
> 
> To:
> ```
       // Begin mc12345678 Checkbox/TextBox 2 of 2
        if (
            !empty($_POST['products_id2']) &&
            (
              defined('PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == '1'
             )
            && $multiAddCheck == true
            ) {

linuxguy2:

That tweak causes the old problem where it adds everything in the product listing whether its' checked or unchecked.
Tested switching the 'true' to true in "product_listing.php" but no joy.
BTW
Here's my Admin settings

Display Product Add to Cart Button (0=off; 1=on; 2=on with Qty Box per Product; 3=on with Adj per Product) 3
Display Multiple Products Qty Box Status and Set Button Location 3
Display Check Box and Text Box for Checkout 1
Display Check Box for Checkout 0
Display Cart Quantity (0 - None, 1 - Greater than 0, 2 - Always) 0


I get it. Went a little too far back in the "correction". Then instead:
Change this portion from:
   // Begin mc12345678 Checkbox/TextBox 2 of 2
    if (
        (
          defined('PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == '1'
         )
        && $multiAddCheck == true
        ) {

To:
   // Begin mc12345678 Checkbox/TextBox 2 of 2
    if (
        (
          defined('PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == '1'
         )
        && $multiAddCheck == true
        ) {
        if (empty($_POST['products_id2'])) $_POST['products_id2'] = array();
26 Feb 2019, 3:50 AM
#49
linuxguy2 avatar

linuxguy2

Zen Follower

Join Date:
Sep 2013
Location:
Texas
Posts:
315
Plugin Contributions:
0

Re: Support Thread: Checkbox Textbox Icon Addon for Listings

mc12345678:

I get it. Went a little too far back in the "correction". Then instead:
Change this portion from:

   // Begin mc12345678 Checkbox/TextBox 2 of 2
    if (
        (
          defined('PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE == '1'
          || defined('PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == '1'
         )
        && $multiAddCheck == true
        ) {
> 
> To:
> ```
       // Begin mc12345678 Checkbox/TextBox 2 of 2
        if (
            (
              defined('PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_ALL_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_FEATURED_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_NEW_CHECKBOX_TEXTBOX_ACTIVE == '1'
              || defined('PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE') && PRODUCT_LISTING_CHECKBOX_TEXTBOX_ACTIVE == '1'
             )
            && $multiAddCheck == true
            ) {
            if (empty($_POST['products_id2'])) $_POST['products_id2'] = array();

Tested and it now appears to work properly!

Many Thanks for your time and expertise!