Making Changes to admin/currencies.php

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

Making Changes to admin/currencies.php

Post by Portman »

Hi again,
I want to make changes to the admin/currencies.php file.

without going into the reasons why (it will take too long to explain)

I have added a collumn to the currencies table and want to add some info into this from the admin/currencies.php page and also a modified currencies update module that I am creating.

I have looked round a bit and played with a few things, but I am assuming that if I want to make changes to this file I will need to make changes to the core code - from what I can tell there are no hooks here and I can not override this file...

am I correct in this assumption?


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
Kofod95
Senior Contributor
Posts: 749
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Making Changes to admin/currencies.php

Post by Kofod95 »

Have a look at this line: https://github.com/CE-PhoenixCart/Phoen ... es.php#L15

And look at the link I have given previously - especially the hook in admin/manufacturers.php

That should give you something to work with ;)

//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
burt
Core Team
Posts: 4561
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 422 times

Re: Making Changes to admin/currencies.php

Post by burt »

Portman wrote: Sat Oct 21, 2023 5:11 am am I correct in this assumption?
No.

Have a read of;

viewtopic.php?p=13652#p13652

This software is very flexible. Obviously different admin page, but the idea is the same.
Omar_one
Senior Contributor
Posts: 679
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: Making Changes to admin/currencies.php

Post by Omar_one »

Check this example viewtopic.php?p=10950#p10950
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: Making Changes to admin/currencies.php

Post by Portman »

Ok, obviously I am very thick... I am really struggling to get my head around hooks...

Could someone help me with a bit of a walk through if it not too much hassle...

In Admin Currencies, I have only changed a small section of code;
Line 73
from;

Code: Select all

          return number_format($row['value'], 8); 
to;

Code: Select all

          return number_format($row['inv_value'], 8); 
I want the value in currencies->value to remain at 1 for all currencies so that there are no changes to the actual value of the product regardless of the currency the user is using (see Background info below for explination) - I assume this does not change here unless I edit it manually with the edit feature otherwise, I can control this with the new update currencies module I created.

How do I create a hook to do this and where do I save it?

I have also needed to make minor changes to the following files...

admin/includes/actions/currencies/save.php
admin/includes/actions/currencies/infoboxes/default.php
admin/includes/actions/currencies/infoboxes/edit.php

I assume I have to create override files for these rather than hooks, is that correct? I am also still not sure where I should save the override files for these.

I hope this is not too much to ask but I feel like if i get a walk through on something I am actually trying to change then it will help it sink in a lot more.

Your help is appreciated.


Background info: I have groups set up using wholesalePro by @raiwa and have forced currencies by group I want my international wholesale customers to purchase items in their own currency as a static price rather than based on what the AUD is doing ... the inv_value value will be used later on for sales reports . Also, if they want to pay via Credit card (vs paypal) then their purchase will need to be converted to AUD before it is put through and I intend for the inv_value to be used at this point too. Hope that makes sense.
User avatar
burt
Core Team
Posts: 4561
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 422 times

Re: Making Changes to admin/currencies.php

Post by burt »

I'll throw another few jigsaw pieces onto the floor...

All (admin side) actions run through this file; admin/includes/segments/process_action.php

This file has 3 Hook calls in it;

Code: Select all

L15: $admin_hooks->cat('preAction');
L20: $admin_hooks->cat($hook_action);
L27: $admin_hooks->cat('postAction');  
Therefore, all actions can utilise these three hooks.

It might be the case, that none of those hooks are useable for a shopowners needs, in which case, some hardcoding may be suitable, or replacement of files (there is no override in the admin area). I think in 95% (or more) of use cases, those three hooks are useable and useful.

The middle one [ $hook_action ] is a little more complicated as it is named depending on the action being used. For example, if you edit an existing currency, then press SAVE...the used action is called "saveAction", which would look like this in a hook;

Code: Select all

public function listen_saveAction() {
 // logic
}
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: Making Changes to admin/currencies.php

Post by Portman »

ok, thanks for your help everyone... I've had a bit of a play around with this with no luck... I will stick with the core code modifications for now and have another play around with it all once I have my site up and running and have more time on my hands.


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