Author Topic: Custom addtocart function query?  (Read 189 times)

Martyn Batten

  • Jr. Member
  • **
  • Posts: 150
Custom addtocart function query?
« on: August 29, 2019, 17:20:21 pm »
Hi,

I want to be able to create a notice on the product details page when the add to cart button has been clicked.

  • I would like it to start with "add to cart" when they first look at the product - which is obviously already a function
  • when they click the "add to cart" i would like it to read "adding" - I am sure this can be achieved with css or javascript action onclick or something similar
  • The tricky part is then adding a notice under the "add to cart" button saying "1 item in your cart" or "you have 1 of these in your cart

My question is, what php code/array/function would I need to use to be able to get the information to display in the product details page?
Is it a cart session/cookie or php array that I need to work with, this is really an area I don't touch much!

I really do not know where to begin and some pointers would be welcome, I don't need this written in full for me, just a starting point.

Cheers
Martyn

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10358
  • VirtueMart Version: 3+
Re: Custom addtocart function query?
« Reply #1 on: August 29, 2019, 20:36:31 pm »
assets/vmprices.js

This
Virtuemart.addtocart = function (e)
then
Virtuemart.productUpdate = function()


are you NOT using the minicart module? or the pop up?


J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

Martyn Batten

  • Jr. Member
  • **
  • Posts: 150
Re: Custom addtocart function query?
« Reply #2 on: August 29, 2019, 20:47:01 pm »
Sorry I don't think I made myself clear.

I want the number of that product only to be displayed under the add to cart button like this website...

https://www.cartridgesave.co.uk/ink-cartridges/Brother/DCP-197C.html

click add to basket and see what happens that's exactly what I am after

I just need to know what variable/array/session or other code I need to work from to make this possible. Thanks in advance.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3978
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Custom addtocart function query?
« Reply #3 on: August 29, 2019, 21:26:53 pm »
Session ?
You can override core javascript in your template to replace the popup and update only the button.
To do this check
assets/vmprices.js

This
Virtuemart.addtocart = function (e)
then
Virtuemart.productUpdate = function()


are you NOT using the minicart module? or the pop up?




Martyn Batten

  • Jr. Member
  • **
  • Posts: 150
Re: Custom addtocart function query?
« Reply #4 on: August 30, 2019, 08:55:09 am »
Thanks, Javascript is my start them in that asset file

By session I was referring to cookie sessions, as I said I had no idea where to start.