VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: Genius WebDesign on August 11, 2014, 00:30:41 AM

Title: Creating my own plugin for Newsletter signup at checkout, need help!
Post by: Genius WebDesign on August 11, 2014, 00:30:41 AM
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?

Title: Re: Creating my own plugin for Newsletter signup at checkout, need help!
Post by: Genius WebDesign on August 11, 2014, 01:15:58 AM
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']
Title: Re: Creating my own plugin for Newsletter signup at checkout, need help!
Post by: GJC Web Design on August 11, 2014, 10:33:40 AM
Unless it's there in the object no  (just echo out the $_cart)

otherwise to a quick query in your plugin
Title: Re: Creating my own plugin for Newsletter signup at checkout, need help!
Post by: Genius WebDesign on August 12, 2014, 09:01:32 AM
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.