Пример #1
0
    public function column_default($item, $column_name)
    {
        global $product;
        if (!$product || $product->id !== $item->id) {
            $product = new fflcommerce_product($item->id);
        }
        switch ($column_name) {
            case 'product':
                if ($sku = $product->get_sku()) {
                    echo $sku . ' - ';
                }
                echo $product->get_title();
                // Get variation data
                if ($product->is_type('variation')) {
                    $list_attributes = array();
                    $attributes = $product->get_available_attributes_variations();
                    foreach ($attributes as $name => $attribute) {
                        $list_attributes[] = $product->attribute_label(str_replace('pa_', '', $name)) . ': <strong>' . $attribute . '</strong>';
                    }
                    echo '<div class="description">' . implode(', ', $list_attributes) . '</div>';
                }
                break;
            case 'parent':
                if ($item->parent) {
                    echo get_the_title($item->parent);
                } else {
                    echo '-';
                }
                break;
            case 'stock_status':
                if ($product->is_in_stock() || !isset($product->meta['stock_manage']) && !isset($product->meta['stock_status']) && $product->get_stock() > 0) {
                    echo '<mark class="instock">' . __('In stock', 'fflcommerce') . '</mark>';
                } else {
                    echo '<mark class="outofstock">' . __('Out of stock', 'fflcommerce') . '</mark>';
                }
                break;
            case 'stock_level':
                echo $product->get_stock();
                break;
            case 'actions':
                ?>
<p>
				<?php 
                $actions = array();
                $action_id = $item->parent != 0 ? $item->parent : $item->id;
                $actions['edit'] = array('url' => admin_url('post.php?post=' . $action_id . '&action=edit'), 'name' => __('Edit', 'fflcommerce'), 'action' => "edit");
                if ($product->is_visible()) {
                    $actions['view'] = array('url' => get_permalink($action_id), 'name' => __('View', 'fflcommerce'), 'action' => "view");
                }
                $actions = apply_filters('fflcommerce_admin_stock_report_product_actions', $actions, $product);
                foreach ($actions as $action) {
                    printf('<a class="button tips %s" href="%s" data-tip="%s ' . __('product', 'fflcommerce') . '">%s</a>', $action['action'], esc_url($action['url']), esc_attr($action['name']), esc_attr($action['name']));
                }
                ?>
				</p><?php 
                break;
        }
    }
Пример #2
0
/**
 * @param \fflcommerce_product $product
 * @return array
 */
function get_stock_email_arguments($product)
{
    $options = FFLCommerce_Base::get_options();
    return array('blog_name' => get_bloginfo('name'), 'shop_name' => $options->get('fflcommerce_company_name'), 'shop_address_1' => $options->get('fflcommerce_address_1'), 'shop_address_2' => $options->get('fflcommerce_address_2'), 'shop_tax_number' => $options->get('fflcommerce_tax_number'), 'shop_phone' => $options->get('fflcommerce_company_phone'), 'shop_email' => $options->get('fflcommerce_company_email'), 'product_id' => $product->id, 'product_name' => $product->get_title(), 'sku' => $product->sku);
}
Пример #3
0
function fflcommerce_order_tracking($atts)
{
    extract(shortcode_atts(array(), $atts));
    global $post;
    $fflcommerce_options = FFLCommerce_Base::get_options();
    if ($_POST) {
        $order = new fflcommerce_order();
        $order->id = !empty($_POST['orderid']) ? $_POST['orderid'] : 0;
        if (isset($_POST['order_email']) && $_POST['order_email']) {
            $order_email = trim($_POST['order_email']);
        } else {
            $order_email = '';
        }
        if (!fflcommerce::verify_nonce('order_tracking')) {
            echo '<p>' . __('You have taken too long. Please refresh the page and retry.', 'fflcommerce') . '</p>';
        } elseif ($order->id && $order_email && $order->get_order(apply_filters('fflcommerce_shortcode_order_tracking_order_id', $order->id))) {
            if ($order->billing_email == $order_email) {
                echo '<p>' . sprintf(__('Order %s which was made %s ago and has the status "%s"', 'fflcommerce'), $order->get_order_number(), human_time_diff(strtotime($order->order_date), current_time('timestamp')), __($order->status, 'fflcommerce'));
                if ($order->status == 'completed') {
                    $completed = (array) get_post_meta($order->id, '_js_completed_date', true);
                    if (!empty($completed)) {
                        $completed = $completed[0];
                    } else {
                        $completed = '';
                    }
                    // shouldn't happen, reset to be sure
                    echo sprintf(__(' was completed %s ago', 'fflcommerce'), human_time_diff(strtotime($completed), current_time('timestamp')));
                }
                echo '.</p>';
                do_action('fflcommerce_tracking_details_info', $order);
                ?>
				<?php 
                do_action('fflcommerce_before_track_order_details', $order->id);
                ?>
				<h2><?php 
                _e('Order Details', 'fflcommerce');
                ?>
</h2>
				<table class="shop_table">
					<thead>
						<tr>
							<th><?php 
                _e('ID/SKU', 'fflcommerce');
                ?>
</th>
							<th><?php 
                _e('Title', 'fflcommerce');
                ?>
</th>
							<th><?php 
                _e('Price', 'fflcommerce');
                ?>
</th>
							<th><?php 
                _e('Quantity', 'fflcommerce');
                ?>
</th>
						</tr>
					</thead>
					<tfoot>
                        <tr>
                            <?php 
                if ($fflcommerce_options->get('fflcommerce_calc_taxes') == 'yes' && $order->has_compound_tax() || $fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'yes' && $order->order_discount > 0) {
                    ?>
                                <td colspan="3"><?php 
                    _e('Retail Price', 'fflcommerce');
                    ?>
</td>
                            <?php 
                } else {
                    ?>
                                <td colspan="3"><?php 
                    _e('Subtotal', 'fflcommerce');
                    ?>
</td>
                            <?php 
                }
                ?>
                                <td><?php 
                echo $order->get_subtotal_to_display();
                ?>
</td>
                        </tr>
                        <?php 
                if ($order->order_shipping > 0) {
                    ?>
                            <tr>
                                <td colspan="3"><?php 
                    _e('Shipping', 'fflcommerce');
                    ?>
</td>
                                <td><?php 
                    echo $order->get_shipping_to_display();
                    ?>
</td>
                            </tr>
                            <?php 
                }
                do_action('fflcommerce_processing_fee_after_shipping');
                if ($fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'yes' && $order->order_discount > 0) {
                    ?>
                            <tr class="discount">
                                <td colspan="3"><?php 
                    _e('Discount', 'fflcommerce');
                    ?>
</td>
                                <td>-<?php 
                    echo fflcommerce_price($order->order_discount);
                    ?>
</td>
                            </tr>
                            <?php 
                }
                if ($fflcommerce_options->get('fflcommerce_calc_taxes') == 'yes' && $order->has_compound_tax() || $fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'yes' && $order->order_discount > 0) {
                    ?>
                            <tr>
                                <td colspan="3"><?php 
                    _e('Subtotal', 'fflcommerce');
                    ?>
</td>
                                <td><?php 
                    echo fflcommerce_price($order->order_discount_subtotal);
                    ?>
</td>
                            </tr>
                            <?php 
                }
                if ($fflcommerce_options->get('fflcommerce_calc_taxes') == 'yes') {
                    foreach ($order->get_tax_classes() as $tax_class) {
                        if ($order->show_tax_entry($tax_class)) {
                            ?>
                                    <tr>
                                        <td colspan="3"><?php 
                            echo $order->get_tax_class_for_display($tax_class) . ' (' . (double) $order->get_tax_rate($tax_class) . '%):';
                            ?>
</td>
                                        <td><?php 
                            echo $order->get_tax_amount($tax_class);
                            ?>
</td>
                                    </tr>
                                    <?php 
                        }
                    }
                }
                ?>
						<?php 
                if ($fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'no' && $order->order_discount > 0) {
                    ?>
<tr class="discount">
							<td colspan="3"><?php 
                    _e('Discount', 'fflcommerce');
                    ?>
</td>
							<td>-<?php 
                    echo fflcommerce_price($order->order_discount);
                    ?>
</td>
						</tr><?php 
                }
                ?>
						<tr>
							<td colspan="3"><strong><?php 
                _e('Grand Total', 'fflcommerce');
                ?>
</strong></td>
							<td><strong><?php 
                echo fflcommerce_price($order->order_total);
                ?>
</strong></td>
						</tr>
					</tfoot>
					<tbody>
						<?php 
                foreach ($order->items as $order_item) {
                    if (isset($order_item['variation_id']) && $order_item['variation_id'] > 0) {
                        $_product = new fflcommerce_product_variation($order_item['variation_id']);
                    } else {
                        $_product = new fflcommerce_product($order_item['id']);
                    }
                    echo '<tr>';
                    echo '<td>' . $_product->sku . '</td>';
                    echo '<td class="product-name">' . $_product->get_title();
                    if ($_product instanceof fflcommerce_product_variation) {
                        echo fflcommerce_get_formatted_variation($_product, $order_item['variation']);
                    }
                    do_action('fflcommerce_display_item_meta_data', $order_item);
                    echo '</td>';
                    echo '<td>' . fflcommerce_price($order_item['cost']) . '</td>';
                    echo '<td>' . $order_item['qty'] . '</td>';
                    echo '</tr>';
                }
                ?>
					</tbody>
				</table>
				<?php 
                do_action('fflcommerce_after_track_order_details', $order->id);
                ?>

				<div style="width: 49%; float:left;">
					<h2><?php 
                _e('Billing Address', 'fflcommerce');
                ?>
</h2>
					<p><?php 
                $address = $order->billing_first_name . ' ' . $order->billing_last_name . '<br/>';
                if ($order->billing_company) {
                    $address .= $order->billing_company . '<br/>';
                }
                $address .= $order->formatted_billing_address;
                echo $address;
                ?>
</p>
				</div>
				<div style="width: 49%; float:right;">
					<h2><?php 
                _e('Shipping Address', 'fflcommerce');
                ?>
</h2>
					<p><?php 
                $address = $order->shipping_first_name . ' ' . $order->shipping_last_name . '<br/>';
                if ($order->shipping_company) {
                    $address .= $order->shipping_company . '<br/>';
                }
                $address .= $order->formatted_shipping_address;
                echo $address;
                ?>
</p>
				</div>
				<div class="clear"></div>
				<?php 
            } else {
                echo '<p>' . __('Sorry, we could not find that order id in our database. <a href="' . get_permalink($post->ID) . '">Want to retry?</a>', 'fflcommerce') . '</p>';
            }
        } else {
            echo '<p>' . sprintf(__('Sorry, we could not find that order id in our database. <a href="%s">Want to retry?</a></p>', 'fflcommerce'), get_permalink($post->ID));
        }
    } else {
        ?>
		<form action="<?php 
        echo esc_url(get_permalink($post->ID));
        ?>
" method="post" class="track_order">

			<p><?php 
        _e('To track your order please enter your Order ID and email address in the boxes below and press return. This was given to you on your receipt and in the confirmation email you should have received.', 'fflcommerce');
        ?>
</p>

			<p class="form-row form-row-first"><label for="orderid"><?php 
        _e('Order ID', 'fflcommerce');
        ?>
</label> <input class="input-text" type="text" name="orderid" id="orderid" placeholder="<?php 
        _e('Found in your order confirmation email.', 'fflcommerce');
        ?>
" /></p>
			<p class="form-row form-row-last"><label for="order_email"><?php 
        _e('Billing Email', 'fflcommerce');
        ?>
</label> <input class="input-text" type="text" name="order_email" id="order_email" placeholder="<?php 
        _e('Email you used during checkout.', 'fflcommerce');
        ?>
" /></p>
			<div class="clear"></div>
			<p class="form-row"><input type="submit" class="button" name="track" value="<?php 
        _e('Track"', 'fflcommerce');
        ?>
" /></p>
			<?php 
        fflcommerce::nonce_field('order_tracking');
        ?>
		</form>
		<?php 
    }
}
Пример #4
0
    /**
     * Generate the skrill button link
     **/
    public function generate_skrill_form()
    {
        $order_id = $_GET['orderId'];
        $order = new fflcommerce_order($order_id);
        $skrill_adr = 'https://www.moneybookers.com/app/payment.pl';
        $shipping_name = explode(' ', $order->shipping_method);
        $order_total = trim($order->order_total, 0);
        if (substr($order_total, -1) == '.') {
            $order_total = str_replace('.', '', $order_total);
        }
        // filter redirect page
        $checkout_redirect = apply_filters('fflcommerce_get_checkout_redirect_page_id', fflcommerce_get_page_id('thanks'));
        $skrill_args = array('merchant_fields' => 'partner', 'partner' => 'FFLCommerce', 'pay_to_email' => $this->email, 'recipient_description' => get_bloginfo('name'), 'transaction_id' => $order_id, 'return_url' => get_permalink($checkout_redirect), 'return_url_text' => 'Return to Merchant', 'new_window_redirect' => 0, 'prepare_only' => 0, 'return_url_target' => 1, 'cancel_url' => trailingslashit(get_bloginfo('url')) . '?skrillListener=skrill_cancel', 'cancel_url_target' => 1, 'status_url' => trailingslashit(get_bloginfo('url')) . '?skrillListener=skrill_status', 'language' => $this->getLocale(), 'hide_login' => 1, 'confirmation_note' => __('Thank you for shopping', 'fflcommerce'), 'pay_from_email' => $order->billing_email, 'firstname' => $order->billing_first_name, 'lastname' => $order->billing_last_name, 'address' => $order->billing_address_1, 'address2' => $order->billing_address_2, 'phone_number' => $order->billing_phone, 'postal_code' => $order->billing_postcode, 'city' => $order->billing_city, 'state' => $order->billing_state, 'country' => $this->retrieveIOC($this->getLocale()), 'amount' => $order_total, 'currency' => FFLCommerce_Base::get_options()->get_option('fflcommerce_currency'), 'detail1_description' => 'Order ID', 'detail1_text' => $order_id, 'payment_methods' => $this->payment_methods);
        // Cart Contents
        $item_loop = 0;
        if (sizeof($order->items) > 0) {
            foreach ($order->items as $item) {
                if (!empty($item['variation_id'])) {
                    $_product = new fflcommerce_product_variation($item['variation_id']);
                } else {
                    $_product = new fflcommerce_product($item['id']);
                }
                if ($_product->exists() && $item['qty']) {
                    $item_loop++;
                    $skrill_args['item_name_' . $item_loop] = $_product->get_title();
                    $skrill_args['quantity_' . $item_loop] = $item['qty'];
                    $skrill_args['amount_' . $item_loop] = $_product->get_price_with_tax();
                }
            }
        }
        // Shipping Cost
        $item_loop++;
        $skrill_args['item_name_' . $item_loop] = __('Shipping cost', 'fflcommerce');
        $skrill_args['quantity_' . $item_loop] = '1';
        $skrill_args['amount_' . $item_loop] = number_format($order->order_shipping, 2);
        $skrill_args_array = array();
        foreach ($skrill_args as $key => $value) {
            $skrill_args_array[] = '<input type="hidden" name="' . esc_attr($key) . '" value="' . esc_attr($value) . '" />';
        }
        // Skirll MD5 concatenation
        $skrill_md = FFLCommerce_Base::get_options()->get_option('fflcommerce_skrill_customer_id') . $skrill_args['transaction_id'] . strtoupper(md5(FFLCommerce_Base::get_options()->get_option('fflcommerce_skrill_secret_word'))) . $order_total . FFLCommerce_Base::get_options()->get_option('fflcommerce_currency') . '2';
        $skrill_md = md5($skrill_md);
        add_post_meta($order_id, '_skrillmd', $skrill_md);
        echo '<form name="moneybookers" id="moneybookers_place_form" action="' . $skrill_adr . '" method="POST">' . implode('', $skrill_args_array) . '</form>';
        echo '<script type="text/javascript">
		//<![CDATA[
    	var paymentform = document.getElementById(\'moneybookers_place_form\');
   		window.onload = paymentform.submit();
		//]]>
		</script>';
        exit;
    }
 /**
  * Show current filters
  */
 public function current_filters()
 {
     $this->product_ids_titles = array();
     foreach ($this->product_ids as $product_id) {
         $product = new fflcommerce_product($product_id);
         if ($product) {
             $this->product_ids_titles[] = $product->get_title();
         } else {
             $this->product_ids_titles[] = '#' . $product_id;
         }
     }
     echo '<p>' . ' <strong>' . implode(', ', $this->product_ids_titles) . '</strong></p>';
     echo '<p><a class="button" href="' . esc_url(remove_query_arg('product_ids')) . '">' . __('Reset', 'fflcommerce') . '</a></p>';
 }
Пример #6
0
 /**
  * Widget
  * Display the widget in the sidebar
  * Save output to the cache if empty
  *
  * @param  array  sidebar arguments
  * @param  array  instance
  */
 public function widget($args, $instance)
 {
     // Get the most recent products from the cache
     $cache = wp_cache_get('widget_recent_reviews', 'widget');
     // If no entry exists use array
     if (!is_array($cache)) {
         $cache = array();
     }
     // If cached get from the cache
     if (isset($cache[$args['widget_id']])) {
         echo $cache[$args['widget_id']];
         return false;
     }
     // Start buffering
     ob_start();
     extract($args);
     // Set the widget title
     $title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : __('Recent Reviews', 'fflcommerce'), $instance, $this->id_base);
     // Set number of products to fetch
     if (!($number = absint($instance['number']))) {
         $number = 5;
     }
     // Modify get_comments query to only include products which are visible
     add_filter('comments_clauses', array($this, 'where_product_is_visible'));
     // Get the latest reviews
     $comments = get_comments(array('number' => $number, 'status' => 'approve', 'post_status' => 'publish', 'post_type' => 'product'));
     // If there are products
     if ($comments) {
         // Print the widget wrapper & title
         echo $before_widget;
         if ($title) {
             echo $before_title . $title . $after_title;
         }
         // Open the list
         echo '<ul class="product_list_widget">';
         // Print out each product
         foreach ($comments as $comment) {
             // Get new fflcommerce_product instance
             $_product = new fflcommerce_product($comment->comment_post_ID);
             // Skip products that are invisible
             if ($_product->visibility == 'hidden') {
                 continue;
             }
             // TODO: Refactor this
             // Apply star size
             $star_size = apply_filters('fflcommerce_star_rating_size_recent_reviews', 16);
             $rating = get_comment_meta($comment->comment_ID, 'rating', true);
             echo '<li>';
             // Print the product image & title with a link to the permalink
             echo '<a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">';
             // Print the product image
             echo has_post_thumbnail($_product->id) ? get_the_post_thumbnail($_product->id, 'shop_tiny') : fflcommerce_get_image_placeholder('shop_tiny');
             echo '<span class="js_widget_product_title">' . $_product->get_title() . '</span>';
             echo '</a>';
             // Print the star rating
             echo "<div class='star-rating' title='{$rating}'>\n\t\t\t\t\t\t<span style='width:" . $rating * $star_size . "px;'>{$rating} " . __('out of 5', 'fflcommerce') . "</span>\n\t\t\t\t\t</div>";
             // Print the author
             printf(_x('by %1$s', 'author', 'fflcommerce'), get_comment_author($comment->comment_ID));
             echo '</li>';
         }
         echo '</ul>';
         // Close the list
         // Print closing widget wrapper
         echo $after_widget;
         // Remove the filter on comments to stop other queries from being manipulated
         remove_filter('comments_clauses', array($this, 'where_product_is_visible'));
     }
     // Flush output buffer and save to cache
     $cache[$args['widget_id']] = ob_get_flush();
     wp_cache_set('widget_recent_reviews', $cache, 'widget');
 }