quick question about override files

Open to all! Ask other shopowners for help.
Post Reply
User avatar
Portman
Contributor
Posts: 158
Joined: Mon Mar 08, 2021 1:04 am
Phoenix Version: v1.0.8.20
Has thanked: 29 times
Been thanked: 4 times

quick question about override files

Post by Portman »

Hi,

I want to make changes to the following files and save them as overridden files;

includes/system/segments/checkout/update_stock.php
includes/system/segments/checkout/check_stock.php

where would I save the updated files - I have tried a number of options and none of them seem to work, or can I not override these files? maybe it is a job for hooks.


Join The Code Co-op to get access to your library in the Code Co-op Forum
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: quick question about override files

Post by heatherbell »

User avatar
Portman
Contributor
Posts: 158
Joined: Mon Mar 08, 2021 1:04 am
Phoenix Version: v1.0.8.20
Has thanked: 29 times
Been thanked: 4 times

Re: quick question about override files

Post by Portman »

thanks @heatherbell

So I have assumed from what you sent me that I really need to use hooks .. so I tried this instead of the modifications I made to;

includes/system/segments/checkout/update_stock.php

I am trying to set up a mod that allows me to count stock movements on some items only. I have added a switch to the products field that lets me choose if I count stock for each seperate product.

my original mod to update_stock.php was essentially a basic If statement that said...

IF the product stock needs to be counted then deduct sale from products_quantity - otherwise no deduction...

IF I make a hook that basically does the same thing then it does what the hook tells it to do, but it also runs through includes/system/segments/checkout/update_stock.php resulting in stock figures deducting twice for items that I want to count stock figures for (once from the hook and once from update_stock.php) and once for the items that I dont want to count (done in update_stock.php)...

Am I missing something? is there a way for me to essentially disable (or negate) includes/system/segments/checkout/update_stock.php from the hook?
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: quick question about override files

Post by Kofod95 »

Why not just add the stock back, for the items that doesn't need to be counted? Either that, or disable stock globaly in admin->configuration and only count stock with your new hook.

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
User avatar
Portman
Contributor
Posts: 158
Joined: Mon Mar 08, 2021 1:04 am
Phoenix Version: v1.0.8.20
Has thanked: 29 times
Been thanked: 4 times

Re: quick question about override files

Post by Portman »

thanks @Kofod95, for your lateral thinking, you are a genious!!
Denzel
Member
Posts: 87
Joined: Sat Oct 31, 2020 7:22 pm
Phoenix Version:
Has thanked: 9 times
Been thanked: 15 times

Re: quick question about override files

Post by Denzel »

I'll chime in here: Is it now possible to change admin/catalog/views/default.php without changing the code? I changed the order of the displayed articles (at that time in admin/categories.php) - i.e. the product query. Now I'm looking for a way to do this in catalog.php. Can this file be overwritten?

Regards,
Denzel
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: quick question about override files

Post by burt »

Admin doesn't have override architecture. It might come in the future.

Some pages can be changed in the way you describe (ie, change the SQL to make the list of items display in a different way), these pages are where the list of items is powered by the paginated_table component. EG: admin/products_expected.php

UNfortunately, catalog.php is not powered by the paginated_table.
Making more use of the paginated_table is something I've been looking at for some future time and space.
Denzel
Member
Posts: 87
Joined: Sat Oct 31, 2020 7:22 pm
Phoenix Version:
Has thanked: 9 times
Been thanked: 15 times

Re: quick question about override files

Post by Denzel »

Maybe something like this:

Code: Select all

            if (isset($_GET['search'])) {
              $products_query_raw = "SELECT p.*, pd.*, p2c.categories_id FROM products p, products_description pd, products_to_categories p2c WHERE p.products_id = pd.products_id AND pd.language_id = " . (int)$_SESSION['languages_id'] . " AND p.products_id = p2c.products_id AND ((pd.products_name LIKE '%" . $db->escape($search) . "%') || (p.products_model LIKE '%" . $db->escape($search) . "%') ||  (p.products_gtin LIKE '%" . $db->escape($search) . "%')) ORDER BY pd.products_name";
            } else {
              $products_query_raw = "SELECT p.*, pd.* FROM products p, products_description pd, products_to_categories p2c WHERE p.products_id = pd.products_id AND pd.language_id = " . (int)$_SESSION['languages_id'] . " AND p.products_id = p2c.products_id AND p2c.categories_id = " . (int)$current_category_id . " ORDER BY pd.products_name";
            }
	    $GLOBALS['admin_hooks']->cat('catalog', $products_query_raw);
            
	    $products_query = $db->query($products_query_raw);
				
            $products_count = mysqli_num_rows($products_query);

            while ($products = $products_query->fetch_assoc()) {
would open up the possibility to add sortable filters ;)
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: quick question about override files

Post by burt »

Yes, you can add in hooks where-ever you need.
I am not here to build for you.
I am here to build with you. Let's help each other.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply