News:

Looking for documentation? Take a look on our wiki

Main Menu

how to override (or complement) VM core functions?

Started by aftertaf, August 03, 2017, 13:01:04 PM

Previous topic - Next topic

aftertaf

Hi,

When we sell some products per cm (fabrics), i want to display the sale price per metre.
The only way I found to do this is to override the products/category views and when CreatePriceDiv() is called, substitute the function call made in my override with a new function, CreatePriceDivPerMetre().
I just copied the function, changed the name and added "product_price = product_price * 100;"

Another 'hack' to make a custom field mandatory (for sending a gift certificate to a mail address) is done in \plugins\vmcustom\textinput\textinput.php

Obviously I lose them on every new VM upgrade...

Is there a different way to add these functions to my overrides and not have to worry about the core files ?

Ghost

Another 'hack' to make a custom field mandatory (for sending a gift certificate to a mail address) is done in \plugins\vmcustom\textinput\textinput.phpFor this you can create a plugin based on textinput plugin and make your changes in the new plugin.

aftertaf

hi, at the risk of sounding stupid, how would I do that? basic copy/paste of the source folder and renaming ?

Ghost

Pretty much yes. Rename everything with textinput (including code and filenames) to something else. E.g. Textinput.php becomes mytextinput.php,  class plgVmCustomTextinput becomes plgVmCustomMytextinput and so on.

aftertaf

ok. done that.. Renamed all "textinput" to "textinputso"
Ran the discovery procedure to install the new plugin as a plugin, and enabled it.
Changed the custom field to be textinputso and not textinput.

But it doesn't make the addition of a mail address mandatory like the hacked original textinput...

oh well...

Not  a major thing, its more the other addition that would be helpful to not lose at all during upgrades : CreatePriceDivPerMetre() in helpers\currencydisplay.php

Milbo

price per meter is the unitprice. it even calculates the price per meter for you.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/