public static function getPlugin($commerce_plugin)
 {
     $plugin = null;
     switch ($commerce_plugin) {
         case 'woocommerce':
             $plugin = CREDC_Loader::get('PLUGIN/Woocommerce');
             break;
     }
     return $plugin;
 }
 public function getCustomer($post_id, $form_id)
 {
     global $woocommerce;
     $model = CREDC_Loader::get('MODEL/Main');
     $orders = $model->getPostBy(array('meta' => array('_cred_post_id' => $post_id, '_cred_form_id' => $form_id), 'post' => array('post_type' => 'shop_order')));
     //cred_log(array($post_id, $form_id, $orders));
     if ($orders) {
         $order = end($orders);
         $order = new WC_Order($order->ID);
         //cred_log($order);
         if ($order && $order->user_id) {
             $user = get_userdata($order->user_id);
             // add some extra fields
             if ($user) {
                 if (!isset($user->user_firstname)) {
                     $user->user_firstname = get_user_meta($user->ID, 'user_firstname', true);
                 }
                 if (!isset($user->user_lastname)) {
                     $user->user_lastname = get_user_meta($user->ID, 'user_lastname', true);
                 }
             }
             return $user;
         }
     }
     return false;
 }
Exemple #3
0
}
define('CRED_COMMERCE_PLUGIN_FOLDER', basename(CRED_COMMERCE_PLUGIN_PATH));
define('CRED_COMMERCE_PLUGIN_URL', plugins_url() . '/' . CRED_COMMERCE_PLUGIN_FOLDER);
define('CRED_COMMERCE_ASSETS_URL', CRED_COMMERCE_PLUGIN_URL . '/assets');
define('CRED_COMMERCE_ASSETS_PATH', CRED_COMMERCE_PLUGIN_PATH . '/assets');
define('CRED_COMMERCE_LOCALE_PATH', CRED_COMMERCE_PLUGIN_FOLDER . '/locale');
define('CRED_COMMERCE_VIEWS_PATH', CRED_COMMERCE_PLUGIN_PATH . '/views');
define('CRED_COMMERCE_VIEWS_PATH2', CRED_COMMERCE_PLUGIN_FOLDER . '/views');
define('CRED_COMMERCE_TEMPLATES_PATH', CRED_COMMERCE_PLUGIN_PATH . '/views/templates');
define('CRED_COMMERCE_TABLES_PATH', CRED_COMMERCE_PLUGIN_PATH . '/views/tables');
define('CRED_COMMERCE_CLASSES_PATH', CRED_COMMERCE_PLUGIN_PATH . '/classes');
define('CRED_COMMERCE_CONTROLLERS_PATH', CRED_COMMERCE_PLUGIN_PATH . '/controllers');
define('CRED_COMMERCE_MODELS_PATH', CRED_COMMERCE_PLUGIN_PATH . '/models');
define('CRED_COMMERCE_LOGS_PATH', CRED_COMMERCE_PLUGIN_PATH . '/logs');
define('CRED_COMMERCE_PLUGINS_PATH', CRED_COMMERCE_PLUGIN_PATH . '/plugins');
// define plugin name (path)
define('CRED_COMMERCE_PLUGIN_NAME', CRED_COMMERCE_PLUGIN_FOLDER . '/' . basename(__FILE__));
define('CRED_COMMERCE_PLUGIN_BASENAME', plugin_basename(__FILE__));
// load on the go resources
require_once CRED_COMMERCE_PLUGIN_PATH . '/onthego-resources/loader.php';
onthego_initialize(CRED_COMMERCE_PLUGIN_PATH . '/onthego-resources', CRED_COMMERCE_PLUGIN_URL . '/onthego-resources/');
//define('CRED_COMMERCE_DEBUG',true);
//define('CRED_COMMERCE_DEV',true);
function cred_commerce_activated()
{
    add_option('cred_commerce_activated', '1');
}
register_activation_hook(__FILE__, 'cred_commerce_activated');
include CRED_COMMERCE_PLUGIN_PATH . '/loader.php';
CREDC_Loader::load('CLASS/CRED_Commerce');
CRED_Commerce::init();
 public static function CommerceSettingsPage()
 {
     CREDC_Loader::load('VIEW/settings');
 }
Exemple #5
0
 public static function add($type = 'dependencies', $deps = array())
 {
     if ('dependencies' == $type) {
         self::$__dependencies__ = array_merge(self::$__dependencies__, $deps);
     } elseif ('assets' == $type) {
         self::$__assets__ = array_merge(self::$__assets__, $deps);
     }
 }
Exemple #6
0
<?php

if (!defined('ABSPATH')) {
    die('Security check');
}
if (!current_user_can('manage_options')) {
    die('Access Denied');
}
/* get settings */
$settings = CREDC_Loader::get('MODEL/Main')->getSettings();
/* get current tab */
$url = remove_query_arg(array('tab'), $_SERVER['REQUEST_URI']);
$tab = 'general';
?>
<div class="wrap cred-commerce-settings">
    <?php 
screen_icon('cred-frontend-editor');
?>
    <h2><?php 
_e('CRED Commerce', 'wp-cred-pay');
?>
</h2>
    <form method="post" action="">
    <div id="general" class="nav-tab-content">
        <div class="cred-fieldset">
        	<h3><?php 
_e('System Check', 'wp-cred-pay');
?>
</h3>
        	<ul>
				<?php 
 public function onOrderChange($data)
 {
     // HOOKS API
     //do_action('cred_commerce_before_send_notifications', $data);
     // send notifications
     if (!isset($data['new_status']) || !in_array($data['new_status'], array('pending', 'failed', 'processing', 'completed', 'on-hold', 'cancelled', 'refunded'))) {
         return;
     }
     // not spam with useless notifications ;)
     if (isset($data['cred_meta']) && $data['cred_meta']) {
         $model = CREDC_Loader::get('MODEL/Main');
         CRED_Loader::load('CLASS/Notification_Manager');
         foreach ($data['cred_meta'] as $ii => $meta) {
             if (!isset($meta['cred_form_id'])) {
                 continue;
             }
             $form_id = $meta['cred_form_id'];
             $form_slug = '';
             $cred_form_post = get_post($form_id);
             if ($cred_form_post) {
                 $form_slug = $cred_form_post->post_name;
             }
             $post_id = $meta['cred_post_id'];
             $form = $model->getForm($form_id, true);
             if ($form->isCommerce && isset($form->fields['notification'])) {
                 $this->_data = array('order_id' => $data['order_id'], 'previous_status' => $data['previous_status'], 'new_status' => $data['new_status'], 'cred_meta' => $meta);
                 add_filter('cred_custom_notification_event', array(&$this, 'notificationOrderEvent'), 1, 4);
                 CRED_Notification_Manager::triggerNotifications($post_id, array('event' => 'order_modified', 'form_id' => $form_id, 'notification' => $form->fields['notification']));
                 remove_filter('cred_custom_notification_event', array(&$this, 'notificationOrderEvent'), 1, 4);
                 $this->_data = false;
             }
         }
     }
     // HOOKS API
     do_action('cred_commerce_after_send_notifications_form_' . $form_slug, $data);
     do_action('cred_commerce_after_send_notifications', $data);
 }