Zen Cart Logo
Forums / General Questions / When I want to customize code, where do I put it?

When I want to customize code, where do I put it?

Views: 268

Results 1 to 3 of 3
1 Jan 2019, 7:49 PM
#1
sammirah avatar

sammirah

Zen Follower

Join Date:
Apr 2012
Location:
Los Angeles, CA
Posts:
185
Plugin Contributions:
2

When I want to customize code, where do I put it?

I have been meaning to ask this for some time, I know we are encouraged to use software such as WinMerge when comparing files to be merged, but what if the files just do not merge well...for instance the update_product.php in ZC 1.5.6 loses major components when you upload or try to merge it with the same file from AutoTweet 2.5

Is it ok to take the functional parts of the AutoTweet copy of update_product.php and just past them at the bottom of the original file (similar to adding html code to the body section - while not disturbing the original or previous additions) or do they absolutely have to be in a specific line or space in the file to work?

Like in math, you work on the stuff in the parenthesis 1st, then divide or multiply before addition and subtraction. Is there a protocol for this?

1 Jan 2019, 8:24 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: When I want to customize code, where do I put it?

Generally speaking, when software modifies an existing ZC file, it does so from some historically known file version. In essence it takes a known good file and adds to it what is needed to operate.

So if it works just fine in ZC 1.5.5, then compare the default version of ZC 1.5.5's file with the new file to identify what was changed to make it work. Then look at how the new version's file is similar/different and determine where to incorporate the necessary information. It may be just adding something to the end, the beginning, or some other file.

The ideal goal is that no ZC provided file should need modification to support additional functionality. Changes should only be needed to address personal preferences of layout (template related).

Now, I say that and there has been some development to make it "easier" to load additional javascript (makes it possible to modify the html of the page without modifying other display files; however, the method provided requires modification of that file in order to load additional javascript at times, so... kind of a catch-22. Want to add code without modifying core or provided files, but may have to modify a core/provided file to do that... I'm still meddling with some things where I might be wrong about needing to modify a file, but...)

2 Jan 2019, 5:13 PM
#3
lindasdd avatar

lindasdd

Zen Follower

Join Date:
Jun 2007
Posts:
474
Plugin Contributions:
0

Re: When I want to customize code, where do I put it?

It depends on the code and the file.

For some stuff it goes on the page where you want it to appear. For other stuff it has to go at the beginning or end.

For what you are describing, it most likely needs to be dropped in the file where you want it to appear. You just have to make sure you account for the ordering of elements - similar to what you described with math.

So for instance, maybe there is a section called/displaying as "Section A". Find that section in the file, find where it closes itself, and put your new code underneath it.

If you provide more specifics we can walk through it more with you.