function learn_press_get_order_status_label($order_id = 0)
{
    $statuses = learn_press_get_order_statuses();
    if (is_numeric($order_id)) {
        $status = get_post_status($order_id);
    } else {
        $status = $order_id;
    }
    return !empty($statuses[$status]) ? $statuses[$status] : __('Pending', 'learn_press');
}
Example #2
0
 function save_order($post_id)
 {
     global $action;
     if (wp_is_post_revision($post_id)) {
         return;
     }
     if ($action == 'editpost' && get_post_type($post_id) == 'lp_order') {
         remove_action('save_post', array($this, 'save_order'));
         $order_statuses = learn_press_get_order_statuses();
         $order_statuses = array_keys($order_statuses);
         $status = learn_press_get_request('order-status');
         if (!in_array($status, $order_statuses)) {
             $status = reset($order_statuses);
         }
         $order = learn_press_get_order($post_id);
         $order->update_status($status);
         $user_id = learn_press_get_request('order-customer');
         //$postdata = array( 'post_status' => $status, 'ID' => $post_id );
         ///wp_update_post( $postdata );
         update_post_meta($post_id, '_user_id', $user_id > 0 ? $user_id : 0);
     }
 }
Example #3
0
 /**
  * Updates order to new status if needed
  *
  * @param string $new_status
  */
 function update_status($new_status = 'pending')
 {
     // Standardise status names.
     $new_status = 'lp-' === substr($new_status, 0, 3) ? substr($new_status, 3) : $new_status;
     $old_status = $this->get_status();
     if ($new_status !== $old_status || !in_array($this->post_status, array_keys(learn_press_get_order_statuses()))) {
         // Update the order
         wp_update_post(array('ID' => $this->id, 'post_status' => 'lp-' . $new_status));
         $this->post_status = 'lp-' . $new_status;
         // Status was changed
         do_action('learn_press_order_status_' . $new_status, $this->id);
         do_action('learn_press_order_status_' . $old_status . '_to_' . $new_status, $this->id);
         do_action('learn_press_order_status_changed', $this->id, $old_status, $new_status);
         switch ($new_status) {
             case 'completed':
                 break;
             case 'processing':
                 break;
         }
         // backward compatible
         do_action('learn_press_update_order_status', $new_status, $this->id);
     }
 }
Example #4
0
	<div id="minor-publishing">
		<div id="misc-publishing-actions">
			<?php 
if ($can_publish) {
    // Contributors don't get to choose the date of publish
    ?>

				<div class="misc-pub-section">
					<label>
						<?php 
    _e('Order status', 'learn_press');
    ?>
					</label>
					<select name="order-status">
						<?php 
    $statuses = learn_press_get_order_statuses();
    foreach ($statuses as $status => $status_name) {
        echo '<option value="' . esc_attr($status) . '" ' . selected($status, 'lp-' . $order->get_status(), false) . '>' . esc_html($status_name) . '</option>';
    }
    ?>
					</select>
				</div>

				<div class="misc-pub-section">
					<label>
						<?php 
    _e('Customer', 'learn_press');
    ?>
					</label>
					<!--
					<input name="order-customer" type="text" class="wp-suggest-user ui-autocomplete-input" id="admin-email" data-autocomplete-type="search" data-autocomplete-field="user_email" autocomplete="off">
Example #5
0
 function get_order_status()
 {
     $statuses = learn_press_get_order_statuses();
     $status = '';
     if (!empty($statuses[$this->post_status])) {
         $status = $statuses[$this->post_status];
     }
     return apply_filters('learn_press_get_order_status', $status, $this);
 }
Example #6
0
        function order_details($post)
        {
            $user = learn_press_get_user(get_post_meta($post->ID, '_learn_press_customer_id', true));
            $order_items = learn_press_get_order_items($post->ID);
            $status = strtolower(get_post_meta($post->ID, '_learn_press_transaction_status', true));
            if ($status && !in_array($status, array('completed', 'pending'))) {
                $status = 'Pending';
            }
            $currency_symbol = learn_press_get_currency_symbol($order_items->currency);
            ?>
            <div class="order-details">
                <div class="order-data">
                    <div class="order-data-number"><?php 
            echo learn_press_transaction_order_number($post->ID);
            ?>
</div>
                    <div
                        class="order-data-date"><?php 
            echo learn_press_transaction_order_date($post->post_date);
            ?>
</div>
                    <div class="order-data-status <?php 
            echo sanitize_title($status);
            ?>
"><?php 
            echo $status;
            ?>
</div>
                    <div
                        class="order-data-payment-method"><?php 
            echo learn_press_payment_method_from_slug($post->ID);
            ?>
</div>
                </div>
                <div class="order-user-data clearfix">
                    <div class="order-user-avatar">
                        <?php 
            echo get_avatar($user->ID, 120);
            ?>
                    </div>
                    <div class="order-user-meta">
                        <h2 class="user-display-name">
                            <?php 
            echo empty($user->display_name) ? __('Unknown', 'learn_press') : $user->display_name;
            ?>
                        </h2>

                        <div class="user-email">
                            <?php 
            echo empty($user->user_email) ? __('Unknown', 'learn_press') : $user->user_email;
            ?>
                        </div>
                        <div class="user-ip-address">
                            <?php 
            echo get_post_meta($post->ID, '_learn_press_customer_ip', true);
            ?>
                        </div>
                    </div>
                </div>
                <div class="order-products">
                    <table>
                        <thead>
                        <tr>
                            <th colspan="2"><?php 
            _e('Courses', 'learn_press');
            ?>
</th>
                            <th class="align-right"><?php 
            _e('Amount', 'learn_press');
            ?>
</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php 
            if ($products = learn_press_get_transition_products($post->ID)) {
                foreach ($products as $pro) {
                    ?>
                            <tr>
                                <td colspan="2">
                                    <a href="<?php 
                    the_permalink($pro->ID);
                    ?>
"><?php 
                    echo get_the_title($pro->ID);
                    ?>
</a>
                                </td>
                                <td class="align-right"><?php 
                    echo $pro->amount ? learn_press_format_price($pro->amount, $currency_symbol) : __('Free!', 'learn_press');
                    ?>
</td>
                            </tr>
                        <?php 
                }
            }
            ?>
                        </tbody>
                        <tfoot>
                        <tr>
                            <td></td>
                            <td width="300" class="align-right"><?php 
            _e('Sub Total', 'learn_press');
            ?>
</td>
                            <td width="100"
                                class="align-right"><?php 
            echo learn_press_format_price($order_items->sub_total, $currency_symbol);
            ?>
</td>
                        </tr>
                        <tr>
                            <td></td>
                            <td class="align-right"><?php 
            _e('Total', 'learn_press');
            ?>
</td>
                            <td class="align-right total"><?php 
            echo learn_press_format_price($order_items->total, $currency_symbol);
            ?>
</td>
                        </tr>
                        <tr>
                            <td></td>
                            <td class="align-right" colspan="2">
                                <?php 
            _e('Status', 'learn_press');
            ?>
                                <select name="learn_press_order_status">
                                    <?php 
            foreach (learn_press_get_order_statuses() as $status => $label) {
                ?>
                                    <option value="<?php 
                echo $status;
                ?>
" <?php 
                selected($status == get_post_status($post->ID) ? 1 : 0, 1);
                ?>
><?php 
                echo $label;
                ?>
</option>
                                    <?php 
            }
            ?>
                                </select>
                                <button id="update-order-status" class="button button-primary" type="button"><?php 
            _e('Apply', 'learn_press');
            ?>
</button>
                            </td>
                        </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
        <?php 
        }
function learn_press_request_query($vars = array())
{
    global $typenow, $wp_query, $wp_post_statuses;
    if ('lpr_order' === $typenow) {
        // Status
        if (!isset($vars['post_status'])) {
            $post_statuses = learn_press_get_order_statuses();
            foreach ($post_statuses as $status => $value) {
                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
                    unset($post_statuses[$status]);
                }
            }
            $vars['post_status'] = array_keys($post_statuses);
        }
    }
    return $vars;
}
Example #8
0
				<td class="align-right total">
					<span class="order-total">
						<?php 
echo learn_press_format_price($order->order_total, $currency_symbol);
?>
					</span>
				</td>
			</tr>
			<tr>
				<td class="align-right" colspan="4">
					<!--<?php 
_e('Status', 'learn_press');
?>
						<select name="learn_press_order_status">
							<?php 
foreach (learn_press_get_order_statuses() as $status => $label) {
    ?>
								<option value="<?php 
    echo $status;
    ?>
" <?php 
    selected($status == get_post_status($post->ID) ? 1 : 0, 1);
    ?>
><?php 
    echo $label;
    ?>
</option>
							<?php 
}
?>
						</select>