Zen Cart Logo
Forums / Code Collaboration / Help with code piece

Help with code piece

Views: 10,395

Results 1 to 17 of 17
11 Jan 2017, 00:22
#1
yaseent avatar

yaseent

Zen Follower

Join Date:
Mar 2009
Posts:
169
Plugin Contributions:
1

Help with code piece

Hi,

in classes/order.php there is the following line of code:

$this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];

Can anyone advise me as to what this actually does? I understand it's part of stock decrement, but I don't see how this specific assignment is being used.

Thanks

11 Jan 2017, 05:07
#2
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Help with code piece

yaseent:

Hi,

in classes/order.php there is the following line of code:

$this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];

> 
> Can anyone advise me as to what this actually does? I understand it's part of stock decrement, but I don't see how this specific assignment is being used.
> 
> Thanks

The array key of 'stock_reduce' for the product identified as item $i is being set to the quantity of the product that is identified by the array key 'qty' for that same product.  Basically it is copying the value from one array key to another, more than likely to allow manipulation of one or the other or to at least pass the information along in other situations... Searching the store on 'stock_reduce' using the ZC 1.5.5d developer's toolkit found that array value only in that one line of the code for both admin and catalog and php files.
11 Jan 2017, 07:21
#3
yaseent avatar

yaseent

Zen Follower

Join Date:
Mar 2009
Posts:
169
Plugin Contributions:
1

Re: Help with code piece

Hi mc12345678,

Thanks for the reply.

Yep I understand what it's doing, I just don't see why it's doing it.

As you've pointed out, it doesn't seem this array variable assignment gets called anywhere else in Zen Cart.

Wonder if it's just for future use, or perhaps code initially intended to be used, but then didn't need to be.

11 Jan 2017, 11:02
#4
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Help with code piece

yaseent:

Hi mc12345678,

Thanks for the reply.

Yep I understand what it's doing, I just don't see why it's doing it.

As you've pointed out, it doesn't seem this array variable assignment gets called anywhere else in Zen Cart.

Wonder if it's just for future use, or perhaps code initially intended to be used, but then didn't need to be.
So, that array key was also found in older ZC versions at least verified in ZC 1.5.1 and likely older. See, that area of code identifies/manages whether the stock quantity should be adjusted or not. If it should be then the array key exists in the products variable. If it shouldn't then it doesn't exist. Later/within the loop there is at least one notifier that passes the $products[$i] array. Code that observes that array could check for the existence of that array key by: array_key_exists('reduce_stock', $products_array) where $products_array is the specific $products[$i] value.

So, you could call it a helper array key and supports expansion on ZC functionality. Now that said, i think that in a plugin I worked on that also reduces or checks for the need to reduce the quantity that I went the way that the original code checks for the need to reduce stock rather than checking for that key because I was concerned that someone may come along and say that the array key was not needed and have it removed from the core code... Others may have or may still use it and for that reason the developers choose to not be concerned with the few bytes added by that array key as compared to the extra code needed to recalculate that single need to reduce the stock or not.

So, one could ask, what is the concern about the setting of that array key? What impact do you perceive there being? Or is it simply a matter of curiosity? :)

11 Jan 2017, 11:54
#5
yaseent avatar

yaseent

Zen Follower

Join Date:
Mar 2009
Posts:
169
Plugin Contributions:
1

Re: Help with code piece

Hi,

thanks. Well yes lol, there's two reasons:

  1. The more I know, the better, so that I don't mess something up.

  2. The more specific reason:

I've cloned a generic payment module (moneyorder) and called it adminpurchase.

The purpose of this module is to allow the cart to act as a purchase order system. So I add product A, B, C and D to my cart, in varying quantities.

When the cart processes the order, INSTEAD of decreasing the product's quantities in the database by the amount ordered, it adds.

So if I ordered 2x Product A, and Product A is currently 10 in stock, it will make Product A's new quantity as 12, instead of 8.

So instead of logging into the backend, updating each product one by one, or using easy populate, I just place an order, and voila it updates my quantities all in one simple go. Also, this specific payment module is only available to an admin logged in with Encrypted Master Password. So anyway.

Here's the code:

// custom code for purchase order
if ($this->info['payment_module_code'] == "adminpurchase")
{
$stock_left = $stock_values->fields['products_quantity'] + $this->products[$i]['qty'];
}
else
{
            $stock_left = $stock_values->fields['products_quantity'] - $this->products[$i]['qty'];
}
            $this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
          } else {
            $stock_left = $stock_values->fields['products_quantity'];
          }

and here is the original code before my custom coding:

            $stock_left = $stock_values->fields['products_quantity'] - $this->products[$i]['qty'];
            $this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
          } else {
            $stock_left = $stock_values->fields['products_quantity'];
          }

As you can see, I've put the ```php
$this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];

11 Jan 2017, 14:30
#6
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Help with code piece

yaseent:

Hi,

thanks. Well yes lol, there's two reasons:

  1. The more I know, the better, so that I don't mess something up.

  2. The more specific reason:

I've cloned a generic payment module (moneyorder) and called it adminpurchase.

The purpose of this module is to allow the cart to act as a purchase order system. So I add product A, B, C and D to my cart, in varying quantities.

When the cart processes the order, INSTEAD of decreasing the product's quantities in the database by the amount ordered, it adds.

So if I ordered 2x Product A, and Product A is currently 10 in stock, it will make Product A's new quantity as 12, instead of 8.

So instead of logging into the backend, updating each product one by one, or using easy populate, I just place an order, and voila it updates my quantities all in one simple go. Also, this specific payment module is only available to an admin logged in with Encrypted Master Password. So anyway.

Here's the code:

// custom code for purchase order
if ($this->info['payment_module_code'] == "adminpurchase")
{
$stock_left = $stock_values->fields['products_quantity'] + $this->products[$i]['qty'];
}
else
{
$stock_left = $stock_values->fields['products_quantity'] - $this->products[$i]['qty'];
}
$this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
} else {
$stock_left = $stock_values->fields['products_quantity'];
}

> 
> and here is the original code before my custom coding:
> 
> ```php
            $stock_left = $stock_values->fields['products_quantity'] - $this->products[$i]['qty'];
            $this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
          } else {
            $stock_left = $stock_values->fields['products_quantity'];
          }

As you can see, I've put the ```php
$this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];


I would think that in order to maintain consistent functionality that the 'stock_reduce' value would reflect the "direction" of reduction, though, that also depends on how one has coded its use... 

For example, the following two code segments "act" differently:

if (array_key_exists('stock_reduce', $product_arrayI)) {
$remaining = $current - $product_array['qty'];
}


if (array_key_exists('stock_reduce', $product_arrayI)) {
$remaining = $current - $product_array['stock_reduce'];
}


I would say/suggest that the second method be used, but even with that in mind, I would say that the code that I have written would fail because the addition/modification above would not be reflected in the code I wrote unless it were manually added...  So, could your code be incorporated in a different way to provide a more robust final resolution without modifying the class? Probably, but that's also not where you're at at the moment.

I would say/suggest that
        $this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
would be better served to be within the applicable increase/decrease and that when increasing the quantity that the value be made negative (a negative reduction is an increase).

So if continuing down this path of modifying the file instead of using an observer I would suggest like this:

```php
// custom code for purchase order
if ($this->info['payment_module_code'] == "adminpurchase")
{
$stock_left = $stock_values->fields['products_quantity'] + $this->products[$i]['qty'];
            $this->products[$i]['stock_reduce'] = (-1.0) * $this->products[$i]['qty'];
}
else
{
            $stock_left = $stock_values->fields['products_quantity'] - $this->products[$i]['qty'];
            $this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
}

          } else {
            $stock_left = $stock_values->fields['products_quantity'];
          }

At least it can be logically applied/other code modified to account for the increase of quantity as compared to just the presence of the array key of 'stock_reduce' to then modify based on the 'qty' (first example above), but that's what happens when "planning" for a specific action versus possible actions.

11 Jan 2017, 15:16
#7
yaseent avatar

yaseent

Zen Follower

Join Date:
Mar 2009
Posts:
169
Plugin Contributions:
1

Re: Help with code piece

mc12345678:

So if continuing down this path of modifying the file instead of using an observer I would suggest like this:

// custom code for purchase order
if ($this->info['payment_module_code'] == "adminpurchase")
{
$stock_left = $stock_values->fields['products_quantity'] + $this->products[$i]['qty'];
$this->products[$i]['stock_reduce'] = (-1.0) * $this->products[$i]['qty'];
}
else
{
$stock_left = $stock_values->fields['products_quantity'] - $this->products[$i]['qty'];
$this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
}

      } else {
        $stock_left = $stock_values->fields['products_quantity'];
      }
> 
> At least it can be logically applied/other code modified to account for the increase of quantity as compared to just the presence of the array key of 'stock_reduce' to then modify based on the 'qty' (first example above), but that's what happens when "planning" for a specific action versus possible actions.

Hey man! This is an excellent suggestion to add consistency! Brilliant, I'll throw that in. At least should it be somehow utilized further down the line then at least the calculations remain intact.

Much appreciated :P
11 Jan 2017, 16:15
#8
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Help with code piece

yaseent:

Hey man! This is an excellent suggestion to add consistency! Brilliant, I'll throw that in. At least should it be somehow utilized further down the line then at least the calculations remain intact.

Much appreciated :P

It's always great to add functionality that is usable by many/more, but should also try to not disable other functionality/options.

That said, I've taken a quick look at the area of code in question, and at least for just this additional code, I can see a way that you can add your code without having to insert the code into the includes/classes/order.php file....
If you were to use this notifier:

      $this->notify('NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_INIT', array('i'=>$i), $this->products[$i], $i);

You could control the stock decrement/increase through this "purchase" method... And possibly use/need the following notifier:

      $this->notify('NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_END', $i);

The below code section opens with a for loop (included below for "presentation" but is not fully closed out), but it appears that the area of concern for your plugin/code is within the if statement of whether or not to decrement stock so there already is a problem with your additions if STOCK_LIMITED is not equal to 'true':

    for ($i=0, $n=sizeof($this->products); $i<$n; $i++) {
      $custom_insertable_text = '';

      $this->doStockDecrement = (STOCK_LIMITED == 'true');
      $this->notify('NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_INIT', array('i'=>$i), $this->products[$i], $i);
      // Stock Update - Joao Correia
      if ($this->doStockDecrement) { // This can be adjusted to false within the observer if previously true, but understand that if previously false that none of your current code will execute.
        if (DOWNLOAD_ENABLED == 'true') {
          $stock_query_raw = "select p.products_quantity, pad.products_attributes_filename, p.product_is_always_free_shipping
                              from " . TABLE_PRODUCTS . " p
                              left join " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                               on p.products_id=pa.products_id
                              left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                               on pa.products_attributes_id=pad.products_attributes_id
                              WHERE p.products_id = '" . zen_get_prid($this->products[$i]['id']) . "'";

          // Will work with only one option for downloadable products
          // otherwise, we have to build the query dynamically with a loop
          $products_attributes = $this->products[$i]['attributes'];
          if (is_array($products_attributes)) {
            $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
          }
          $stock_values = $db->Execute($stock_query_raw, false, false, 0, true);
        } else {
          $stock_values = $db->Execute("select * from " . TABLE_PRODUCTS . " where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'", false, false, 0, true);
        }

        $this->notify('NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_BEGIN', $i, $stock_values);

        if ($stock_values->RecordCount() > 0) {
          // do not decrement quantities if products_attributes_filename exists
          if ((DOWNLOAD_ENABLED != 'true') || $stock_values->fields['product_is_always_free_shipping'] == 2 || (!$stock_values->fields['products_attributes_filename']) ) {
            $stock_left = $stock_values->fields['products_quantity'] - $this->products[$i]['qty'];
            $this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
          } else {
            $stock_left = $stock_values->fields['products_quantity'];
          }

          //            $this->products[$i]['stock_value'] = $stock_values->fields['products_quantity'];

          $db->Execute("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'");
          //        if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
          if ($stock_left <= 0) {
            // only set status to off when not displaying sold out
            if (SHOW_PRODUCTS_SOLD_OUT == '0') {
              $db->Execute("update " . TABLE_PRODUCTS . " set products_status = 0 where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'");
            }
          }

          // for low stock email
          if ( $stock_left <= STOCK_REORDER_LEVEL ) {
            // WebMakers.com Added: add to low stock email
            $this->email_low_stock .=  'ID# ' . zen_get_prid($this->products[$i]['id']) . "\t\t" . $this->products[$i]['model'] . "\t\t" . $this->products[$i]['name'] . "\t\t" . ' Qty Left: ' . $stock_left . "\n";
          }
        }
      } // This is the end of the "if ($this->doStockDecrement)" section.

By using an observer off of the notifier: NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_INIT, you can check to see if the payment module being used is your 'adminpurchase' module, if it is, then you can set the calling classes doStockDecrement to false (could check first if it is not equal to false and then set to false if it is, otherwise leave it alone with whatever value it is set to. This would "affect" how someone else's code works, but if you want to not do so there are a few things that could be done which would include capturing the necessary data through this observer event, then listen to the follow on observer event and make modifications that are deemed necessary to the data and both/all plugins could live together copacetically.)

Then, if the payment module is your 'adminpurchase' module, you can take just the action you need to take against the data that is provided, and when the observer completes the expectation is that the builtin code will not do any builtin decrement code and your results can be further fed along with the change(s) made to them as you have done in the observer.

So for ZC 1.5.3 and above an observer would be stored in includes/modules/classes/observers:
filename something similar to: auto.admin_purchase.php (see includes/init_includes/init_observers.php for "instruction" and naming)

<?php

class zcObserverAdminPurchase extends base {
  function __construct() {
    $attachMe = array();
    $attachMe[] = 'NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_INIT';

    $this->attach($this, $attachMe);
  }

  function updateNotifyOrderProcessingStockDecrementInit(&$callingClass, $notifier, $varArray, &$products_i, &$i_passed) {
    if ($callingClass->info['payment_module_code'] == "adminpurchase") {
       if ($callingClass->doStockDecrement != false) { // Check to see if the current value/status will allow processing the stock decrement code, if so, disable it.
         $callingClass->doStockDecrement = false;
       }
        if (DOWNLOAD_ENABLED == 'true') {
          $stock_query_raw = "select p.products_quantity, pad.products_attributes_filename, p.product_is_always_free_shipping
                              from " . TABLE_PRODUCTS . " p
                              left join " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                               on p.products_id=pa.products_id
                              left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                               on pa.products_attributes_id=pad.products_attributes_id
                              WHERE p.products_id = '" . zen_get_prid($products_i['id']) . "'";

          // Will work with only one option for downloadable products
          // otherwise, we have to build the query dynamically with a loop
          $products_attributes = $products_i['attributes'];
          if (is_array($products_attributes)) {
            $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
          }
          $stock_values = $db->Execute($stock_query_raw, false, false, 0, true);
        } else {
          $stock_values = $db->Execute("select * from " . TABLE_PRODUCTS . " where products_id = '" . zen_get_prid($products_i['id']) . "'", false, false, 0, true);
        }

        $this->notify('NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_BEGIN', $i, $stock_values);

        if ($stock_values->RecordCount() > 0) {
          // do not decrement quantities if products_attributes_filename exists
          if ((DOWNLOAD_ENABLED != 'true') || $stock_values->fields['product_is_always_free_shipping'] == 2 || (!$stock_values->fields['products_attributes_filename']) ) {
            $stock_left = $stock_values->fields['products_quantity'] + $products_i['qty'];
            $products_i['stock_reduce'] = (-1.0) * $products_i['qty'];
          } else {
            $stock_left = $stock_values->fields['products_quantity'];
          }

          //            $products_i['stock_value'] = $stock_values->fields['products_quantity'];

          $db->Execute("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . zen_get_prid($products_i['id']) . "'");

          // Section about setting the product to disabled is unnecessary generally speaking though it may be desirable to reenable product that are now
          //  in stock that previously weren't, though the problem with that "thought" is if they were not in stock (disabled) then how could they have been
          //  added to the cart in order to make this purchase so again, back to don't need the disable/enable condition of the product because this process
          //  without additional code work would not permit the purchase of out-of-stock product in order to reup the quantity.
          // Can leave in the low stock email if you wish to be notified (again) that the stock quantity now still remains below the reorder level...
          // for low stock email
          if ( $stock_left <= STOCK_REORDER_LEVEL ) {
            // WebMakers.com Added: add to low stock email
            $this->email_low_stock .=  'ID# ' . zen_get_prid($products_i['id']) . "\t\t" . $products_i['model'] . "\t\t" . $products_i['name'] . "\t\t" . ' Qty Left: ' . $stock_left . "\n";
          }

        }       
    }
  }
}

Now, the flip side to all of this? Could create (or support creation) of a "filter" for EasyPopulate that would allow you to enter just the stock quantity to be increased by (not the final value, but the change in quantity) and upload the file... No admin login as a user, no making sure that a product is first active, etc... Just another thought (which is something I'm looking to do for EasyPopulate V4)...

12 Jan 2017, 00:09
#9
yaseent avatar

yaseent

Zen Follower

Join Date:
Mar 2009
Posts:
169
Plugin Contributions:
1

Re: Help with code piece

:lookaroun .... That's all a bit too higher grade for me...

It's funny you should mention that.

I've added some functionality to my Admin Categories section to do exactly that:

Attachment 16885

12 Jan 2017, 01:08
#10
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Help with code piece

Yeah, but that still requires being in the admin and keeping the session active as compared to populating something "off-line" and hitting go... sure, maybe you've implemented a sort of session refresh by key action, but if you walk away, take a phone call, etc... also "sorting" is a bit more difficult from within there generally. All that said... still good to have a tool that fits the needs and appears that's something you have already.

As to the above code, well, that just takes the snippet you've added into the includes/classes/order.php file and pulls it out so that you don't have to keep modifying the file on each upgrade. Makes at least that portion of your overall "plugin" actually a plugin. :) doesn't overwrite or modify core code. :)

12 Jan 2017, 01:20
#11
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Help with code piece

Had a bit of a double-take on this thread. At first glance I thought you were asking for help with your cod piece... (Search Google images for cod piece). :D

12 Jan 2017, 03:45
#12
yaseent avatar

yaseent

Zen Follower

Join Date:
Mar 2009
Posts:
169
Plugin Contributions:
1

Re: Help with code piece

:laugh:

Now that you mention it...I do need some help with my cod piece...

It's got a stack overflow error :ohmy:

12 Jan 2017, 03:50
#13
yaseent avatar

yaseent

Zen Follower

Join Date:
Mar 2009
Posts:
169
Plugin Contributions:
1

Re: Help with code piece

I haven't been completely honest about my intentions though.

You see, I use QuickBooks Online for my accounting.

The actual reason I needed to use purchase orders from the front-end was to calculate average costing of my goods.

Most unfortunately, QuickBooks Online uses FIFO, and as such, you cannot get an average cost.

But, given that this sufffices for me to adjust stock levels when new stock has come in, and also calculates the average cost for me...kind of 2 birds with one stone situation.

That being said, I've also got some custom coding that allows the EMP logged in admin to adjust the prices in the cart.

Uses a simple input box field, and each modification of price is separated by commas.

Unfortunately my coding is obviously very amateurish, and so are my techniques.

If it were not for that, I'd have packaged it into a module for the community.

The only hurdle going forward is to now find a way to allow an EMP admin to checkout with out of stock items. Which shouldn't be too much trouble.

12 Jan 2017, 12:03
#14
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Help with code piece

There is sort of a built in way to at least see an out-of-stock item, then after that it's a matter of allowing that individual to do atypical action of adding an out-of-stock product to the cart. :)

BTW, regarding quickbooks, can't recall if you've posted to related threads, but I know there are those out there that would like to be able to link ZC with their quickbooks. Not sure if your current method of doing so has been discussed there or not. If it hasn't, there are plenty that would appreciate your input.

Further on that, thank you for providing further business reason for doing what you are doing. Provides a better understanding of the associated "constraints".

And on the discussion of clarity, to confirm, the stack overflow error had nothing to do with the computer code, correct? :P

12 Jan 2017, 13:00
#15
yaseent avatar

yaseent

Zen Follower

Join Date:
Mar 2009
Posts:
169
Plugin Contributions:
1

Re: Help with code piece

:laugh: Of course it did....metaphysically speaking.

I haven't really posted much about Quickbooks Online. I've been studying their API for several months along with a few other accounting systems...But i settled on QuickBooks Online because, as a cloud-based solution, it is constantly evolving, and their API is unprecedented in terms of access. It's even got a webhooks section, allows you to set up rules that push content from QuickBooks to your store if you want that to happen.

Unfortunately, my coding skills are very limited. I've had a look at a "library" created by Consolibyte aka Keith Palmer who I think specialized in QuickBooks Online integrations. He's got a Github repo with free PHP libraries he's coded. But this would be useful to someone with a better understanding of OAuth and then API development. Also, I think Keith offers his services commercially, and from what I've seen on StackOverflow posts, he seems very forthcoming and hands on.

At the moment, I'll only be using Zen Cart to constantly update my average costings, and using this purchase order method to do that.

With QuickBooks online, I'll be re-entering orders manually, but, in the past few weeks I stumbled across a new SaaS called Zapier.com

By far one of the most well-integrated, and efficient uses of SaaS I've ever come across.

I signed up for a trial account, and decided to do this as a test case:

  1. Zapier.com connects to my GMail account, and checks it every 15 minutes. If there is a new email with the label, Bank Statement, Zapier.com goes to work. It then has a function that allows you to dig further into this email, and find a PDF attachment.

  2. Then you can add another step. So in Step 2, I tell it to print out the PDF statement, via my Google Cloud Connected printer.

All of the calls, and all the technical issues, get sorted out by them. Now my bank statements, landline statements, and even certain distributor statements, all print out, by themselves, without me. And upon testing the service, I found that it is so far 100% reliable. Not one missed statement. Great time to be living.

Blah di blah...Zapier.com offers support for QuickBooks Online as well. Zapier.com can add an Estimate, an Invoice, a Sales Receipt, even a New Customer.

And the big number is MySQL integration. It can connect to MySQL, check for new rows, and then it's gone line item support for integration with QuickBooks Online.

Once I'm done with a few small things on Zen Cart, I'm going to focus my efforts on Zapier.com and integrating my Zen Cart's MySQL with QuickBooks Online via Zapier.com. I have high hopes.

But I have no interest in going with a custom SaaS solution, because it's way too expensive, and with Zapier.com, you pay your 15 dollars a month, and you've got support from a reputable company who makes it their business to continue keeping you as a client.

I suggest anyone reading this post to grab a quick look at Zapier.com. Scroll down to the bottom, click on "App Directory". Search for Gmail, open in new Tab, and search for MySQL, open in new Tab, and search for QuickBooks Online, and open.

Just take a look at the Triggers, Search and Action capabilities of their integrations with the various services I mentioned, and you will get a striking idea of the possibilities their platform is capable of. It's a real game-changer IMO.

If I ever do come right with Zapier + QuickBooks Online + Zen Cart - I will definitely be posting my solution here. The most intriguing thing about this kind of solution, is that Zapier.com would need limited read-only access to your MySQL database. It can't touch core code, it can't modify your database, and most importantly, it doesn't need to.

18 Feb 2018, 02:15
#16
wolfderby avatar

wolfderby

Zen Follower

Join Date:
Dec 2008
Location:
Pittsburgh, PA
Posts:
241
Plugin Contributions:
0

Re: Help with code piece

yaseent:

:lookaroun .... That's all a bit too higher grade for me...

It's funny you should mention that.

I've added some functionality to my Admin Categories section to do exactly that:

Attachment 16885

Share this code?

18 Feb 2018, 02:44
#17
yaseent avatar

yaseent

Zen Follower

Join Date:
Mar 2009
Posts:
169
Plugin Contributions:
1

Re: Help with code piece

I didn't document the code changes.

Here are three files I believe control all the functions.

admin/categories.php

admin/includes/modules/category_product_listing.php

admin/includes/functions/extra_functions/update_product_quantity.php

I've attached all three files for you, backup yours, then upload (test environment) to their correct folders as mentioned above.

Give it a whirl and lemme know how it pans out.

Attachment #17699