0

I found a plugin on the following site http://becordial.co.uk/expressionengine-cartthrob-email-notification-dynamic-custom-field/ which I have uploaded but does not show up in the extensions list so cannot install. Using EE 2.7.2

Any ideas why it is not showing up?

EE =& get_instance();
    $this->settings = $settings;
    }


    public function activate_extension()
    {
        $this->EE->db->insert(
            'extensions',
            array(
            'class' => __CLASS__,
            'method' => 'cartthrob_on_authorize',
            'hook'  => 'cartthrob_on_authorize',
            'settings' => '',
            'priority' => 10,
            'version' => $this->version,
            'enabled' => 'y'
            )
        );

$this->EE->load->add_package_path(PATH_THIRD.'cartthrob/');
$this->EE->load->library('cartthrob_loader');

$this->notification_events = array('custom_field_event'); 
$this->module_name = "Cartthrob_customfield_notification"; 

if (!empty($this->notification_events))
{
    $this->EE->db->select('notification_event')
            ->from('cartthrob_notification_events')
            ->like('application', ucwords($this->module_name), 'after');

    $existing_notifications = array();

    foreach ($this->EE->db->get()->result() as $row)
    {
        $existing_notifications[] = $row->notification_event;
    }

    foreach ($this->notification_events as $event)
    {
        if (!empty($event))
        {
            if ( ! in_array($event, $existing_notifications))
            {
                $this->EE->db->insert(
                    'cartthrob_notification_events',
                    array(
                        'application' => ucwords($this->module_name),
                        'notification_event' => $event,
                    )
                );
            }
        }
    }
}







    }

    public function update_extension($current='')
    {
        if ($current == '' OR $current == $this->version)
        {
            return FALSE;
        }

        $this->EE->db->update(
            'extensions',
            array('version' => $this->version),
            array('class' => __CLASS__)
        );
    }
    public function disable_extension()
    {
        $this->module_name = "Cartthrob_customfield_notification"; 

$this->EE->db->delete('cartthrob_notification_events', array('application' => ucwords($this->module_name)));
    $this->EE->db->delete('extensions', array('class' => __CLASS__));
 }


    public function settings()
    {
    return $settings;
    }



    function cartthrob_on_authorize()
    {
        if ($this->EE->cartthrob->cart->order('entry_id'))
        {
            $entry_id = $this->EE->cartthrob->cart->order('entry_id'); 

 ee()->load->library('logger');


$this->EE->load->add_package_path(PATH_THIRD.'cartthrob/');

$this->EE->load->library('cartthrob_loader');
$this->EE->load->library('cartthrob_emails');

$this->module_name = "Cartthrob_customfield_notification"; 

$event='custom_field_event';

$emails = $this->EE->cartthrob_emails->get_email_for_event(ucwords($this->module_name."_".$event)); 


$totagb=$emails[0]['to'];

 $order_managers_field=trim($totagb, "{}") ;

 $query = $this->EE->db->select('field_id', 'field_name')
  ->from('exp_channel_fields f')
   ->where(array(
        'f.field_name'=>$order_managers_field
    ))
     ->limit(1)
  ->get();  

$order_managers_field_id=0;

 if ($query->num_rows() > 0)
{

$order_managers_field_id='field_id_'. $query->row('field_id');


$email_query = $this->EE->db->select($order_managers_field_id)
  ->from('exp_channel_data d')
   ->where(array(
        'd.entry_id' => $entry_id
    ))
     ->limit(1)
  ->get();          



 if ($email_query->num_rows() > 0)
{

    $this->EE->load->model("order_model");



$order_managers_email= $email_query->row($order_managers_field_id);


if (!empty($emails))
{
    foreach ($emails as $email_content)
    {

$email_content['to'] = $order_managers_email;

        $this->EE->cartthrob_emails->send_email($email_content,$this->EE->cartthrob->cart->order()); 
    }
}



}




}else{
ee()->logger->developer('no data returned'); 

}

}
    }
    // END
}
//END CLASS
0

Eventually used Postmaster and created a hook to send a custom_field notifcation

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.