Forums / All Other Contributions/Addons / Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Views: 660,384

Results 3,541 to 3,560 of 3,609
29 Aug 2023, 9:25 PM
#3541
mc12345678 avatar

mc12345678

Totally Zenned

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

Stock by Attribute v4.0 addon for v1.3.5-1.3.9

gemohler:

Last question, then I have a lot of other work to do.

How do I set "No, Do not show Quantity Box" in EP?
Question is more applicable for the EP4 thread; however, the specific products table field to "not show the quantity box" is: products_qty_box_status
That field can be added to your export/import of EP4 fields by updating the user defined fields within the configuration. In your import/export file, the field will be shown as: v_products_qty_box_status; however, the user defined fields should just identify the field as it is listed in the products table: products_qty_box_status
Then, setting that value to 0 will prevent the display of the quantity box on the product information page (when considering a Zen Cart standard/base template). Templates could be designed that exclude this feature/capability so if such is not working in your cart, then please attempt to use one of the Zen Cart default templates for testing and discovering where the problem is.

In a standard Zen Cart template, the same effect can be made by restricting the maximum product quantity to 1. Note though that these two characteristics may operate differently throughout the store. For example, having a product quantity of only 1 being added from the product information page, means that for each add to the cart only a quantity of 1 is added, but the total quantity at checkout could exceed 1. Limiting a maximum product quantity to 1 is expected to prevent the cart from having any quantity larger than 1 meaning ultimately checkout of that product can be of only a quantity of 1. (While not necessarily easily done in the base code, if a partial quantity of the product can be incorporated, then the expectation of having a maximum quantity of 1 is that at no time could any portion of a quantity added to the existing amount expected to be able to exceed 1.)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

29 Aug 2023, 10:10 PM
#3542
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

lsde:

Current version 1.5.7b
Using 1 option name with "SBA Select List (Dropdown) Basic" and I would like to rearrange how the quantity and price show in the dropdown. Current order is option value + stock qty + price. Would like to have it read option value + price + stock qty.
Pretty sure I need to edit class.products_with_attributes_stock.php not sure where. Any guidance would be appreciated.
Thanks
lsde, I apologize for two things, one in attempting to create my post about the quantity box, I lost what I had researched and begun creating to answer your question, two is that I had not completed that response in a more timely manner.

Basically, the stock quantity text is generated and incorporated in $PWA_STOCK_QTY within includes/classes/observers/class.products_with_attributes_stock.php.
The "safest" way that I see to resequence the data so that the newly added stock quantity does not appear in other potentially undesirable areas, would be to add an additional notifier to your copy of includes/modules/YOUR_TEMPLATE/attributes.php after this code group:

        $zco_notifier->notify('NOTIFY_ATTRIBUTES_MODULE_ORIGINAL_PRICE', $products_options->fields, $products_options_array, $products_options_display_price, $data_properties);




        $products_options_array[count($products_options_array) - 1]['text'] .= $products_options_display_price;

to look something like this:

        $zco_notifier->notify('NOTIFY_ATTRIBUTES_MODULE_ORIGINAL_PRICE', $products_options->fields, $products_options_array, $products_options_display_price, $data_properties);




        $products_options_array[count($products_options_array) - 1]['text'] .= $products_options_display_price;


        $zco_notifier->notify('NOTIFY_ATTRIBUTES_MODULE_AFTER_ORIGINAL_PRICE', $products_options->fields, $products_options_array, $data_properties);

The reason is this: The developers and associated code maintainers have merged in the price to the notifier: NOTIFY_ATTRIBUTES_MODULE_ORIGINAL_PRICE, such that if $products_options_display_price is modified to include your desired stock quantity at the end, it will impact later usage of that variable. Further there is no notifier before the next addition of text to $products_options_array[nth_value]['text'] to force/guarantee that the quantity would be the next value added because weight information is possibly the next content to be added to that array value. Then if weight information isn't added, the next existing code opportunity is to use the observer: NOTIFY_ATTRIBUTES_MODULE_BEFORE_ASSEMBLE_OUTPUTS with a forced global in that observer to update that text or for specifically observing about 'SBA Select List' to do similar in the observer for NOTIFY_ATTRIBUTES_MODULE_DEFAULT_SWITCH (again recognizing that this addition would be after any expected addition of weight related text).

If the text is added directly to the price related information, then note that $products_options_details and $products_options_details_noname will each also include that additional information and that there are unevaluated downstream affects of that additional content.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

8 Nov 2023, 9:00 PM
#3543
strelitzia avatar

strelitzia

Totally Zenned

Join Date:
Nov 2005
Location:
France
Posts:
588
Plugin Contributions:
1

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Is there a simple switch to disable a selected attribute being shown as the product image in the shopping cart?

I didn't see anything in admin for it so if I missed it, either I'm losing the plot or I need to update the prescription on my glasses!

Zen Cart developer since 2009 — Zen Cart Solutions
Ecommerce development, integrations & automation — Junction Solutions

8 Nov 2023, 9:03 PM
#3544
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

strelitzia:

Is there a simple switch to disable a selected attribute being shown as the product image in the shopping cart?

I didn't see anything in admin for it so if I missed it, either I'm losing the plot or I need to update the prescription on my glasses!

To confirm terminology and request, it's OK to swap the image on the product page, but not on the shopping cart page? Is that the request?

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

8 Nov 2023, 9:10 PM
#3545
strelitzia avatar

strelitzia

Totally Zenned

Join Date:
Nov 2005
Location:
France
Posts:
588
Plugin Contributions:
1

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

I don't need to swap images on either page. The attribute images are simply a graphical display of nicotine strength in e-liquids. The same attribute images are used across all products so disabling image swap completely would be the preferred method.

Zen Cart developer since 2009 — Zen Cart Solutions
Ecommerce development, integrations & automation — Junction Solutions

8 Nov 2023, 9:21 PM
#3546
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

strelitzia:

I don't need to swap images on either page. The attribute images are simply a graphical display of nicotine strength in e-liquids. The same attribute images are used across all products so disabling image swap completely would be the preferred method.

Then yes, SBA Display Attributes Images set to 0 would accomplish not swapping. That configuration setting should have been added to configuration->Stock during install/upgrade.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

8 Nov 2023, 9:26 PM
#3547
strelitzia avatar

strelitzia

Totally Zenned

Join Date:
Nov 2005
Location:
France
Posts:
588
Plugin Contributions:
1

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

mc12345678:

Then yes, SBA Display Attributes Images set to 0 would accomplish not swapping. That configuration setting should have been added to configuration->Stock during install/upgrade.

And therein lies the problem. As it was an image related change I was looking under the 'Images' configuration options. TBH it never even occurred to me to look under 'Stock'.

Thanks for the quick response mcnumbers

Zen Cart developer since 2009 — Zen Cart Solutions
Ecommerce development, integrations & automation — Junction Solutions

8 Nov 2023, 9:31 PM
#3548
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

strelitzia:

And therein lies the problem. As it was an image related change I was looking under the 'Images' configuration options. TBH it never even occurred to me to look under 'Stock'.

Thanks for the quick response mcnumbers

In development when there was a lot spoken about configuration listing assignment, tried to keep as much in one place as reasonably possible. Haven't gone back to revisit and not sure what additional value to users there would be.

Had toyed with idea of a unique configuration menu just for SBA, a separate admin page, mixing into default areas, etc... sorry about the confusion caused in this case, but glad to help!

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

8 Mar 2024, 1:53 PM
#3549
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

[ZC v1.5.8][Bootstrap v3.5.0]

I have a problem of image swapping on the product info page for Bootstrap template.
When I switch to other templates, e.g. Classic Contemporary Green or Responsive Classic Template, image swapping works fine.

I have the hunch that it is due to includes/modules/bootstrap/attributes.php
because on an earlier version of this file (later overwritten) mc12345678 wrote in the info-header:

 * attributes module
 *
 * Prepares attributes content for rendering in the template system
 * Prepares HTML for input fields with required uniqueness so template can display them as needed and keep collected data in proper fields
 *
 * @package modules
 * @copyright Copyright 2003-2018 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: mc12345678 Fri Nov 9 21:03:09 2018 -0500 Modified in v1.5.6 $
 * 
 * Stock by Attributes 1.5.4 : mc12345678 16-01-02
 * Attribute image replaces main product image on selecting attribute mc12345678 16-12-09
 * Incorporated to support ZC 1.5.1 and up when using SBA.

So, obviously it is needed for image swapping.
However, there are far too many changes in the attributes file that I do not know where to start.
Is there any adapted version of the bootstrap's or can anyone guide me what essential changes to make in the attributes.php ?

9 Mar 2024, 5:31 PM
#3550
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

I don't recall at what version of Zen Cart, but at that point which includes 1.5.8 (back to some version) the attributes file did not require override. The base 1.5.8 version is sufficient. Further the Javascript/jquery involved does not override the associated actions.

My suggestion would be to consider inspecting your page(s) for html and/or Javascript validation. The template may not validate and cause swap issues. Another may be that expected tags may have been altered.

As normally is presented in the posting tips, for others to independently see the on page issues, an example link should be given. If another page works within the same template then that should be shared as well. Of course break it up as necessary to prevent indexing or that sort of web action.

Then lastly, suggest identifying versions of things installed.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

20 Mar 2024, 4:43 PM
#3551
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

[ZC v1.5.8][Bootstrap v3.5.0][SBA v4.0]

Unfortunately I can not share a link, coz it is yet running on a localhost.
The versions of modules I use are in the upper part of my message.
I have checked for mistakes by a validator; the only important mistake i got is SBA_ProductImage id tag being repeated:

Validator message export for "https://localhost/":
Generated by CSS HTML Validator Professional 2024/v24.0100 (https://htmlval.com/)

  1. Error in line 754 at character 194: The "id" attribute value "SBA_ProductImage" has already been used in this document in a <img> tag that starts in line 719. An element's "id" value must be unique within the document. An element cannot have an "id" attribute that has already been used. Note that "id" values are treated as being case-sensitive.

  2. Error in line 765 at character 151: The "id" attribute value "SBA_ProductImage" has already been used in this document in a <img> tag that starts in line 719. An element's "id" value must be unique within the document. An element cannot have an "id" attribute that has already been used. Note that "id" values are treated as being case-sensitive.

I bet, this is the tag being used by the javascript for an image swap, so it sounded important to me.
This is probably because in includes/templates/bootstrap/templates/tpl_product_info_display.php in the <-- Main Product Image --> section there is a call to includes/templates/bootstrap/templates/tpl_modules_main_product_image.php and then from there to includes/modules/main_product_image.php which has a notifer to 'NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_FILENAME' which is observed by includes/classes/observers/auto.pwas_imageswap.php and hence in the first call to zen_image function ' id="SBA_ProductImage" ' is added to the images HTML output.
However also in tpl_product_info_display.php in the <-- Additional Product Images --> section there is a call to includes/templates/bootstrap/modalboxes/tpl_bootstrap_images.php which has an include to main_product_image.php and again SBA_ProductImage gets appended twice more to html image output.
Now, this I have overcome by stoping the observation of 'NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_FILENAME' after the first occurance of 'NOTIFY_OPTIMIZE_IMAGE' (html image output). Does it sound right?
In includes/classes/observers/auto.pwas_imageswap.php after around line 53 I add the detach statement:

    $parameters .= ' id="SBA_ProductImage" ';
	$this->detach($this, array('NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_START'));

thus no other SBA_ProductImage id tag is added to the images.

Now, this is not even the tip of the iceberg. There are a lot more changes/modifications needed in the bootstrap template files so that an image swap may succeed. Most important of all, the javascript part which is supposed to do the imageswap is not appended.

In order to separate the focus, I will discuss/consult in the following posts.

25 Mar 2024, 3:42 AM
#3552
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

zamzom:

[ZC v1.5.8][Bootstrap v3.5.0][SBA v4.0]

Unfortunately I can not share a link, coz it is yet running on a localhost.
The versions of modules I use are in the upper part of my message.
I have checked for mistakes by a validator; the only important mistake i got is SBA_ProductImage id tag being repeated:

I bet, this is the tag being used by the javascript for an image swap, so it sounded important to me.
This is probably because in includes/templates/bootstrap/templates/tpl_product_info_display.php in the <-- Main Product Image --> section there is a call to includes/templates/bootstrap/templates/tpl_modules_main_product_image.php and then from there to includes/modules/main_product_image.php which has a notifer to 'NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_FILENAME' which is observed by includes/classes/observers/auto.pwas_imageswap.php and hence in the first call to zen_image function ' id="SBA_ProductImage" ' is added to the images HTML output.
However also in tpl_product_info_display.php in the <-- Additional Product Images --> section there is a call to includes/templates/bootstrap/modalboxes/tpl_bootstrap_images.php which has an include to main_product_image.php and again SBA_ProductImage gets appended twice more to html image output.
Now, this I have overcome by stoping the observation of 'NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_FILENAME' after the first occurance of 'NOTIFY_OPTIMIZE_IMAGE' (html image output). Does it sound right?
In includes/classes/observers/auto.pwas_imageswap.php after around line 53 I add the detach statement:

$parameters .= ' id="SBA_ProductImage" ';
$this->detach($this, array('NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_START'));
> thus no other SBA_ProductImage id tag is added to the images.
> 
> Now, this is not even the tip of the iceberg. There are a lot more changes/modifications needed in the bootstrap template files so that an image swap may succeed. Most important of all, the javascript part which is supposed to do the imageswap is not appended.
> 
> In order to separate the focus, I will discuss/consult in the following posts.

There's a number of ways to address the situation. Detaching after the first occurrence can be an appropriate solution, though I personally find this designed loop to be troubling where such an observer is effectively reused. 

So what are some other ways to address/handle this? What I am thinking of doing is implementing a class internal counter that accounts for the number of times that a particular notifier is called. In this way, a modicum of control could be maintained about what is and what is not executed within a notifier. By detaching, the observer is ignored completely as compared to being entered but a quantity of action bypassed. Sure maybe an observer should only be tracked by a used/not used condition instead of them going down a "how many times have you been called" counter. Each has its place and need though I may implement one type throughout it all.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

26 Mar 2024, 3:41 PM
#3553
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

mc12345678:

There's a number of ways to address the situation. Detaching after the first occurrence can be an appropriate solution, though I personally find this designed loop to be troubling where such an observer is effectively reused.

So what are some other ways to address/handle this? What I am thinking of doing is implementing a class internal counter that accounts for the number of times that a particular notifier is called. In this way, a modicum of control could be maintained about what is and what is not executed within a notifier. By detaching, the observer is ignored completely as compared to being entered but a quantity of action bypassed. Sure maybe an observer should only be tracked by a used/not used condition instead of them going down a "how many times have you been called" counter. Each has its place and need though I may implement one type throughout it all.

Yes, I agree, therefore in fact I have been also along the same path of thinking and I have given up detaching the observer, because there are other images need to be swapped, too. I have not posted about it in here, since things are not completely working yet. But since you mentioned, here is what I have done:

Changes in auto.pwas_imageswap.php
1- I have added a new variable to count occurances of SBA_ProductImage (around after line #17)

  private $MainImage;
  
  private $image_no;     // Add underscore image no

  function __construct() {
    
	$image_no =0;     // Reset image no
    $attachNotifier = array();

2-I have changed the parameters variable as follows (around line #56)

    $parameters .= ' id="SBA_ProductImage_' . strval(++$this->image_no) . '" ';   // Modified to add underscore number

This creates id tags such as SBA_ProductImage_1, SBA_ProductImage_2 etc. for each occurance.

But then, since the javascript is looking for SBA_ProductImage id tag to replace the image, I needed to change the
includes/classes/class.products_with_attributes_class_stock.php as follows (changes are on those lines where SBA_ProductImage occurs)

  function zen_draw_pull_down_menu_SBAmod($name, $values, $default = '', $parameters = '', $required = false, $disable = array(), $options_menu_images = null) {
    
//    global $template_dir;
    $tmp_attribID = trim($name, 'id[]');//used to get the select ID reference to be used in jquery
    $field = '';
    if (defined('SBA_SHOW_IMAGE_ON_PRODUCT_INFO') && SBA_SHOW_IMAGE_ON_PRODUCT_INFO != '0' && !empty($_GET['products_id']) && $this->zen_product_is_sba($_GET['products_id'])) 
    {
      $field = /*'<script ' . *//*src="'.DIR_WS_TEMPLATES . $template_dir . '/jscript/jquery-1.10.2.min.js"*//* '></script> */
        '<script type="text/javascript">
          $(function(){
          $("#attrib-'.$tmp_attribID.'").change(function(){
      if (typeof $(this).find(":selected").attr("data-src") == "undefined") { 
              $("[id^=\'SBA_ProductImage_\']").attr("src", "'; // This is the end of the assignment to $field before the below
      if (isset($options_menu_images) && is_array($options_menu_images) && (isset($options_menu_images['product_image']) || array_key_exists('product_image', $options_menu_images))) {
        if ($options_menu_images['product_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1' 
             or $options_menu_images['product_image'] == DIR_WS_IMAGES and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
          $field .= DIR_WS_IMAGES . PRODUCTS_IMAGE_NO_IMAGE;
        } else {
          $field .= $options_menu_images['product_image'];
        }
      } else {
        if (PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
         $field .= DIR_WS_IMAGES . PRODUCTS_IMAGE_NO_IMAGE;
        }
      }
    
      $field .= '"); 
             } else { 
               $("[id^=\'SBA_ProductImage_\']").attr("src", $(this).find(":selected").attr("data-src"));
             } 
             if (typeof $("#productMainImage") != "undefined") {
               if (typeof $("#productMainImage a[href]") != "undefined") {
                 $("#productMainImage a[href]").attr("href",$("#SBA_ProductImage_1").attr("src"));
               }
             }
          });
        });
      </script>';
    }

So, it will replace all images no matter what is after the underscore.
I am not good in PHP, but particularly bad in javascript, and I found this solution on StackOverflow. Does it look good? It works fine though.

29 Mar 2024, 3:03 AM
#3555
jimmie avatar

jimmie

Totally Zenned

Join Date:
Jan 2013
Location:
New Port Richey, Florida
Posts:
971
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

how do i fix this warning
[28-Mar-2024 21:32:23 UTC] Request URI: /Returns, IP address: 44.222.104.49
#1 products_with_attributes_stock->catalogCustomID() called at [/var/www/clients/client1/web3/web/includes/classes/observers/class.pwas_customid.php:32]
#2 pwas_customid->updateNotifyHeaderEndAccountHistoryInfo() called at [/var/www/clients/client1/web3/web/includes/classes/class.base.php:103]
#3 base->notify() called at [/var/www/clients/client1/web3/web/includes/modules/pages/returns_request/header_php.php:74]
#4 require(/var/www/clients/client1/web3/web/includes/modules/pages/returns_request/header_php.php) called at [/var/www/clients/client1/web3/web/index.php:36]
--> PHP Warning: Invalid argument supplied for foreach() in /var/www/clients/client1/web3/web/includes/classes/observers/class.products_with_attributes_stock.php on line 1612.
and here is line 1612 from file

foreach ($productArray as $i => &$productsI) {
      $customid[$i] = '';
29 Mar 2024, 9:57 AM
#3556
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

jimmie:

how do i fix this warning
[28-Mar-2024 21:32:23 UTC] Request URI: /Returns, IP address: 44.222.104.49
#1 products_with_attributes_stock->catalogCustomID() called at [/var/www/clients/client1/web3/web/includes/classes/observers/class.pwas_customid.php:32]
#2 pwas_customid->updateNotifyHeaderEndAccountHistoryInfo() called at [/var/www/clients/client1/web3/web/includes/classes/class.base.php:103]
#3 base->notify() called at [/var/www/clients/client1/web3/web/includes/modules/pages/returns_request/header_php.php:74]
#4 require(/var/www/clients/client1/web3/web/includes/modules/pages/returns_request/header_php.php) called at [/var/www/clients/client1/web3/web/index.php:36]
--> PHP Warning: Invalid argument supplied for foreach() in /var/www/clients/client1/web3/web/includes/classes/observers/class.products_with_attributes_stock.php on line 1612.
and here is line 1612 from file

foreach ($productArray as $i => &$productsI) {
$customid[$i] = '';

Could you post the contents of includes/modules/pages/returns_request/header_php.php?

It appears that the code is "misusing" or not properly initiating the process to fully support reuse of the notifier associated with account history information...

While, the code may be "the same" as a possibility, perhaps the avenue to arrive there is not equivalent. When looking at the code for includes/modules/pages/account_history_info/header_php.php, there are a number of "early out" operations to ensure that processing continues successfully and as expected for arriving on that page.

Reviewing the order class initiation (__construct) at least in ZC 1.5.8, the result is at least an array of product even if that is an empty array. Provided the product member is an array, there should be no issue with attempting execution of that foreach loop. It just wouldn't do any action if it was empty. That said, I see in the order class initiation there are also two additional notifiers either of which may have been called and modified the data being returned... That could be an indicator of the situation's cause.

Based on the warning message, it appears that $order is initiated (not null), otherwise there would be an issue within observer class.pwas_customid.php at line 32 with attempting to access a null variable or accessing a member that does not exist $order->products. These issues do not arise and instead $order->products appears to not be an array, though the warning doesn't identify what type of variable it is (null, false, or something else). There may also be other information in that particular log that points to one or more of the above issues, but I have to assume that the entire log was provided.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

29 Mar 2024, 5:33 PM
#3557
jimmie avatar

jimmie

Totally Zenned

Join Date:
Jan 2013
Location:
New Port Richey, Florida
Posts:
971
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

here you go, also forgot to mention im using zen version 1.56c

<?php

/**

 *

 * @package page

 * @copyright Copyright 2003-2005 Zen Cart Development Team

 * @copyright Portions Copyright 2003 osCommerce

 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

 * @version $Id: J_Schilz for Integrated COWOA - 14 April 2007

 */

// This should be first line of the script:

$zco_notifier->notify('NOTIFY_HEADER_START_ACCOUNT_HISTORY_INFO');



    $_SESSION['navigation']->set_snapshot();



  if ($_SESSION['customer_id']) {

    zen_redirect(zen_href_link(FILENAME_ACCOUNT_HISTORY, 'action=returns_request', 'SSL'));

  }



if (!isset($_POST['order_id']) || (isset($_POST['order_id']) && !is_numeric($_POST['order_id'])))

  $errorInvalidID=TRUE;



$query_email_address = trim($_POST['query_email_address']);  

if(!isset($query_email_address) || zen_validate_email($query_email_address) == false)

  $errorInvalidEmail=TRUE;



if(!$errorInvalidID && !$errorInvalidEmail)

{



  $customer_info_query = "SELECT customers_email_address, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country,

                                 billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country     

                          FROM   " . TABLE_ORDERS . "

                          WHERE  orders_id = :ordersID";



  $customer_info_query = $db->bindVars($customer_info_query, ':ordersID', $_POST['order_id'], 'integer');

  $customer_info = $db->Execute($customer_info_query);



  if (isset($query_email_address) && $customer_info->fields['customers_email_address'] != $query_email_address && $customer_info->fields['customers_email_address'] != $query_email_address . '.')

    $errorNoMatch=TRUE;

  else

  {



    $statuses_query = "SELECT os.orders_status_name, osh.date_added, osh.comments

                       FROM   " . TABLE_ORDERS_STATUS . " os, " . TABLE_ORDERS_STATUS_HISTORY . " osh

                       WHERE      osh.orders_id = :ordersID

                       AND        osh.orders_status_id = os.orders_status_id

                       AND        os.language_id = :languagesID

                       AND        osh.customer_notified >= 0

                       ORDER BY   osh.date_added";



    $statuses_query = $db->bindVars($statuses_query, ':ordersID', $_POST['order_id'], 'integer');

    $statuses_query = $db->bindVars($statuses_query, ':languagesID', $_SESSION['languages_id'], 'integer');

    $statuses = $db->Execute($statuses_query);



    while (!$statuses->EOF) {



      $statusArray[] = array('date_added'=>$statuses->fields['date_added'],

      'orders_status_name'=>$statuses->fields['orders_status_name'],

      'comments'=>$statuses->fields['comments']);



      $statuses->MoveNext();

    }



    require(DIR_WS_CLASSES . 'order.php');

    $order = new order($_POST['order_id']);

  }

}



require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));

$breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_ACCOUNT, '', 'SSL'));







// This should be last line of the script:

$zco_notifier->notify('NOTIFY_HEADER_END_ACCOUNT_HISTORY_INFO');

?>
31 Mar 2024, 1:06 AM
#3558
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

jimmie:

here you go, also forgot to mention im using zen version 1.56c

<?php /** * * @package page * @copyright Copyright 2003-2005 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: J_Schilz for Integrated COWOA - 14 April 2007 */ // This should be first line of the script: $zco_notifier->notify('NOTIFY_HEADER_START_ACCOUNT_HISTORY_INFO'); $_SESSION['navigation']->set_snapshot(); if ($_SESSION['customer_id']) { zen_redirect(zen_href_link(FILENAME_ACCOUNT_HISTORY, 'action=returns_request', 'SSL')); } if (!isset($_POST['order_id']) || (isset($_POST['order_id']) && !is_numeric($_POST['order_id']))) $errorInvalidID=TRUE; $query_email_address = trim($_POST['query_email_address']); if(!isset($query_email_address) || zen_validate_email($query_email_address) == false) $errorInvalidEmail=TRUE; if(!$errorInvalidID && !$errorInvalidEmail) { $customer_info_query = "SELECT customers_email_address, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country FROM " . TABLE_ORDERS . " WHERE orders_id = :ordersID"; $customer_info_query = $db->bindVars($customer_info_query, ':ordersID', $_POST['order_id'], 'integer'); $customer_info = $db->Execute($customer_info_query); if (isset($query_email_address) && $customer_info->fields['customers_email_address'] != $query_email_address && $customer_info->fields['customers_email_address'] != $query_email_address . '.') $errorNoMatch=TRUE; else { $statuses_query = "SELECT os.orders_status_name, osh.date_added, osh.comments FROM " . TABLE_ORDERS_STATUS . " os, " . TABLE_ORDERS_STATUS_HISTORY . " osh WHERE osh.orders_id = :ordersID AND osh.orders_status_id = os.orders_status_id AND os.language_id = :languagesID AND osh.customer_notified >= 0 ORDER BY osh.date_added"; $statuses_query = $db->bindVars($statuses_query, ':ordersID', $_POST['order_id'], 'integer'); $statuses_query = $db->bindVars($statuses_query, ':languagesID', $_SESSION['languages_id'], 'integer'); $statuses = $db->Execute($statuses_query); while (!$statuses->EOF) { $statusArray[] = array('date_added'=>$statuses->fields['date_added'], 'orders_status_name'=>$statuses->fields['orders_status_name'], 'comments'=>$statuses->fields['comments']); $statuses->MoveNext(); } require(DIR_WS_CLASSES . 'order.php'); $order = new order($_POST['order_id']); } } require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php')); $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_ACCOUNT, '', 'SSL')); // This should be last line of the script: $zco_notifier->notify('NOTIFY_HEADER_END_ACCOUNT_HISTORY_INFO'); ?>


Not sure why a portion of the code is/was written the way it was; however, may I suggest trying the below code in place of what is there? Have to test it though also. A major difference is that I added execution/generation of an order, though it will get populated with what is in the shopping cart if some of the entered data is incorrect. I don't know the impact of the $order variable being populated like that, though the notifier(s) being reused like they are is not a great idea, especially because of the condition it creates.

<?php /** * * @package page * @copyright Copyright 2003-2005 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: J_Schilz for Integrated COWOA - 14 April 2007 edited by mc12345678 2024-03-30 */ // This should be first line of the script: $zco_notifier->notify('NOTIFY_HEADER_START_ACCOUNT_HISTORY_INFO'); $_SESSION['navigation']->set_snapshot(); // if logged in then go to account history if (!empty($_SESSION['customer_id'])) { zen_redirect(zen_href_link(FILENAME_ACCOUNT_HISTORY, 'action=returns_request', 'SSL')); } if (!isset($errorInvalidID)) { $errorInvalidID = false; } if (!isset($errorInvalidEmail)) { $errorInvalidEmail = false; } if (!isset($_POST['order_id']) || (isset($_POST['order_id']) && !is_numeric($_POST['order_id']))) { $errorInvalidID=TRUE; // Really should initiate this; however, it may already have a value. } $query_email_address = isset($_POST['query_email_address']) ? trim($_POST['query_email_address']) : null; if(!isset($query_email_address) || zen_validate_email($query_email_address) == false) { $errorInvalidEmail=TRUE; // Really should initiate this; however, it may already have a value. } require_once(DIR_WS_CLASSES . 'order.php'); if (!isset($statusArray) || !is_array($statusArray)) { $statusArray = array(); } // No issues identified, continue processing if(empty($errorInvalidID) && empty($errorInvalidEmail)) { $customer_info_query = "SELECT customers_email_address, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country FROM " . TABLE_ORDERS . " WHERE orders_id = :ordersID"; $customer_info_query = $db->bindVars($customer_info_query, ':ordersID', $_POST['order_id'], 'integer'); $customer_info = $db->Execute($customer_info_query, 1); if (isset($query_email_address) && $customer_info->fields['customers_email_address'] != $query_email_address && $customer_info->fields['customers_email_address'] != $query_email_address . '.') { $errorNoMatch=TRUE; // Really should initiate this; however, it may already have a value. $order = new order(); } else { $statuses_query = "SELECT os.orders_status_name, osh.date_added, osh.comments FROM " . TABLE_ORDERS_STATUS . " os INNER JOIN " . TABLE_ORDERS_STATUS_HISTORY . " osh ON (osh.orders_status_id = os.orders_status_id) WHERE osh.orders_id = :ordersID AND os.language_id = :languagesID AND osh.customer_notified >= 0 ORDER BY osh.date_added"; $statuses_query = $db->bindVars($statuses_query, ':ordersID', $_POST['order_id'], 'integer'); $statuses_query = $db->bindVars($statuses_query, ':languagesID', $_SESSION['languages_id'], 'integer'); $statuses = $db->Execute($statuses_query); while (!$statuses->EOF) { $statusArray[] = array( 'date_added'=>$statuses->fields['date_added'], 'orders_status_name'=>$statuses->fields['orders_status_name'], 'comments'=>$statuses->fields['comments'], ); $statuses->MoveNext(); } // require(DIR_WS_CLASSES . 'order.php'); $order = new order($_POST['order_id']); } } else { $order = new order(); } require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php')); $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_ACCOUNT, '', 'SSL')); // This should be last line of the script: $zco_notifier->notify('NOTIFY_HEADER_END_ACCOUNT_HISTORY_INFO'); ```

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

8 May 2024, 6:58 PM
#3559
pegasuspublishing avatar

pegasuspublishing

New Zenner

Join Date:
Dec 2019
Location:
Trenton, TX
Posts:
25
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

So does ZC2.0.0 have the stock by attribute built in, or is this still necessary? And will this work with 2.0.0?

9 May 2024, 1:50 AM
#3560
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

pegasuspublishing:

So does ZC2.0.0 have the stock by attribute built in, or is this still necessary? And will this work with 2.0.0?

Not built in still based on the idea that not everyone needs our wants attribute stock control. Also I haven't tried it yet, but don't (yet) know of anything preventing its operation.

Reporting of one's own experience would help others/all.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...