Exemplo n.º 1
0
 public static function getPlugin($commerce_plugin)
 {
     $plugin = null;
     switch ($commerce_plugin) {
         case 'woocommerce':
             $plugin = CREDC_Loader::get('PLUGIN/Woocommerce');
             break;
     }
     return $plugin;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
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 
Exemplo n.º 4
0
 public static function renderCommerceExtraColumns($column_name, $post_ID)
 {
     if ('cred_commerce' == $column_name) {
         $data = CREDC_Loader::get('MODEL/Main')->getForm($post_ID, false);
         if (isset($data->commerce)) {
             $data = $data->commerce;
             if (isset($data['associate_product']) && 'form' == $data['associate_product'] && isset($data['product'])) {
                 $product = self::$handler ? self::$handler->getProduct($data['product']) : false;
                 if ($product) {
                     printf(__('Product: %s', 'wp-cred-pay'), $product->title);
                 } else {
                     echo '<strong>' . __('Not Set', 'wp-cred-pay') . '</strong>';
                 }
             } elseif (isset($data['associate_product']) && 'post' == $data['associate_product'] && isset($data['product_field'])) {
                 printf(__('Product Field: %s', 'wp-cred-pay'), $data['product_field']);
             } else {
                 echo '<strong>' . __('Not Set', 'wp-cred-pay') . '</strong>';
             }
         } else {
             echo '<strong>' . __('Not Set', 'wp-cred-pay') . '</strong>';
         }
     }
 }
Exemplo n.º 5
0
 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);
 }