I want to create a php script that will be connected to a cron task and this script will send an email to me if something is found in database.
I was thinking of creating the php file in the root directory of my cs cart installation with something like this in it:
get_something_from_database;
if(something==true)
{
Mailer::sendMail(array(
‘to’ => ‘test@example.com’,
‘from’ => ‘company_users_department’,
‘reply_to’ => $un[‘shop_user_id’],
‘data’ => array(
‘user_data’ => $user_data,
‘product_name’ => $un[‘name’],
‘syntheseis’ => $product_code,
),
‘tpl’ => ‘profiles/disabled_product.tpl’,
‘company_id’ => $shop_data[‘full_description’]
), ‘A’, Registry::get(‘settings.Appearance.backend_default_language’));
}
?>
But when I tried to run this script from the browser, like: "http://localhost/cs/name_of_php.php
I get 2 basic errors.
First that it cannot connect to Database, and second, that it cannot find the Tygh\Mailer
Any ideas how to create my script?
I managed to do what I wanted but I have a another similar question now.
I connect to database, but I cannot use the db_get_fields etc functions.
Or the Tygh/Mailer.
Why is this happening and what do I have to do in order to use the placeholders, microformats etc that cs cart provides?
Thank you
SDAD
#3
I managed to do what I wanted but I have a another similar question now.
I connect to database, but I cannot use the db_get_fields etc functions.
Or the Tygh/Mailer.
Why is this happening and what do I have to do in order to use the placeholders, microformats etc that cs cart provides?
Thank you
It is better to create new controller, because all CS-Cart functions and classes will be accessible there.
A controller in a new addon right?
My_changes addon for example.
Please try
use Tygh\Mailer;
use Tygh\Registry;
define(‘AREA’, ‘C’);
require dirname(FILE) . ‘/init.php’;
…YOUR_CODE_HERE…
(!) Not tested
Please try
use Tygh\Mailer;
use Tygh\Registry;
define(‘AREA’, ‘C’);
require dirname(FILE) . ‘/init.php’;
…YOUR_CODE_HERE…
(!) Not tested
I'll give it a try!! Thanks for your time