Your webshop has been deactivated

Probably the most horrible message to receive, your webshop is offline. Hopefully it doesn’t happen often, but if it does happen, I am sure you’ll want to be the first to know.

This can be due to an update you did, or an update your host performed, or even when there is something wrong at the serverside of things.

Get notified

On deacativation Shopp performs a list of tasks.
We are going to add our own task to that list.
We want the system to send us an email.

The code

Put this code in your theme’s functions.php

1
2
3
4
5
6
7
8
9
10
11
add_action('shopp_deactivate', 'my_shop_deactivated_function');
 
function my_shop_deactivated_function () {
    $to      = 'mail@yourdomain.com'; //Put your email address here
    $subject = '[WARNING] Your Webshop deactivated.';
    $message = 'Help, I have been deactivated!';
    $headers = 'From: ' . $to . "\r\n" .
        'Reply-To: '.$to. "\r\n" .
        'X-Mailer: PHP/' . phpversion();
    mail($to, $subject, $message, $headers);
}

What does this code do?

On line 1 we add a function the ‘shopp_deactivate’ hook.
We have named it ‘my_shop_deactivated_function’.
You can pick any name you like, as long as it is unique to the system.

On line 3 we start the function definition.
If you picked another function name be sure to make it match with this function definition.
Because we want the system to send us mail, we specify:

  • $to – the emailaddress to send this message to
  • $subject – the subject of the message
  • $message – the message itself. We have kept it short but you can add more information if needed.
  • $headers – information the mail() function need to be able to send the message
  • When all the information is present, we call the mail() function using the provided information.

    Now let’s hope the system will never have to run this function.

calculating-converting-prices link-to-php-article shopp-webshop-homepage Image for Shopp WordPress bestfriends article
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *