Creating my own plugin for Newsletter signup at checkout, need help!

Started by Genius WebDesign, August 11, 2014, 00:30:41 AM

Previous topic - Next topic

Genius WebDesign

hello,

I want to make my own plugin for Virtuemart so that customers will automatically subscribe to AcyMailing newsletter after successful order, if they click a checkbox on check-out page.

So here are the requirements:

1. Single checkbox on checkout page "Do you want to subscribe to our newsletter?"
2. The customers checks the checkbox.
3. The customer completes order.
4. Now the customer must be subscribed to newsletter with email from order.

So, as far as I know I need to make a plugin that taps into the function updateStatusForOneOrder, located in file:
/administrator/components/com_virtuemart/models/orders.php

What I donĀ“t know is how to construct a plugin to trigger when order status is updated to "Order Registered" (not pending)
Is there a free plugin out there that does more or less the same, that I can use as a template, maybe?


Genius WebDesign

Well, now I found a plugin that I can modify, which is designed to tap into function plgVmOnUserOrder, but I need to sort out one detail.
I need to fetch the BT email address from cart session to use for the Newsletter signup script.

I can see in orders.php this is used for fetching order customer notes: $_cart->customer_comment
So my simple question is, how do I fetch/echo the BT email?
Could it be something like this, maybe?:   $_cart->BT['email']

GJC Web Design

Unless it's there in the object no  (just echo out the $_cart)

otherwise to a quick query in your plugin
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Genius WebDesign

I found a solution.
I just had to target the function: plgVmConfirmedOrder
Here I have all the order data I need.

The final step is to create a new user field as checkbox and implement it in checkout template.