Author Topic: how to override (or complement) VM core functions?  (Read 300 times)

aftertaf

  • Jr. Member
  • **
  • Posts: 156
    • sO couture
  • VirtueMart Version: 3.2.4
how to override (or complement) VM core functions?
« on: August 03, 2017, 13:01:04 pm »
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 ?
Webmaster for my wife (link in my profile ;)
Extensions / plugins : POSForWebshops, TemplatecreatorCK ,MaximenuCK, and PageBuilderCK, VM BatchEdit Pro, VM CustomFilters Pro, Awocoupon Pro, slogin, supersaas,  among other things...
Joomla! 3.8.2//VM 3.2.4//PHP7.0.18 & mariadb 10.1.22 on Debian
big up to notepad++!!!!

Ghost

  • Jr. Member
  • **
  • Posts: 377
Re: how to override (or complement) VM core functions?
« Reply #1 on: August 03, 2017, 14:46:21 pm »
Code: [Select]
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

  • Jr. Member
  • **
  • Posts: 156
    • sO couture
  • VirtueMart Version: 3.2.4
Re: how to override (or complement) VM core functions?
« Reply #2 on: August 03, 2017, 16:06:23 pm »
hi, at the risk of sounding stupid, how would I do that? basic copy/paste of the source folder and renaming ?
Webmaster for my wife (link in my profile ;)
Extensions / plugins : POSForWebshops, TemplatecreatorCK ,MaximenuCK, and PageBuilderCK, VM BatchEdit Pro, VM CustomFilters Pro, Awocoupon Pro, slogin, supersaas,  among other things...
Joomla! 3.8.2//VM 3.2.4//PHP7.0.18 & mariadb 10.1.22 on Debian
big up to notepad++!!!!

Ghost

  • Jr. Member
  • **
  • Posts: 377
Re: how to override (or complement) VM core functions?
« Reply #3 on: August 03, 2017, 20:15:47 pm »
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

  • Jr. Member
  • **
  • Posts: 156
    • sO couture
  • VirtueMart Version: 3.2.4
Re: how to override (or complement) VM core functions?
« Reply #4 on: August 04, 2017, 13:30:59 pm »
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
Webmaster for my wife (link in my profile ;)
Extensions / plugins : POSForWebshops, TemplatecreatorCK ,MaximenuCK, and PageBuilderCK, VM BatchEdit Pro, VM CustomFilters Pro, Awocoupon Pro, slogin, supersaas,  among other things...
Joomla! 3.8.2//VM 3.2.4//PHP7.0.18 & mariadb 10.1.22 on Debian
big up to notepad++!!!!

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9415
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: how to override (or complement) VM core functions?
« Reply #5 on: August 05, 2017, 20:29:06 pm »
price per meter is the unitprice. it even calculates the price per meter for you.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/