Zen Cart Logo
Forums / Contribution-Writing Guidelines / Take out of stock from catalog (front-end) *inventory taking cheats* :D

Take out of stock from catalog (front-end) *inventory taking cheats* :D

Views: 9,528

Results 1 to 9 of 9
24 Jan 2017, 11:42 PM
#1
wolfderby avatar

wolfderby

Zen Follower

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

Take out of stock from catalog (front-end) *inventory taking cheats* :D

So back when I had 1.3.9 I had a bit of code in includes/templates/mytemplate/templates/tpl_product_info_display.php

that looked like this:

<?php
if($_SESSION['customer_id'] == 2) {
?>
<li><a href="/admin/product.php?cPath=<?= $_GET['cPath']; ?>&product_type=1&pID=<?= $_GET['products_id']; ?>&action=new_product&search=<?= $_GET['products_id']; ?>" target="_top" accesskey="i">Edit Product##########____(Alt+i)</a></li>

<li><a href="/admin/categories.php?&search=<?= $_GET['products_id']; ?>" target="_blank" accesskey="a">Search Admin##########__(Alt+a)</a></li>

<li><a href="/admin/categories.php?action=setflag&pID=<?= $_GET['products_id']; ?>&cPath=<?= $_GET['cPath']; ?>&page=1" target="_blank" accesskey="o">Take Out of Stock##########(Alt+o)</a></li>

<?php
}
?>

which basically gave my customer_id "2" account a few nice admin links that I could use to help w/ inventory from the front end... but now my "Take Out of Stock" link doesn't work, I'm thinking because the added security of the 1.5.x admin...

any suggestions on getting this working? and/or modules that already do this? It's pretty handy.

25 Jan 2017, 12:05 AM
#2
wolfderby avatar

wolfderby

Zen Follower

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

Re: Take out of stock from catalog (front-end) *inventory taking cheats* :D

created a work around

admin/categories.php

      case 'setgetflag':

      if ( isset($_GET['flag']) && ($_GET['flag'] == '0') || ($_GET['flag'] == '1') ) {
        if (isset($_GET['pID'])) {
          zen_set_product_status($_GET['pID'], $_GET['flag']);
        }
      }

      zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&pID=' . $_GET['pID'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '')));
      break;

and change the link text to...

<li><a href="/admin/categories.php?action=setgetflag&flag=0&pID=<?= $_GET['products_id']; ?>&cPath=<?= $_GET['cPath']; ?>&page=1" target="_blank" accesskey="o">Take Out of Stock##########(Alt+o)</a></li>
25 Jan 2017, 1:17 AM
#3
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Take out of stock from catalog (front-end) *inventory taking cheats* :D

Is the goal of "taking out of stock" to keep the product visible but make it appear to have zero quantity? Such that it shows "out-of-stock" on the front end?

If it is not that, and instead to "hide" the product from the front end, clicking on the green/red button within the category listing of the admin performs that action already...

As to the issue with the front end approach, yeah, security is a reason why you don't get to where you want, but it could still be merged in one way or another.

26 Jan 2017, 5:25 AM
#4
wolfderby avatar

wolfderby

Zen Follower

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

Re: Take out of stock from catalog (front-end) *inventory taking cheats* :D

mc12345678:

Is the goal of "taking out of stock" to keep the product visible but make it appear to have zero quantity? Such that it shows "out-of-stock" on the front end?

If it is not that, and instead to "hide" the product from the front end, clicking on the green/red button within the category listing of the admin performs that action already...

As to the issue with the front end approach, yeah, security is a reason why you don't get to where you want, but it could still be merged in one way or another.

I suppose the goal of "taking out of stock" would be simply hide it from the catalog so that a customer can't buy it. I somewhat use my zen-cart as an inventory management system, so I try to never just change quantities w/o some accountability.

I have a brick and mortar store so I use the visible products in the catalog "status = 1" as "in-stock". It's easiest for me/us to take inventory by changing the status, and then eventually doing something w/ any extra quantities like "buying" them w/ a shrinkage account.

13 Mar 2017, 8:36 PM
#5
wolfderby avatar

wolfderby

Zen Follower

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

Re: Take out of stock from catalog (front-end) *inventory taking cheats* :D

so after I updated to 1.5.5e I can't seem to get these links to work w/o having to log into the admin each time it's clicked. I tried reverted to the old 1.5.5d .htaccess but that didn't seem to fix it. Not sure what changed... :/

13 Mar 2017, 8:52 PM
#6
wolfderby avatar

wolfderby

Zen Follower

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

Re: Take out of stock from catalog (front-end) *inventory taking cheats* :D

I also upgraded from php 5.3 to php 5.4... not sure if this would have done anything to cause this. I ran into problems w/ 1.5.5e and php 5.3 so I went to the latest my hosting offers, which is php 5.4

16 Mar 2017, 4:08 PM
#7
wolfderby avatar

wolfderby

Zen Follower

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

Re: Take out of stock from catalog (front-end) *inventory taking cheats* :D

Does anyone know if this is not working because I'm not using the zen_href_link function? If I were to use that function I'm not sure how to reference the unique admin folder name. I'm assuming defining it as a constant would not be advised.

I noticed that there's mention of a zen_admin_href_link in a few Github links google turned up, but it doesn't appear that was ever implemented at least as of 1.5.5e, because developer's tool kit doesn't turn it up and it's not in html_output.php that I noticed.

Also would it even be possible link to the admin given current security measures (that are over my head programming wise) to create this link? As it is, it currently works, I just have to log-in a second time. A link I had created from the admin to another admin page had this problem until I re-created the link w/ zen_href_link.

23 Mar 2017, 1:58 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,080
Plugin Contributions:
56

Re: Take out of stock from catalog (front-end) *inventory taking cheats* :D

There were security-related changes in the ZC 1.3.9 to 1.5.0 transition that preclude the use of an admin-level script (e.g. customers.php) outside of a logged-in admin environment.

3 Apr 2017, 7:31 PM
#9
wolfderby avatar

wolfderby

Zen Follower

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

Re: Take out of stock from catalog (front-end) *inventory taking cheats* :D

lat9:

There were security-related changes in the ZC 1.3.9 to 1.5.0 transition that preclude the use of an admin-level script (e.g. customers.php) outside of a logged-in admin environment.

Any idea how I'd go about figuring out why it's requesting the second admin log-in? For example, if I've already logged in as an admin user (before the session time's out...) why would it ask for another log in? Is there a way I can get it to echo the reason for the admin log-in ?