Esempio n. 1
0
function wpinventory_process_reserve($data)
{
    $to_email = wpinventory_get_config('reserve_email');
    if (!$to_email) {
        $to_email = get_option('admin_email');
    }
    $subject = WPIMCore::__('An item has been reserved from') . ' ' . get_bloginfo('site_name');
    $message = '';
    $fields = array('inventory_number', 'inventory_serial', 'inventory_name');
    $fields = apply_filters('wpim_reserve_item_fields', $fields);
    $item_title = WPIMCore::__('Item Details');
    $item_title = apply_filters('wpim_reserve_title_item_details', $item_title);
    $message .= PHP_EOL . $item_title;
    $inventory_display = wpinventory_get_display_settings('detail');
    if (!empty($data['inventory_id'])) {
        $loop = new WPIMLoop(array('inventory_id' => $data['inventory_id']));
        while ($loop->have_items()) {
            $loop->the_item();
            foreach ($inventory_display as $field) {
                $message .= PHP_EOL . $loop->get_label($field) . ': ' . $loop->get_field($field);
            }
        }
    }
    $reservation_title = WPIMCore::__('Reservation Details');
    $reservation_title = apply_filters('wpim_reserve_title_reservation_details', $reservation_title);
    $message .= PHP_EOL . PHP_EOL . $reservation_title;
    $exclude = array('inventory_id');
    $exclude = apply_filters('wpim_reserve_exclude_form_fields', $exclude);
    $args = wpinventory_get_reserve_config();
    foreach ($data as $field => $d) {
        if (!in_array($field, $exclude) && $args['display_' . $field]) {
            $message .= PHP_EOL . $d['label'] . ': ' . $d['value'];
        }
    }
    $subject = apply_filters('wpim_reserve_email_subject', $subject);
    $message = apply_filters('wpim_reserve_email_message', $message);
    $status = FALSE;
    $test_mode = FALSE;
    if ($test_mode) {
        echo '<br>== E-Mail output (in test mode) ==<br>';
        echo '<pre>';
        echo 'To: ' . $to_email . PHP_EOL;
        echo 'Subject: ' . $subject . PHP_EOL;
        echo 'Message:' . PHP_EOL;
        echo $message;
        echo '</pre>';
    }
    $success = wp_mail($to_email, $subject, $message);
    if (!$success) {
        return WPIMCore::__('There was an issue sending your e-mail.  Please try again later.');
    } else {
        if (wpinventory_get_config('reserve_decrement')) {
            $wpim_item = new WPIMItem();
            $wpim_item->save_reserve($data['inventory_id'], $data['quantity']['value']);
            do_action('wpim_reserve_sent', $data['inventory_id'], $data, $subject, $message);
            $status = TRUE;
        }
    }
    $send_confirmation = wpinventory_get_config('reserve_confirmation');
    if ($send_confirmation) {
        // Grab e-mail from the form
        $confirm_email = $data['email']['value'];
        // If the user is logged in, use that e-mail
        if (is_user_logged_in()) {
            $current_user = wp_get_current_user();
            $confirm_email = $current_user->user_email;
        }
        $subject = apply_filters('wpim_reserve_confirmation_email_subject', $subject);
        $message = apply_filters('wpim_reserve_confirmation_email_message', $message);
        if ($test_mode) {
            echo '<br>== E-Mail Confirmation output (in test mode) ==<br>';
            echo '<pre>';
            echo 'To: ' . $confirm_email . PHP_EOL;
            echo 'Subject: ' . $subject . PHP_EOL;
            echo 'Message:' . PHP_EOL;
            echo $message;
            echo '</pre>';
        }
        $success = wp_mail($confirm_email, $subject, $message);
        if (!$success) {
            return WPIMCore::__('There was an issue sending the confirmation e-mail.  Please try again later.');
        } else {
            do_action('wpim_reserve_confirmation_sent', $data['inventory_id'], $data, $subject, $message);
            $status = TRUE;
        }
    }
    return $status;
}
Esempio n. 2
0
}
wpinventory_get_items();
echo wpinventory_filter_form('filter=true&sort=true');
global $inventory_display;
$inventory_display = wpinventory_get_display_settings('listing');
if (wpinventory_have_items()) {
    ?>
	<table
		class="wpinventory_loop wpinventory_loop_category wpinventory_loop_category-<?php 
    echo wpinventory_get_the_category_ID();
    ?>
">
		<thead>
		<tr>
			<?php 
    if (wpinventory_get_config('display_listing_labels')) {
        foreach ($inventory_display as $sort => $field) {
            ?>
					<th class="<?php 
            echo wpinventory_label_class($field);
            ?>
"><?php 
            wpinventory_the_label($field);
            ?>
</th>
				<?php 
        }
    }
    ?>
		</tr>
		</thead>
Esempio n. 3
0
<?php

/**
 * The single template specifically designed for the shortcode.
 * This file may be overridden by copying it into your theme directory, into a folder titled wpinventory/views/single-item.php
 * While inventory does not use the WP post types, it does model functions after the WP core functions
 * to provide similar functionality.
 * */
$inventory_display = wpinventory_get_display_settings('detail');
$display_labels = wpinventory_get_config('display_detail_labels');
wpinventory_get_items();
if (wpinventory_have_items()) {
    while (wpinventory_have_items()) {
        wpinventory_the_item();
        ?>
		<div class="<?php 
        wpinventory_class();
        ?>
">
		<?php 
        foreach ($inventory_display as $sort => $field) {
            ?>
			<div class="<?php 
            echo $field;
            ?>
">
				<?php 
            if ($display_labels) {
                ?>
					<span class="wpinventory_label"><?php 
                wpinventory_the_label($field);