Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Plugins

Shoppingcart email confirmation

Started by Ragnar Markus 8 years ago · 2 replies · 671 views
8 years ago

Hi,

Does anyone have experience with the shopping cart plugin? I can see that at some point it should fire the event "onShoppingCartAfterSaveOrder" that should trigger the email notification. But can't find it anywhere.

Any ideas? So far im trying to add my own onShoppingCartAfterSaveOrder event and that gets fired but fails when i use it to send and email.

8 years ago

Hi,

In the shoppingcart.php , you will find the onshoppingcartaftersaveorder function.

I have just added few lines to test it and i have received correctly the email.

`
public function onShoppingCartSaveOrder($event)
{
$order = $event['order'];
$this->order_id = $this->saveOrderToFilesystem($order);
$this->grav->fireEvent('onShoppingCartAfterSaveOrder', new Event([
'order' => $order,
'order_id' => $this->order_id
]));
$to = '[email protected]';
$from = '[email protected]';

PHP
    $subject = 'Test';
    $content = 'Test';

    $message = $this->grav['Email']->message($subject, $content, 'text/html')
        ->setFrom($from)
        ->setTo($to);
    $sent = $this->grav['Email']->send($message);
}

`
I am not sure that is the best way but it works!

8 years ago

Thank you for your response unmick. I should have reported back but thats exactly what i ended up doing to fix the situation. But then i thought it over and did some digging and found a customcheckout plugin from the cart developer that does not seem to be maintained anymore so decided to move over to snipcart. Seems like a more solid solution for me.

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Rene, 1 week ago
2 43 1 week ago
Plugins · by Xavier, 4 weeks ago
2 53 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1179 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 48 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 72 2 months ago