More woo goodness

This commit is contained in:
Mike Jolley 2011-08-10 18:11:50 +01:00
parent 0425a68eca
commit 43c1ff17ad
34 changed files with 211 additions and 7733 deletions

View File

@ -1,178 +0,0 @@
<?php
/**
* Order Data Save
*
* Function for processing and storing all order data.
*
* @author Jigowatt
* @category Admin Write Panels
* @package JigoShop
*/
add_action('jigoshop_process_shop_order_meta', 'jigoshop_process_shop_order_meta', 1, 2);
function jigoshop_process_shop_order_meta( $post_id, $post ) {
global $wpdb;
$jigoshop_errors = array();
$order = &new jigoshop_order($post_id);
// Get old data + attributes
$data = (array) maybe_unserialize( get_post_meta($post_id, 'order_data', true) );
// Add/Replace data to array
$data['billing_first_name'] = stripslashes( $_POST['billing_first_name'] );
$data['billing_last_name'] = stripslashes( $_POST['billing_last_name'] );
$data['billing_company'] = stripslashes( $_POST['billing_company'] );
$data['billing_address_1'] = stripslashes( $_POST['billing_address_1'] );
$data['billing_address_2'] = stripslashes( $_POST['billing_address_2'] );
$data['billing_city'] = stripslashes( $_POST['billing_city'] );
$data['billing_postcode'] = stripslashes( $_POST['billing_postcode'] );
$data['billing_country'] = stripslashes( $_POST['billing_country'] );
$data['billing_state'] = stripslashes( $_POST['billing_state'] );
$data['billing_email'] = stripslashes( $_POST['billing_email'] );
$data['billing_phone'] = stripslashes( $_POST['billing_phone'] );
$data['shipping_first_name'] = stripslashes( $_POST['shipping_first_name'] );
$data['shipping_last_name'] = stripslashes( $_POST['shipping_last_name'] );
$data['shipping_company'] = stripslashes( $_POST['shipping_company'] );
$data['shipping_address_1'] = stripslashes( $_POST['shipping_address_1'] );
$data['shipping_address_2'] = stripslashes( $_POST['shipping_address_2'] );
$data['shipping_city'] = stripslashes( $_POST['shipping_city'] );
$data['shipping_postcode'] = stripslashes( $_POST['shipping_postcode'] );
$data['shipping_country'] = stripslashes( $_POST['shipping_country'] );
$data['shipping_state'] = stripslashes( $_POST['shipping_state'] );
$data['shipping_method'] = stripslashes( $_POST['shipping_method'] );
$data['payment_method'] = stripslashes( $_POST['payment_method'] );
$data['order_subtotal'] = stripslashes( $_POST['order_subtotal'] );
$data['order_shipping'] = stripslashes( $_POST['order_shipping'] );
$data['order_discount'] = stripslashes( $_POST['order_discount'] );
$data['order_tax'] = stripslashes( $_POST['order_tax'] );
$data['order_shipping_tax'] = stripslashes( $_POST['order_shipping_tax'] );
$data['order_total'] = stripslashes( $_POST['order_total'] );
// Customer
update_post_meta( $post_id, 'customer_user', (int) $_POST['customer_user'] );
// Order status
$order->update_status( $_POST['order_status'] );
// Order items
$order_items = array();
if (isset($_POST['item_id'])) :
$item_id = $_POST['item_id'];
$item_variation= $_POST['item_variation'];
$item_name = $_POST['item_name'];
$item_quantity = $_POST['item_quantity'];
$item_cost = $_POST['item_cost'];
$item_tax_rate = $_POST['item_tax_rate'];
for ($i=0; $i<sizeof($item_id); $i++) :
if (!isset($item_id[$i])) continue;
if (!isset($item_name[$i])) continue;
if (!isset($item_quantity[$i])) continue;
if (!isset($item_cost[$i])) continue;
if (!isset($item_tax_rate[$i])) continue;
$order_items[] = apply_filters('update_order_item', array(
'id' => htmlspecialchars(stripslashes($item_id[$i])),
'variation_id' => (int) $item_variation[$i],
'name' => htmlspecialchars(stripslashes($item_name[$i])),
'qty' => (int) $item_quantity[$i],
'cost' => number_format(jigowatt_clean($item_cost[$i]), 2),
'taxrate' => number_format(jigowatt_clean($item_tax_rate[$i]), 4)
));
endfor;
endif;
// Save
update_post_meta( $post_id, 'order_data', $data );
update_post_meta( $post_id, 'order_items', $order_items );
// Handle button actions
if (isset($_POST['reduce_stock']) && $_POST['reduce_stock'] && sizeof($order_items)>0) :
$order->add_order_note( __('Manually reducing stock.', 'jigoshop') );
foreach ($order_items as $order_item) :
$_product = $order->get_product_from_item( $order_item );
if ($_product->exists) :
if ($_product->managing_stock()) :
$old_stock = $_product->stock;
$new_quantity = $_product->reduce_stock( $order_item['qty'] );
$order->add_order_note( sprintf( __('Item #%s stock reduced from %s to %s.', 'jigoshop'), $order_item['id'], $old_stock, $new_quantity) );
if ($new_quantity<0) :
do_action('jigoshop_product_on_backorder_notification', $order_item['id'], $values['quantity']);
endif;
// stock status notifications
if (get_option('jigoshop_notify_no_stock_amount') && get_option('jigoshop_notify_no_stock_amount')>=$new_quantity) :
do_action('jigoshop_no_stock_notification', $order_item['id']);
elseif (get_option('jigoshop_notify_low_stock_amount') && get_option('jigoshop_notify_low_stock_amount')>=$new_quantity) :
do_action('jigoshop_low_stock_notification', $order_item['id']);
endif;
endif;
else :
$order->add_order_note( sprintf( __('Item %s %s not found, skipping.', 'jigoshop'), $order_item['id'], $order_item['name'] ) );
endif;
endforeach;
$order->add_order_note( __('Manual stock reduction complete.', 'jigoshop') );
elseif (isset($_POST['restore_stock']) && $_POST['restore_stock'] && sizeof($order_items)>0) :
$order->add_order_note( __('Manually restoring stock.', 'jigoshop') );
foreach ($order_items as $order_item) :
$_product = $order->get_product_from_item( $order_item );
if ($_product->exists) :
if ($_product->managing_stock()) :
$old_stock = $_product->stock;
$new_quantity = $_product->increase_stock( $order_item['qty'] );
$order->add_order_note( sprintf( __('Item #%s stock increased from %s to %s.', 'jigoshop'), $order_item['id'], $old_stock, $new_quantity) );
endif;
else :
$order->add_order_note( sprintf( __('Item %s %s not found, skipping.', 'jigoshop'), $order_item['id'], $order_item['name'] ) );
endif;
endforeach;
$order->add_order_note( __('Manual stock restore complete.', 'jigoshop') );
elseif (isset($_POST['invoice']) && $_POST['invoice']) :
// Mail link to customer
jigoshop_pay_for_order_customer_notification( $order->id );
endif;
// Error Handling
if (sizeof($jigoshop_errors)>0) update_option('jigoshop_errors', $jigoshop_errors);
}

View File

@ -1,438 +0,0 @@
<?php
/**
* Order Data
*
* Functions for displaying the order data meta box
*
* @author Jigowatt
* @category Admin Write Panels
* @package JigoShop
*/
/**
* Order data meta box
*
* Displays the meta box
*
* @since 1.0
*/
function jigoshop_order_data_meta_box($post) {
global $post, $wpdb, $thepostid;
add_action('admin_footer', 'jigoshop_meta_scripts');
wp_nonce_field( 'jigoshop_save_data', 'jigoshop_meta_nonce' );
$data = (array) maybe_unserialize( get_post_meta($post->ID, 'order_data', true) );
if (!isset($data['billing_first_name'])) $data['billing_first_name'] = '';
if (!isset($data['billing_last_name'])) $data['billing_last_name'] = '';
if (!isset($data['billing_company'])) $data['billing_company'] = '';
if (!isset($data['billing_address_1'])) $data['billing_address_1'] = '';
if (!isset($data['billing_address_2'])) $data['billing_address_2'] = '';
if (!isset($data['billing_city'])) $data['billing_city'] = '';
if (!isset($data['billing_postcode'])) $data['billing_postcode'] = '';
if (!isset($data['billing_country'])) $data['billing_country'] = '';
if (!isset($data['billing_state'])) $data['billing_state'] = '';
if (!isset($data['billing_email'])) $data['billing_email'] = '';
if (!isset($data['billing_phone'])) $data['billing_phone'] = '';
if (!isset($data['shipping_first_name'])) $data['shipping_first_name'] = '';
if (!isset($data['shipping_last_name'])) $data['shipping_last_name'] = '';
if (!isset($data['shipping_company'])) $data['shipping_company'] = '';
if (!isset($data['shipping_address_1'])) $data['shipping_address_1'] = '';
if (!isset($data['shipping_address_2'])) $data['shipping_address_2'] = '';
if (!isset($data['shipping_city'])) $data['shipping_city'] = '';
if (!isset($data['shipping_postcode'])) $data['shipping_postcode'] = '';
if (!isset($data['shipping_country'])) $data['shipping_country'] = '';
if (!isset($data['shipping_state'])) $data['shipping_state'] = '';
$data['customer_user'] = (int) get_post_meta($post->ID, 'customer_user', true);
$order_status = wp_get_post_terms($post->ID, 'shop_order_status');
if ($order_status) :
$order_status = current($order_status);
$data['order_status'] = $order_status->slug;
else :
$data['order_status'] = 'pending';
endif;
if (!isset($post->post_title) || empty($post->post_title)) :
$order_title = 'Order';
else :
$order_title = $post->post_title;
endif;
?>
<style type="text/css">
#titlediv, #major-publishing-actions, #minor-publishing-actions { display:none }
</style>
<div class="panel-wrap jigoshop">
<input name="post_title" type="hidden" value="<?php echo $order_title; ?>" />
<input name="post_status" type="hidden" value="publish" />
<ul class="product_data_tabs tabs" style="display:none;">
<li class="active"><a href="#order_data"><?php _e('Order', 'jigoshop'); ?></a></li>
<li><a href="#order_customer_billing_data"><?php _e('Customer Billing Address', 'jigoshop'); ?></a></li>
<li><a href="#order_customer_shipping_data"><?php _e('Customer Shipping Address', 'jigoshop'); ?></a></li>
</ul>
<div id="order_data" class="panel jigoshop_options_panel">
<p class="form-field"><label for="order_status"><?php _e('Order status:', 'jigoshop') ?></label>
<select id="order_status" name="order_status">
<?php
$statuses = (array) get_terms('shop_order_status', array('hide_empty' => 0, 'orderby' => 'id'));
foreach ($statuses as $status) :
echo '<option value="'.$status->slug.'" ';
if ($status->slug==$data['order_status']) echo 'selected="selected"';
echo '>'.$status->name.'</option>';
endforeach;
?>
</select></p>
<p class="form-field"><label for="customer_user"><?php _e('Customer:', 'jigoshop') ?></label>
<select id="customer_user" name="customer_user">
<option value=""><?php _e('Guest', 'jigoshop') ?></option>
<?php
$users = $wpdb->get_col( $wpdb->prepare("SELECT $wpdb->users.ID FROM $wpdb->users ORDER BY %s ASC", 'display_name' ));
foreach ( $users as $user_id ) :
$user = get_userdata( $user_id );
echo '<option value="'.$user->ID.'" ';
if ($user->ID==$data['customer_user']) echo 'selected="selected"';
echo '>' . $user->display_name . ' ('.$user->user_email.')</option>';
endforeach;
?>
</select></p>
<p class="form-field"><label for="excerpt"><?php _e('Customer Note:', 'jigoshop') ?></label>
<textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt" placeholder="<?php _e('Customer\'s notes about the order', 'jigoshop'); ?>"><?php echo $post->post_excerpt; ?></textarea></p>
</div>
<div id="order_customer_billing_data" class="panel jigoshop_options_panel"><?php
// First Name
$field = array( 'id' => 'billing_first_name', 'label' => 'First Name:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Last Name
$field = array( 'id' => 'billing_last_name', 'label' => 'Last Name:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Company
$field = array( 'id' => 'billing_company', 'label' => 'Company:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Address 1
$field = array( 'id' => 'billing_address_1', 'label' => 'Address 1:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Address 2
$field = array( 'id' => 'billing_address_2', 'label' => 'Address 2:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// City
$field = array( 'id' => 'billing_city', 'label' => 'City:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Postcode
$field = array( 'id' => 'billing_postcode', 'label' => 'Postcode:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Country
$field = array( 'id' => 'billing_country', 'label' => 'Country:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// State
$field = array( 'id' => 'billing_state', 'label' => 'State/County:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Email
$field = array( 'id' => 'billing_email', 'label' => 'Email Address:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Tel
$field = array( 'id' => 'billing_phone', 'label' => 'Tel:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
?>
</div>
<div id="order_customer_shipping_data" class="panel jigoshop_options_panel">
<p class="form-field"><button class="button billing-same-as-shipping"><?php _e('Copy billing address to shipping address', 'jigoshop'); ?></button></p>
<?php
// First Name
$field = array( 'id' => 'shipping_first_name', 'label' => 'First Name:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Last Name
$field = array( 'id' => 'shipping_last_name', 'label' => 'Last Name:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Company
$field = array( 'id' => 'shipping_company', 'label' => 'Company:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Address 1
$field = array( 'id' => 'shipping_address_1', 'label' => 'Address 1:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Address 2
$field = array( 'id' => 'shipping_address_2', 'label' => 'Address 2:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// City
$field = array( 'id' => 'shipping_city', 'label' => 'City:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Postcode
$field = array( 'id' => 'shipping_postcode', 'label' => 'Postcode:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Country
$field = array( 'id' => 'shipping_country', 'label' => 'Country:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// State
$field = array( 'id' => 'shipping_state', 'label' => 'State/County:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
?>
</div>
</div>
<?php
}
/**
* Order items meta box
*
* Displays the order items meta box - for showing individual items in the order
*
* @since 1.0
*/
function jigoshop_order_items_meta_box($post) {
$order_items = (array) maybe_unserialize( get_post_meta($post->ID, 'order_items', true) );
?>
<div class="jigoshop_order_items_wrapper">
<table cellpadding="0" cellspacing="0" class="jigoshop_order_items">
<thead>
<tr>
<th class="product-id"><?php _e('ID', 'jigoshop'); ?></th>
<th class="variation-id"><?php _e('Variation ID', 'jigoshop'); ?></th>
<th class="product-sku"><?php _e('SKU', 'jigoshop'); ?></th>
<th class="name"><?php _e('Name', 'jigoshop'); ?></th>
<th class="variation"><?php _e('Variation', 'jigoshop'); ?></th>
<th class="meta"><?php _e('Order Item Meta', 'jigoshop'); ?></th>
<?php do_action('jigoshop_admin_order_item_headers'); ?>
<th class="quantity"><?php _e('Quantity', 'jigoshop'); ?></th>
<th class="cost"><?php _e('Cost', 'jigoshop'); ?></th>
<th class="tax"><?php _e('Tax Rate', 'jigoshop'); ?></th>
<th class="center" width="1%"><?php _e('Remove', 'jigoshop'); ?></th>
</tr>
</thead>
<tbody id="order_items_list">
<?php if (sizeof($order_items)>0 && isset($order_items[0]['id'])) foreach ($order_items as $item) :
if (isset($item['variation_id']) && $item['variation_id'] > 0) :
$_product = &new jigoshop_product_variation( $item['variation_id'] );
else :
$_product = &new jigoshop_product( $item['id'] );
endif;
?>
<tr class="item">
<td class="product-id"><?php echo $item['id']; ?></td>
<td class="variation-id"><?php if ($item['variation_id']) echo $item['variation_id']; else echo '-'; ?></td>
<td class="product-sku"><?php if ($_product->sku) echo $_product->sku; ?></td>
<td class="name"><a href="<?php echo admin_url('post.php?post='. $_product->id .'&action=edit'); ?>"><?php echo $item['name']; ?></a></td>
<td class="variation"><?php
if (isset($_product->variation_data)) :
echo jigoshop_get_formatted_variation( $_product->variation_data, true );
else :
echo '-';
endif;
?></td>
<td>
<table class="meta" cellspacing="0">
<tfoot>
<tr>
<td colspan="3"><button class="add_meta button"><?php _e('Add meta', 'jigoshop'); ?></button></td>
</tr>
</tfoot>
<tbody></tbody>
</table>
</td>
<?php do_action('jigoshop_admin_order_item_values', $_product, $item); ?>
<td class="quantity"><input type="text" name="item_quantity[]" placeholder="<?php _e('Quantity e.g. 2', 'jigoshop'); ?>" value="<?php echo $item['qty']; ?>" /></td>
<td class="cost"><input type="text" name="item_cost[]" placeholder="<?php _e('Cost per unit ex. tax e.g. 2.99', 'jigoshop'); ?>" value="<?php echo $item['cost']; ?>" /></td>
<td class="tax"><input type="text" name="item_tax_rate[]" placeholder="<?php _e('Tax Rate e.g. 20.0000', 'jigoshop'); ?>" value="<?php echo $item['taxrate']; ?>" /></td>
<td class="center">
<input type="hidden" name="item_id[]" value="<?php echo $item['id']; ?>" />
<input type="hidden" name="item_name[]" value="<?php echo $item['name']; ?>" />
<button type="button" class="remove_row button">&times;</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<p class="buttons">
<select name="item_id" class="item_id">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'post_status' => 'publish',
'post_parent' => 0,
'order' => 'ASC',
'orderby' => 'title'
);
$products = get_posts( $args );
if ($products) foreach ($products as $product) :
$sku = get_post_meta($product->ID, 'SKU', true);
if ($sku) $sku = ' SKU: '.$sku;
echo '<option value="'.$product->ID.'">'.$product->post_title.$sku.' (#'.$product->ID.''.$sku.')</option>';
$args_get_children = array(
'post_type' => array( 'product_variation', 'product' ),
'posts_per_page' => -1,
'order' => 'ASC',
'orderby' => 'title',
'post_parent' => $product->ID
);
if ( $children_products =& get_children( $args_get_children ) ) :
foreach ($children_products as $child) :
echo '<option value="'.$child->ID.'">&nbsp;&nbsp;&mdash;&nbsp;'.$child->post_title.'</option>';
endforeach;
endif;
endforeach;
?>
</select>
<button type="button" class="button button-primary add_shop_order_item"><?php _e('Add item', 'jigoshop'); ?></button>
</p>
<p class="buttons buttons-alt">
<button type="button" class="button button calc_totals"><?php _e('Calculate totals', 'jigoshop'); ?></button>
</p>
<div class="clear"></div>
<?php
}
/**
* Order actions meta box
*
* Displays the order actions meta box - buttons for managing order stock and sending the customer an invoice.
*
* @since 1.0
*/
function jigoshop_order_actions_meta_box($post) {
?>
<ul class="order_actions">
<li><input type="submit" class="button button-primary" name="save" value="<?php _e('Save Order', 'jigoshop'); ?>" /> <?php _e('- Save/update the order.', 'jigoshop'); ?></li>
<li><input type="submit" class="button" name="reduce_stock" value="<?php _e('Reduce stock', 'jigoshop'); ?>" /> <?php _e('- Reduces stock for each item in the order; useful after manually creating an order or manually marking an order as complete/processing after payment.', 'jigoshop'); ?></li>
<li><input type="submit" class="button" name="restore_stock" value="<?php _e('Restore stock', 'jigoshop'); ?>" /> <?php _e('- Restores stock for each item in the order; useful after refunding or canceling the entire order.', 'jigoshop'); ?></li>
<li><input type="submit" class="button" name="invoice" value="<?php _e('Email invoice', 'jigoshop'); ?>" /> <?php _e('- Emails the customer order details and a payment link.', 'jigoshop'); ?></li>
<li>
<?php
if ( current_user_can( "delete_post", $post->ID ) ) {
if ( !EMPTY_TRASH_DAYS )
$delete_text = __('Delete Permanently');
else
$delete_text = __('Move to Trash');
?>
<a class="submitdelete deletion" href="<?php echo get_delete_post_link($post->ID); ?>"><?php echo $delete_text; ?></a><?php
} ?>
</li>
</ul>
<?php
}
/**
* Order totals meta box
*
* Displays the order totals meta box
*
* @since 1.0
*/
function jigoshop_order_totals_meta_box($post) {
$data = maybe_unserialize( get_post_meta($post->ID, 'order_data', true) );
if (!isset($data['shipping_method'])) $data['shipping_method'] = '';
if (!isset($data['payment_method'])) $data['payment_method'] = '';
if (!isset($data['order_subtotal'])) $data['order_subtotal'] = '';
if (!isset($data['order_shipping'])) $data['order_shipping'] = '';
if (!isset($data['order_discount'])) $data['order_discount'] = '';
if (!isset($data['order_tax'])) $data['order_tax'] = '';
if (!isset($data['order_total'])) $data['order_total'] = '';
if (!isset($data['order_shipping_tax'])) $data['order_shipping_tax'] = '';
?>
<dl class="totals">
<dt><?php _e('Subtotal:', 'jigoshop'); ?></dt>
<dd><input type="text" id="order_subtotal" name="order_subtotal" placeholder="0.00 <?php _e('(ex. tax)', 'jigoshop'); ?>" value="<?php echo $data['order_subtotal']; ?>" class="first" /></dd>
<dt><?php _e('Shipping &amp; Handling:', 'jigoshop'); ?></dt>
<dd><input type="text" id="order_shipping" name="order_shipping" placeholder="0.00 <?php _e('(ex. tax)', 'jigoshop'); ?>" value="<?php echo $data['order_shipping']; ?>" class="first" /> <input type="text" name="shipping_method" id="shipping_method" value="<?php echo $data['shipping_method']; ?>" class="last" placeholder="<?php _e('Shipping method...', 'jigoshop'); ?>" /></dd>
<dt><?php _e('Order shipping tax:', 'jigoshop'); ?></dt>
<dd><input type="text" id="order_shipping_tax" name="order_shipping_tax" placeholder="0.00" value="<?php echo $data['order_shipping_tax']; ?>" class="first" /></dd>
<dt><?php _e('Tax:', 'jigoshop'); ?></dt>
<dd><input type="text" id="order_tax" name="order_tax" placeholder="0.00" value="<?php echo $data['order_tax']; ?>" class="first" /></dd>
<dt><?php _e('Discount:', 'jigoshop'); ?></dt>
<dd><input type="text" id="order_discount" name="order_discount" placeholder="0.00" value="<?php echo $data['order_discount']; ?>" /></dd>
<dt><?php _e('Total:', 'jigoshop'); ?></dt>
<dd><input type="text" id="order_total" name="order_total" placeholder="0.00" value="<?php echo $data['order_total']; ?>" class="first" /> <input type="text" name="payment_method" id="payment_method" value="<?php echo $data['payment_method']; ?>" class="last" placeholder="<?php _e('Payment method...', 'jigoshop'); ?>" /></dd>
</dl>
<div class="clear"></div>
<?php
}

View File

@ -1,211 +0,0 @@
<?php
/**
* Product Data Save
*
* Function for processing and storing all product data.
*
* @author Jigowatt
* @category Admin Write Panels
* @package JigoShop
*/
add_action('jigoshop_process_product_meta', 'jigoshop_process_product_meta', 1, 2);
function jigoshop_process_product_meta( $post_id, $post ) {
global $wpdb;
$jigoshop_errors = array();
// Get old data + attributes
$data = (array) maybe_unserialize( get_post_meta($post_id, 'product_data', true) );
$attributes = (array) maybe_unserialize( get_post_meta($post_id, 'product_attributes', true) );
// Add/Replace data to array
$data['regular_price'] = stripslashes( $_POST['regular_price'] );
$data['sale_price'] = stripslashes( $_POST['sale_price'] );
$data['weight'] = stripslashes( $_POST['weight'] );
$data['tax_status'] = stripslashes( $_POST['tax_status'] );
$data['tax_class'] = stripslashes( $_POST['tax_class'] );
if (isset($_POST['stock_status'])) $data['stock_status'] = stripslashes( $_POST['stock_status'] );
// Attributes
$attributes = array();
//var_dump($_POST['attribute_values']);
if (isset($_POST['attribute_names'])) :
$attribute_names = $_POST['attribute_names'];
$attribute_values = $_POST['attribute_values'];
if (isset($_POST['attribute_visibility'])) $attribute_visibility = $_POST['attribute_visibility'];
if (isset($_POST['attribute_variation'])) $attribute_variation = $_POST['attribute_variation'];
$attribute_is_taxonomy = $_POST['attribute_is_taxonomy'];
$attribute_position = $_POST['attribute_position'];
for ($i=0; $i<sizeof($attribute_names); $i++) :
if (!($attribute_names[$i])) continue;
if (isset($attribute_visibility[$i])) $visible = 'yes'; else $visible = 'no';
if (isset($attribute_variation[$i])) $variation = 'yes'; else $variation = 'no';
if ($attribute_is_taxonomy[$i]) $is_taxonomy = 'yes'; else $is_taxonomy = 'no';
if (is_array($attribute_values[$i])) :
$attribute_values[$i] = array_map('htmlspecialchars', array_map('stripslashes', $attribute_values[$i]));
else :
$attribute_values[$i] = trim(htmlspecialchars(stripslashes($attribute_values[$i])));
endif;
if (empty($attribute_values[$i]) || ( is_array($attribute_values[$i]) && sizeof($attribute_values[$i])==0) ) :
if ($is_taxonomy=='yes' && taxonomy_exists('product_attribute_'.strtolower(sanitize_title($attribute_names[$i])))) :
wp_set_object_terms( $post_id, 0, 'product_attribute_'.strtolower(sanitize_title($attribute_names[$i])) );
endif;
continue;
endif;
$attributes[ strtolower(sanitize_title( $attribute_names[$i] )) ] = array(
'name' => htmlspecialchars(stripslashes($attribute_names[$i])),
'value' => $attribute_values[$i],
'position' => $attribute_position[$i],
'visible' => $visible,
'variation' => $variation,
'is_taxonomy' => $is_taxonomy
);
if ($is_taxonomy=='yes') :
// Update post terms
$tax = $attribute_names[$i];
$value = $attribute_values[$i];
if (taxonomy_exists('product_attribute_'.strtolower(sanitize_title($tax)))) :
wp_set_object_terms( $post_id, $value, 'product_attribute_'.strtolower(sanitize_title($tax)) );
endif;
endif;
endfor;
endif;
if (!function_exists('attributes_cmp')) {
function attributes_cmp($a, $b) {
if ($a['position'] == $b['position']) {
return 0;
}
return ($a['position'] < $b['position']) ? -1 : 1;
}
}
uasort($attributes, 'attributes_cmp');
// Product type
$product_type = sanitize_title( stripslashes( $_POST['product-type'] ) );
if( !$product_type ) $product_type = 'simple';
wp_set_object_terms($post_id, $product_type, 'product_type');
// visibility
$visibility = stripslashes( $_POST['visibility'] );
update_post_meta( $post_id, 'visibility', $visibility );
// Featured
$featured = stripslashes( $_POST['featured'] );
update_post_meta( $post_id, 'featured', $featured );
// Unique SKU
$SKU = get_post_meta($post_id, 'SKU', true);
$new_sku = stripslashes( $_POST['sku'] );
if ($new_sku!==$SKU) :
if ($new_sku && !empty($new_sku)) :
if ($wpdb->get_var("SELECT * FROM $wpdb->postmeta WHERE meta_key='SKU' AND meta_value='".$new_sku."';") || $wpdb->get_var("SELECT * FROM $wpdb->posts WHERE ID='".$new_sku."' AND ID!=".$post_id.";")) :
$jigoshop_errors[] = __('Product SKU must be unique.', 'jigoshop');
else :
update_post_meta( $post_id, 'SKU', $new_sku );
endif;
else :
update_post_meta( $post_id, 'SKU', '' );
endif;
endif;
// Sales and prices
if ($product_type!=='grouped') :
$date_from = (isset($_POST['sale_price_dates_from'])) ? $_POST['sale_price_dates_from'] : '';
$date_to = (isset($_POST['sale_price_dates_to'])) ? $_POST['sale_price_dates_to'] : '';
// Dates
if ($date_from) :
update_post_meta( $post_id, 'sale_price_dates_from', strtotime($date_from) );
else :
update_post_meta( $post_id, 'sale_price_dates_from', '' );
endif;
if ($date_to) :
update_post_meta( $post_id, 'sale_price_dates_to', strtotime($date_to) );
else :
update_post_meta( $post_id, 'sale_price_dates_to', '' );
endif;
if ($date_to && !$date_from) :
update_post_meta( $post_id, 'sale_price_dates_from', strtotime('NOW') );
endif;
// Update price if on sale
if ($data['sale_price'] && $date_to == '' && $date_from == '') :
update_post_meta( $post_id, 'price', $data['sale_price'] );
else :
update_post_meta( $post_id, 'price', $data['regular_price'] );
endif;
if ($date_from && strtotime($date_from) < strtotime('NOW')) :
update_post_meta( $post_id, 'price', $data['sale_price'] );
endif;
if ($date_to && strtotime($date_to) < strtotime('NOW')) :
update_post_meta( $post_id, 'price', $data['regular_price'] );
update_post_meta( $post_id, 'sale_price_dates_from', '');
update_post_meta( $post_id, 'sale_price_dates_to', '');
endif;
else :
$data['sale_price'] = '';
$data['regular_price'] = '';
update_post_meta( $post_id, 'sale_price_dates_from', '' );
update_post_meta( $post_id, 'sale_price_dates_to', '' );
update_post_meta( $post_id, 'price', '' );
endif;
// Stock Data
if (get_option('jigoshop_manage_stock')=='yes') :
// Manage Stock Checkbox
if ($product_type!=='grouped' && isset($_POST['manage_stock']) && $_POST['manage_stock']) :
update_post_meta( $post_id, 'stock', $_POST['stock'] );
$data['manage_stock'] = 'yes';
$data['backorders'] = stripslashes( $_POST['backorders'] );
else :
update_post_meta( $post_id, 'stock', '0' );
$data['manage_stock'] = 'no';
$data['backorders'] = 'no';
endif;
endif;
// Apply filters to data
$data = apply_filters( 'process_product_meta', $data, $post_id );
// Apply filter to data for product type
$data = apply_filters( 'filter_product_meta_' . $product_type, $data, $post_id );
// Do action for product type
do_action( 'process_product_meta_' . $product_type, $data, $post_id );
// Save
update_post_meta( $post_id, 'product_attributes', $attributes );
update_post_meta( $post_id, 'product_data', $data );
update_option('jigoshop_errors', $jigoshop_errors);
}

View File

@ -1,364 +0,0 @@
<?php
/**
* Product Data
*
* Function for displaying the product data meta boxes
*
* @author Jigowatt
* @category Admin Write Panels
* @package JigoShop
*/
/**
* Product data box
*
* Displays the product data box, tabbed, with several panels covering price, stock etc
*
* @since 1.0
*/
function jigoshop_product_data_box() {
global $post, $wpdb, $thepostid;
add_action('admin_footer', 'jigoshop_meta_scripts');
wp_nonce_field( 'jigoshop_save_data', 'jigoshop_meta_nonce' );
$data = (array) maybe_unserialize( get_post_meta($post->ID, 'product_data', true) );
$featured = (string) get_post_meta( $post->ID, 'featured', true );
$visibility = (string) get_post_meta( $post->ID, 'visibility', true);
if (!isset($data['weight'])) $data['weight'] = '';
if (!isset($data['regular_price'])) $data['regular_price'] = '';
if (!isset($data['sale_price'])) $data['sale_price'] = '';
$thepostid = $post->ID;
?>
<div class="panel-wrap product_data">
<ul class="product_data_tabs tabs" style="display:none;">
<li class="active"><a href="#general_product_data"><?php _e('General', 'jigoshop'); ?></a></li>
<li class="pricing_tab"><a href="#pricing_product_data"><?php _e('Pricing', 'jigoshop'); ?></a></li>
<?php if (get_option('jigoshop_manage_stock')=='yes') : ?><li class="inventory_tab"><a href="#inventory_product_data"><?php _e('Inventory', 'jigoshop'); ?></a></li><?php endif; ?>
<li><a href="#jigoshop_attributes"><?php _e('Attributes', 'jigoshop'); ?></a></li>
<?php do_action('product_write_panel_tabs'); ?>
</ul>
<div id="general_product_data" class="panel jigoshop_options_panel"><?php
// Product Type
if ($terms = wp_get_object_terms( $thepostid, 'product_type' )) $product_type = current($terms)->slug; else $product_type = 'simple';
$field = array( 'id' => 'product-type', 'label' => __('Product Type', 'jigoshop') );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].' <em class="req" title="'.__('Required', 'jigoshop') . '">*</em></label><select id="'.$field['id'].'" name="'.$field['id'].'">';
echo '<option value="simple" '; if ($product_type=='simple') echo 'selected="selected"'; echo '>'.__('Simple','jigoshop').'</option>';
do_action('product_type_selector', $product_type);
echo '</select></p>';
// List Grouped products
$posts_in = (array) get_objects_in_term( get_term_by( 'slug', 'grouped', 'product_type' )->term_id, 'product_type' );
$posts_in = array_unique($posts_in);
$field = array( 'id' => 'parent_id', 'label' => __('Parent post', 'jigoshop') );
echo '<p class="form-field parent_id_field"><label for="'.$field['id'].'">'.$field['label'].'</label><select id="'.$field['id'].'" name="'.$field['id'].'"><option value="">'.__('Choose a grouped product&hellip;', 'jigoshop').'</option>';
if (sizeof($posts_in)>0) :
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'numberposts' => -1,
'orderby' => 'title',
'order' => 'asc',
'post_parent' => 0,
'include' => $posts_in,
);
$grouped_products = get_posts($args);
$loop = 0;
if ($grouped_products) : foreach ($grouped_products as $product) :
if ($product->ID==$post->ID) continue;
echo '<option value="'.$product->ID.'" ';
if ($post->post_parent==$product->ID) echo 'selected="selected"';
echo '>'.$product->post_title.'</option>';
endforeach; endif;
endif;
echo '</select></p>';
// Ordering
$menu_order = $post->menu_order;
$field = array( 'id' => 'menu_order', 'label' => _x('Post Order', 'ordering', 'jigoshop') );
echo '<p class="form-field menu_order_field">
<label for="'.$field['id'].'">'.$field['label'].':</label>
<input type="text" class="short" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$menu_order.'" /></p>';
// Summary
echo '<p class="form-field"><label for="excerpt">' . __('Summary', 'jigoshop') . ':</label>
<textarea name="excerpt" id="excerpt" placeholder="' . __('Add a summary for your product &ndash; this is a quick description to encourage users to view the product.', 'jigoshop') . '">'.esc_html( $post->post_excerpt ).'</textarea></p>';
// SKU
$field = array( 'id' => 'sku', 'label' => __('SKU', 'jigoshop') );
$SKU = get_post_meta($thepostid, 'SKU', true);
if( get_option('jigoshop_enable_sku', true) !== 'no' ) :
echo '<p class="form-field">
<label for="'.$field['id'].'">'.$field['label'].':</label>
<input type="text" class="short" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$SKU.'" /> <span class="description">' . __('Leave blank to use product ID', 'jigoshop') . '</span></p>';
else:
echo '<input type="hidden" name="'.$field['id'].'" value="'.$SKU.'" />';
endif;
// Weight
$field = array( 'id' => 'weight', 'label' => __('Weight', 'jigoshop') . ' ('.get_option('jigoshop_weight_unit').'):' );
if( get_option('jigoshop_enable_weight', true) !== 'no' ) :
echo '<p class="form-field">
<label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" class="short" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" placeholder="0.00" /></p>';
else:
echo '<input type="hidden" name="'.$field['id'].'" value="'.$data[$field['id']].'" />';
endif;
// Featured
$field = array( 'id' => 'featured', 'label' => __('Featured?', 'jigoshop') );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label><select name="'.$field['id'].'">';
echo '<option value="no" '; if (isset($featured) && $featured=='no') echo 'selected="selected"'; echo '>' . __('No', 'jigoshop') . '</option>';
echo '<option value="yes" '; if (isset($featured) && $featured=='yes') echo 'selected="selected"'; echo '>' . __('Yes', 'jigoshop') . '</option>';
echo '</select></p>';
// Visibility
$field = array( 'id' => 'visibility', 'label' => __('Visibility', 'jigoshop') );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].':</label><select name="'.$field['id'].'">';
echo '<option value="visible" '; if (isset($visibility) && $visibility=='visible') echo 'selected="selected"'; echo '>' . __('Catalog &amp; Search', 'jigoshop') . '</option>';
echo '<option value="catalog" '; if (isset($visibility) && $visibility=='catalog') echo 'selected="selected"'; echo '>' . __('Catalog', 'jigoshop') . '</option>';
echo '<option value="search" '; if (isset($visibility) && $visibility=='search') echo 'selected="selected"'; echo '>' . __('Search', 'jigoshop') . '</option>';
echo '<option value="hidden" '; if (isset($visibility) && $visibility=='hidden') echo 'selected="selected"'; echo '>' . __('Hidden', 'jigoshop') . '</option>';
echo '</select></p>';
?>
</div>
<div id="pricing_product_data" class="panel jigoshop_options_panel">
<?php
// Price
$field = array( 'id' => 'regular_price', 'label' => __('Regular Price', 'jigoshop') . ' ('.get_jigoshop_currency_symbol().'):' );
echo ' <p class="form-field">
<label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" class="short" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" placeholder="0.00" /></p>';
// Special Price
$field = array( 'id' => 'sale_price', 'label' => __('Sale Price', 'jigoshop') . ' ('.get_jigoshop_currency_symbol().'):' );
echo ' <p class="form-field">
<label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" class="short" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" placeholder="0.00" /></p>';
// Special Price date range
$field = array( 'id' => 'sale_price_dates', 'label' => __('Sale Price Dates', 'jigoshop') );
$sale_price_dates_from = get_post_meta($thepostid, 'sale_price_dates_from', true);
$sale_price_dates_to = get_post_meta($thepostid, 'sale_price_dates_to', true);
echo ' <p class="form-field">
<label for="'.$field['id'].'_from">'.$field['label'].':</label>
<input type="text" class="short date-pick" name="'.$field['id'].'_from" id="'.$field['id'].'_from" value="';
if ($sale_price_dates_from) echo date('Y-m-d', $sale_price_dates_from);
echo '" placeholder="' . __('From&hellip;', 'jigoshop') . '" maxlength="10" />
<input type="text" class="short date-pick" name="'.$field['id'].'_to" id="'.$field['id'].'_to" value="';
if ($sale_price_dates_to) echo date('Y-m-d', $sale_price_dates_to);
echo '" placeholder="' . __('To&hellip;', 'jigoshop') . '" maxlength="10" />
<span class="description">' . __('Date format', 'jigoshop') . ': <code>YYYY-MM-DD</code></span>
</p>';
// Tax
$_tax = new jigoshop_tax();
$field = array( 'id' => 'tax_status', 'label' => __('Tax Status', 'jigoshop') );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].':</label><select name="'.$field['id'].'">';
echo '<option value="taxable" '; if (isset($data[$field['id']]) && $data[$field['id']]=='taxable') echo 'selected="selected"'; echo '>' . __('Taxable', 'jigoshop') . '</option>';
echo '<option value="shipping" '; if (isset($data[$field['id']]) && $data[$field['id']]=='shipping') echo 'selected="selected"'; echo '>' . __('Shipping only', 'jigoshop') . '</option>';
echo '<option value="none" '; if (isset($data[$field['id']]) && $data[$field['id']]=='none') echo 'selected="selected"'; echo '>' . __('None', 'jigoshop') . '</option>';
echo '</select></p>';
$field = array( 'id' => 'tax_class', 'label' => __('Tax Class', 'jigoshop') );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].':</label><select name="'.$field['id'].'">';
echo '<option value="" '; if (isset($data[$field['id']]) && $data[$field['id']]=='') echo 'selected="selected"'; echo '>'.__('Standard', 'jigoshop').'</option>';
$tax_classes = $_tax->get_tax_classes();
if ($tax_classes) foreach ($tax_classes as $class) :
echo '<option value="'.sanitize_title($class).'" '; if (isset($data[$field['id']]) && $data[$field['id']]==sanitize_title($class)) echo 'selected="selected"'; echo '>'.$class.'</option>';
endforeach;
echo '</select></p>';
?>
</div>
<?php if (get_option('jigoshop_manage_stock')=='yes') : ?>
<div id="inventory_product_data" class="panel jigoshop_options_panel">
<?php
// manage stock
$field = array( 'id' => 'manage_stock', 'label' => __('Manage stock?', 'jigoshop') );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].' <em class="req" title="' .__('Required', 'jigoshop') . '">*</em></label><input type="checkbox" class="checkbox" name="'.$field['id'].'" id="'.$field['id'].'"';
if (isset($data[$field['id']]) && $data[$field['id']]=='yes') echo 'checked="checked"';
echo ' /></p>';
// Stock status
$field = array( 'id' => 'stock_status', 'label' => 'Stock status:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].' <em class="req" title="'.__('Required', 'jigoshop') . '">*</em></label><select name="'.$field['id'].'">';
echo '<option value="instock" '; if (isset($data[$field['id']]) && $data[$field['id']]=='instock') echo 'selected="selected"'; echo '>In stock</option>';
echo '<option value="outofstock" '; if (isset($data[$field['id']]) && $data[$field['id']]=='outofstock') echo 'selected="selected"'; echo '>Out of stock</option>';
echo '</select></p>';
echo '<div class="stock_fields">';
// Stock
$field = array( 'id' => 'stock', 'label' => __('Stock Qty', 'jigoshop') );
echo ' <p class="form-field">
<label for="'.$field['id'].'">'.$field['label'].': <em class="req" title="'.__('Required', 'jigoshop') . '">*</em></label>
<input type="text" class="short" name="'.$field['id'].'" id="'.$field['id'].'" value="';
$stock = get_post_meta($post->ID, 'stock', true);
if (!$stock) $stock = 0;
echo $stock;
echo '" />
</p>';
// Backorders?
$field = array( 'id' => 'backorders', 'label' => __('Allow Backorders?', 'jigoshop') );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].' <em class="req" title="'.__('Required', 'jigoshop') . '">*</em></label><select name="'.$field['id'].'">';
echo '<option value="no" '; if (isset($data[$field['id']]) && $data[$field['id']]=='no') echo 'selected="selected"'; echo '>' . __('Do not allow', 'jigoshop') . '</option>';
echo '<option value="notify" '; if (isset($data[$field['id']]) && $data[$field['id']]=='notify') echo 'selected="selected"'; echo '>' . __('Allow, but notify customer', 'jigoshop') . '</option>';
echo '<option value="yes" '; if (isset($data[$field['id']]) && $data[$field['id']]=='yes') echo 'selected="selected"'; echo '>' . __('Allow', 'jigoshop') . '</option>';
echo '</select></p>';
echo '</div>';
?>
</div>
<?php endif; ?>
<div id="jigoshop_attributes" class="panel">
<div class="jigoshop_attributes_wrapper">
<table cellpadding="0" cellspacing="0" class="jigoshop_attributes">
<thead>
<tr>
<th class="center" width="60"><?php _e('Order', 'jigoshop'); ?></th>
<th width="180"><?php _e('Name', 'jigoshop'); ?></th>
<th><?php _e('Value', 'jigoshop'); ?></th>
<th class="center" width="1%"><?php _e('Visible?', 'jigoshop'); ?></th>
<th class="center" width="1%"><?php _e('Variation?', 'jigoshop'); ?></th>
<th class="center" width="1%"><?php _e('Remove', 'jigoshop'); ?></th>
</tr>
</thead>
<tbody id="attributes_list">
<?php
$attribute_taxonomies = jigoshop::$attribute_taxonomies;
$attributes = maybe_unserialize( get_post_meta($post->ID, 'product_attributes', true) );
$i = -1;
// Taxonomies
if ( $attribute_taxonomies ) :
foreach ($attribute_taxonomies as $tax) : $i++;
$attribute_nicename = strtolower(sanitize_title($tax->attribute_name));
if (isset($attributes[$attribute_nicename])) $attribute = $attributes[$attribute_nicename];
if (isset($attribute['visible']) && $attribute['visible']=='yes') $checked = 'checked="checked"'; else $checked = '';
if (isset($attribute['variation']) && $attribute['variation']=='yes') $checked2 = 'checked="checked"'; else $checked2 = '';
$values = wp_get_post_terms( $thepostid, 'product_attribute_'.strtolower(sanitize_title($tax->attribute_name)) );
$value = array();
if (!is_wp_error($values) && $values) :
foreach ($values as $v) :
$value[] = $v->slug;
endforeach;
endif;
?><tr class="taxonomy <?php echo strtolower(sanitize_title($tax->attribute_name)); ?>" rel="<?php if (isset($attribute['position'])) echo $attribute['position']; else echo '0'; ?>" <?php if (!$value || sizeof($value)==0) echo 'style="display:none"'; ?>>
<td class="center">
<button type="button" class="move_up button">&uarr;</button><button type="button" class="move_down button">&darr;</button>
<input type="hidden" name="attribute_position[<?php echo $i; ?>]" class="attribute_position" value="<?php if (isset($attribute['position'])) echo $attribute['position']; else echo '0'; ?>" />
</td>
<td class="name">
<?php echo $tax->attribute_name; ?>
<input type="hidden" name="attribute_names[<?php echo $i; ?>]" value="<?php echo $tax->attribute_name; ?>" />
<input type="hidden" name="attribute_is_taxonomy[<?php echo $i; ?>]" value="1" />
</td>
<td>
<?php if ($tax->attribute_type=="select" || $tax->attribute_type=="multiselect") : ?>
<select <?php if ($tax->attribute_type=="multiselect") echo 'multiple="multiple" class="multiselect" name="attribute_values['.$i.'][]"'; else echo 'name="attribute_values['.$i.']"'; ?>>
<?php if ($tax->attribute_type=="select") : ?><option value=""><?php _e('Choose an option&hellip;', 'jigoshop'); ?></option><?php endif; ?>
<?php
if (taxonomy_exists('product_attribute_'.strtolower(sanitize_title($tax->attribute_name)))) :
$terms = get_terms( 'product_attribute_'.strtolower(sanitize_title($tax->attribute_name)), 'orderby=name&hide_empty=0' );
if ($terms) :
foreach ($terms as $term) :
echo '<option value="'.$term->slug.'" ';
if (in_array($term->slug, $value)) echo 'selected="selected"';
echo '>'.$term->name.'</option>';
endforeach;
endif;
endif;
?>
</select>
<?php elseif ($tax->attribute_type=="text") : ?>
<input type="text" name="attribute_values[<?php echo $i; ?>]" value="<?php if (isset($attribute['value'])) echo $attribute['value']; ?>" placeholder="<?php _e('Comma separate terms', 'jigoshop'); ?>" />
<?php endif; ?>
</td>
<td class="center"><input type="checkbox" <?php echo $checked; ?> name="attribute_visibility[<?php echo $i; ?>]" value="1" /></td>
<td class="center"><input type="checkbox" <?php echo $checked2; ?> name="attribute_variation[<?php echo $i; ?>]" value="1" /></td>
<td class="center"><button type="button" class="hide_row button">&times;</button></td>
</tr><?php
endforeach;
endif;
// Attributes
if ($attributes && sizeof($attributes)>0) foreach ($attributes as $attribute) :
if (isset($attribute['is_taxonomy']) && $attribute['is_taxonomy']=='yes') continue;
$i++;
if (isset($attribute['visible']) && $attribute['visible']=='yes') $checked = 'checked="checked"'; else $checked = '';
if (isset($attribute['variation']) && $attribute['variation']=='yes') $checked2 = 'checked="checked"'; else $checked2 = '';
?><tr rel="<?php if (isset($attribute['position'])) echo $attribute['position']; else echo '0'; ?>">
<td class="center">
<button type="button" class="move_up button">&uarr;</button><button type="button" class="move_down button">&darr;</button>
<input type="hidden" name="attribute_position[<?php echo $i; ?>]" class="attribute_position" value="<?php if (isset($attribute['position'])) echo $attribute['position']; else echo '0'; ?>" />
</td>
<td>
<input type="text" name="attribute_names[<?php echo $i; ?>]" value="<?php echo $attribute['name']; ?>" />
<input type="hidden" name="attribute_is_taxonomy[<?php echo $i; ?>]" value="0" />
</td>
<td><input type="text" name="attribute_values[<?php echo $i; ?>]" value="<?php echo $attribute['value']; ?>" /></td>
<td class="center"><input type="checkbox" <?php echo $checked; ?> name="attribute_visibility[<?php echo $i; ?>]" value="1" /></td>
<td class="center"><input type="checkbox" <?php echo $checked2; ?> name="attribute_variation[<?php echo $i; ?>]" value="1" /></td>
<td class="center"><button type="button" class="remove_row button">&times;</button></td>
</tr><?php
endforeach;
?>
</tbody>
</table>
</div>
<button type="button" class="button button-primary add_attribute"><?php _e('Add', 'jigoshop'); ?></button>
<select name="attribute_taxonomy" class="attribute_taxonomy">
<option value=""><?php _e('Custom product attribute', 'jigoshop'); ?></option>
<?php
if ( $attribute_taxonomies ) :
foreach ($attribute_taxonomies as $tax) :
echo '<option value="'.strtolower(sanitize_title($tax->attribute_name)).'">'.$tax->attribute_name.'</option>';
endforeach;
endif;
?>
</select>
<div class="clear"></div>
</div>
<?php do_action('product_write_panels'); ?>
</div>
<?php
}

View File

@ -1,32 +0,0 @@
<?php
/**
* Product Type
*
* Function for displaying the product type meta (specific) meta boxes
*
* @author Jigowatt
* @category Admin Write Panels
* @package JigoShop
*/
foreach(glob( dirname(__FILE__)."/product-types/*.php" ) as $filename) include_once($filename);
/**
* Product type meta box
*
* Display the product type meta box which contains a hook for product types to hook into and show their options
*
* @since 1.0
*/
function jigoshop_product_type_options_box() {
global $post;
?>
<div id="simple_product_options" class="panel jigoshop_options_panel">
<?php
_e('Simple products have no specific options.', 'jigoshop');
?>
</div>
<?php
do_action('jigoshop_product_type_options_box');
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

View File

@ -1,633 +0,0 @@
<?php
/*
Plugin Name: Jigoshop - WordPress eCommerce
Plugin URI: http://jigoshop.com
Description: An eCommerce plugin for wordpress.
Version: 0.9.9
Author: Jigowatt
Author URI: http://jigowatt.co.uk
Requires at least: 3.1
Tested up to: 3.1.3
*/
@session_start();
if (!defined("JIGOSHOP_VERSION")) define("JIGOSHOP_VERSION", "0.9.9");
if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n");
load_plugin_textdomain('jigoshop', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
/**
* Installs and upgrades
**/
register_activation_hook( __FILE__, 'install_jigoshop' );
function jigoshop_update_check() {
if (get_site_option('jigoshop_db_version') != JIGOSHOP_VERSION) install_jigoshop();
}
if (is_admin()) add_action('init', 'jigoshop_update_check');
/**
* Include core files and classes
**/
include_once( 'classes/jigoshop.class.php' );
include_once( 'jigoshop_taxonomy.php' );
include_once( 'jigoshop_widgets.php' );
include_once( 'jigoshop_shortcodes.php' );
include_once( 'jigoshop_templates.php' );
include_once( 'jigoshop_template_actions.php' );
include_once( 'jigoshop_emails.php' );
include_once( 'jigoshop_query.php' );
include_once( 'jigoshop_cron.php' );
include_once( 'jigoshop_actions.php' );
include_once( 'gateways/gateways.class.php' );
include_once( 'gateways/gateway.class.php' );
include_once( 'shipping/shipping.class.php' );
include_once( 'shipping/shipping_method.class.php' );
/**
* Include admin area
**/
if (is_admin()) include_once( 'admin/jigoshop-admin.php' );
/**
* Include all classes, dro-ins and shipping/gateways modules
*/
$include_files = array();
// Classes
$include_files = array_merge($include_files, (array) glob( dirname(__FILE__)."/classes/*.php" ));
// Shipping
$include_files = array_merge($include_files, (array) glob( dirname(__FILE__)."/shipping/*.php" ));
// Payment Gateways
$include_files = array_merge($include_files, (array) glob( dirname(__FILE__)."/gateways/*.php" ));
// Drop-ins (addons, premium features etc)
$include_files = array_merge($include_files, (array) glob( dirname(__FILE__)."/drop-ins/*.php" ));
if ($include_files) :
foreach($include_files as $filename) :
if (!empty($filename) && strstr($filename, 'php')) :
include_once($filename);
endif;
endforeach;
endif;
$jigoshop = jigoshop::get();
// Init class singletons
$jigoshop_customer = jigoshop_customer::get(); // Customer class, sorts out session data such as location
$jigoshop_shipping = jigoshop_shipping::get(); // Shipping class. loads and stores shipping methods
$jigoshop_payment_gateways = jigoshop_payment_gateways::get(); // Payment gateways class. loads and stores payment methods
$jigoshop_cart = jigoshop_cart::get(); // Cart class, stores the cart contents
// Constants
if (!defined('JIGOSHOP_USE_CSS')) :
if (get_option('jigoshop_disable_css')=='yes') define('JIGOSHOP_USE_CSS', false);
else define('JIGOSHOP_USE_CSS', true);
endif;
if (!defined('JIGOSHOP_TEMPLATE_URL')) define('JIGOSHOP_TEMPLATE_URL', 'jigoshop/'); // Trailing slash is important :)
/**
* Add post thumbnail support to wordpress
**/
add_theme_support( 'post-thumbnails' );
/**
* Filters and hooks
**/
add_action('init', 'jigoshop_init', 0);
add_action('plugins_loaded', 'jigoshop_shipping::init', 1); // Load shipping methods - some may be added by plugins
add_action('plugins_loaded', 'jigoshop_payment_gateways::init', 1); // Load payment methods - some may be added by plugins
if (get_option('jigoshop_force_ssl_checkout')=='yes') add_action( 'wp_head', 'jigoshop_force_ssl');
add_action( 'wp_footer', 'jigoshop_demo_store' );
add_action( 'wp_footer', 'jigoshop_sharethis' );
/**
* IIS compat fix/fallback
**/
if (!isset($_SERVER['REQUEST_URI'])) {
$_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'],1 );
if (isset($_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'].='?'.$_SERVER['QUERY_STRING']; }
}
/**
* Mail from name/email
**/
add_filter( 'wp_mail_from', 'jigoshop_mail_from' );
add_filter( 'wp_mail_from_name', 'jigoshop_mail_from_name' );
function jigoshop_mail_from_name( $name ) {
$name = get_bloginfo('name');
$name = esc_attr($name);
return $name;
}
function jigoshop_mail_from( $email ) {
$email = get_option('admin_email');
return $email;
}
/**
* Support for Import/Export
*
* WordPress import should work - however, it fails to import custom product attribute taxonomies.
* This code grabs the file before it is imported and ensures the taxonomies are created.
**/
function jigoshop_import_start() {
global $wpdb;
$id = (int) $_POST['import_id'];
$file = get_attached_file( $id );
$parser = new WXR_Parser();
$import_data = $parser->parse( $file );
if (isset($import_data['posts'])) :
$posts = $import_data['posts'];
if ($posts && sizeof($posts)>0) foreach ($posts as $post) :
if ($post['post_type']=='product') :
if ($post['terms'] && sizeof($post['terms'])>0) :
foreach ($post['terms'] as $term) :
$domain = $term['domain'];
if (strstr($domain, 'product_attribute_')) :
// Make sure it exists!
if (!taxonomy_exists( $domain )) :
$nicename = ucfirst(str_replace('product_attribute_', '', $domain));
// Create the taxonomy
$wpdb->insert( $wpdb->prefix . "jigoshop_attribute_taxonomies", array( 'attribute_name' => $nicename, 'attribute_type' => 'text' ), array( '%s', '%s' ) );
// Register the taxonomy now so that the import works!
register_taxonomy( $domain,
array('product'),
array(
'hierarchical' => true,
'labels' => array(
'name' => $nicename,
'singular_name' => $nicename,
'search_items' => __( 'Search ', 'jigoshop') . $nicename,
'all_items' => __( 'All ', 'jigoshop') . $nicename,
'parent_item' => __( 'Parent ', 'jigoshop') . $nicename,
'parent_item_colon' => __( 'Parent ', 'jigoshop') . $nicename . ':',
'edit_item' => __( 'Edit ', 'jigoshop') . $nicename,
'update_item' => __( 'Update ', 'jigoshop') . $nicename,
'add_new_item' => __( 'Add New ', 'jigoshop') . $nicename,
'new_item_name' => __( 'New ', 'jigoshop') . $nicename
),
'show_ui' => false,
'query_var' => true,
'rewrite' => array( 'slug' => strtolower(sanitize_title($nicename)), 'with_front' => false, 'hierarchical' => true ),
)
);
update_option('jigowatt_update_rewrite_rules', '1');
endif;
endif;
endforeach;
endif;
endif;
endforeach;
endif;
}
add_action('import_start', 'jigoshop_import_start');
### Functions #########################################################
function jigoshop_init() {
jigoshop_post_type();
// Image sizes
add_image_size( 'shop_tiny', jigoshop::get_var('shop_tiny_w'), jigoshop::get_var('shop_tiny_h'), 'true' );
add_image_size( 'shop_thumbnail', jigoshop::get_var('shop_thumbnail_w'), jigoshop::get_var('shop_thumbnail_h'), 'true' );
add_image_size( 'shop_small', jigoshop::get_var('shop_small_w'), jigoshop::get_var('shop_small_h'), 'true' );
add_image_size( 'shop_large', jigoshop::get_var('shop_large_w'), jigoshop::get_var('shop_large_h'), 'true' );
// Include template functions here so they are pluggable by themes
include_once( 'jigoshop_template_functions.php' );
@ob_start();
add_role('customer', 'Customer', array(
'read' => true,
'edit_posts' => false,
'delete_posts' => false
));
$css = file_exists(get_stylesheet_directory() . '/jigoshop/style.css') ? get_stylesheet_directory_uri() . '/jigoshop/style.css' : jigoshop::plugin_url() . '/assets/css/frontend.css';
if (JIGOSHOP_USE_CSS) wp_register_style('jigoshop_frontend_styles', $css );
if (is_admin()) :
wp_register_style('jigoshop_admin_styles', jigoshop::plugin_url() . '/assets/css/admin.css');
wp_register_style('jigoshop_admin_datepicker_styles', jigoshop::plugin_url() . '/assets/css/datepicker.css');
wp_enqueue_style('jigoshop_admin_styles');
wp_enqueue_style('jigoshop_admin_datepicker_styles');
else :
wp_register_style( 'jigoshop_fancybox_styles', jigoshop::plugin_url() . '/assets/css/fancybox.css' );
wp_register_style( 'jqueryui_styles', jigoshop::plugin_url() . '/assets/css/ui.css' );
wp_enqueue_style('jigoshop_frontend_styles');
wp_enqueue_style('jigoshop_fancybox_styles');
wp_enqueue_style('jqueryui_styles');
endif;
}
function jigoshop_admin_scripts() {
wp_register_script( 'jigoshop_backend', jigoshop::plugin_url() . '/assets/js/jigoshop_backend.js', 'jquery', '1.0' );
wp_enqueue_script('jigoshop_backend');
}
add_action('admin_print_scripts', 'jigoshop_admin_scripts');
function jigoshop_frontend_scripts() {
wp_register_script( 'jigoshop_frontend', jigoshop::plugin_url() . '/assets/js/jigoshop_frontend.js', 'jquery', '1.0' );
wp_register_script( 'jigoshop_script', jigoshop::plugin_url() . '/assets/js/script.js', 'jquery', '1.0' );
wp_register_script( 'fancybox', jigoshop::plugin_url() . '/assets/js/jquery.fancybox-1.3.4.pack.js', 'jquery', '1.0' );
wp_register_script( 'jqueryui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js', 'jquery', '1.0' );
wp_enqueue_script('jquery');
wp_enqueue_script('jqueryui');
wp_enqueue_script('jigoshop_frontend');
wp_enqueue_script('fancybox');
wp_enqueue_script('jigoshop_script');
/* Script.js variables */
$params = array(
'currency_symbol' => get_jigoshop_currency_symbol(),
'countries' => json_encode(jigoshop_countries::$states),
'select_state_text' => __('Select a state&hellip;', 'jigoshop'),
'state_text' => __('state', 'jigoshop'),
'variation_not_available_text' => __('This variation is not available.', 'jigoshop'),
'plugin_url' => jigoshop::plugin_url(),
'ajax_url' => admin_url('admin-ajax.php'),
'get_variation_nonce' => wp_create_nonce("get-variation"),
'review_order_url' => jigoshop_get_template_file_url('checkout/review_order.php', true),
'option_guest_checkout' => get_option('jigoshop_enable_guest_checkout'),
'checkout_url' => admin_url('admin-ajax.php?action=jigoshop-checkout')
);
if (isset($_SESSION['min_price'])) :
$params['min_price'] = $_SESSION['min_price'];
endif;
if (isset($_SESSION['max_price'])) :
$params['max_price'] = $_SESSION['max_price'];
endif;
if ( is_page(get_option('jigoshop_checkout_page_id')) || is_page(get_option('jigoshop_pay_page_id')) ) :
$params['is_checkout'] = 1;
else :
$params['is_checkout'] = 0;
endif;
wp_localize_script( 'jigoshop_script', 'params', $params );
}
add_action('template_redirect', 'jigoshop_frontend_scripts');
/*
jigoshop_demo_store
Adds a demo store banner to the site
*/
function jigoshop_demo_store() {
if (get_option('jigoshop_demo_store')=='yes') :
echo '<p class="demo_store">'.__('This is a demo store for testing purposes &mdash; no orders shall be fulfilled.', 'jigoshop').'</p>';
endif;
}
/*
jigoshop_sharethis
Adds social sharing code to footer
*/
function jigoshop_sharethis() {
if (is_single() && get_option('jigoshop_sharethis')) :
if (is_ssl()) :
$sharethis = 'https://ws.sharethis.com/button/buttons.js';
else :
$sharethis = 'http://w.sharethis.com/button/buttons.js';
endif;
echo '<script type="text/javascript">var switchTo5x=true;</script><script type="text/javascript" src="'.$sharethis.'"></script><script type="text/javascript">stLight.options({publisher:"'.get_option('jigoshop_sharethis').'"});</script>';
endif;
}
function is_cart() {
if (is_page(get_option('jigoshop_cart_page_id'))) return true;
return false;
}
function is_checkout() {
if (
is_page(get_option('jigoshop_checkout_page_id'))
) return true;
return false;
}
if (!function_exists('is_ajax')) {
function is_ajax() {
if ( isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) return true;
return false;
}
}
function jigoshop_force_ssl() {
if (is_checkout() && !is_ssl()) :
wp_redirect( str_replace('http:', 'https:', get_permalink(get_option('jigoshop_checkout_page_id'))), 301 );
exit;
endif;
}
function jigoshop_force_ssl_images( $content ) {
if (is_ssl()) :
if (is_array($content)) :
$content = array_map('jigoshop_force_ssl_images', $content);
else :
$content = str_replace('http:', 'https:', $content);
endif;
endif;
return $content;
}
add_filter('post_thumbnail_html', 'jigoshop_force_ssl_images');
add_filter('widget_text', 'jigoshop_force_ssl_images');
add_filter('wp_get_attachment_url', 'jigoshop_force_ssl_images');
add_filter('wp_get_attachment_image_attributes', 'jigoshop_force_ssl_images');
add_filter('wp_get_attachment_url', 'jigoshop_force_ssl_images');
function get_jigoshop_currency_symbol() {
$currency = get_option('jigoshop_currency');
$currency_symbol = '';
switch ($currency) :
case 'AUD' :
case 'BRL' :
case 'CAD' :
case 'MXN' :
case 'NZD' :
case 'HKD' :
case 'SGD' :
case 'USD' : $currency_symbol = '&#36;'; break;
case 'EUR' : $currency_symbol = '&euro;'; break;
case 'JPY' : $currency_symbol = '&yen;'; break;
case 'CZK' :
case 'DKK' :
case 'HUF' :
case 'ILS' :
case 'MYR' :
case 'NOK' :
case 'PHP' :
case 'PLN' :
case 'SEK' :
case 'CHF' :
case 'TWD' :
case 'THB' : $currency_symbol = $currency; break;
case 'GBP' :
default : $currency_symbol = '&pound;'; break;
endswitch;
return apply_filters('jigoshop_currency_symbol', $currency_symbol, $currency);
}
function jigoshop_price( $price, $args = array() ) {
extract(shortcode_atts(array(
'ex_tax_label' => '0'
), $args));
$return = '';
$num_decimals = (int) get_option('jigoshop_price_num_decimals');
$currency_pos = get_option('jigoshop_currency_pos');
$currency_symbol = get_jigoshop_currency_symbol();
$price = number_format( (double) $price, $num_decimals, get_option('jigoshop_price_decimal_sep'), get_option('jigoshop_price_thousand_sep') );
switch ($currency_pos) :
case 'left' :
$return = $currency_symbol . $price;
break;
case 'right' :
$return = $price . $currency_symbol;
break;
case 'left_space' :
$return = $currency_symbol . ' ' . $price;
break;
case 'right_space' :
$return = $price . ' ' . $currency_symbol;
break;
endswitch;
if ($ex_tax_label && get_option('jigoshop_calc_taxes')=='yes') $return .= __(' <small>(ex. tax)</small>', 'jigoshop');
return $return;
}
/** Show variation info if set */
function jigoshop_get_formatted_variation( $variation = '', $flat = false ) {
if ($variation && is_array($variation)) :
$return = '';
if (!$flat) :
$return = '<dl class="variation">';
endif;
$varation_list = array();
foreach ($variation as $name => $value) :
if ($flat) :
$varation_list[] = ucfirst(str_replace('tax_', '', $name)).': '.ucfirst($value);
else :
$varation_list[] = '<dt>'.ucfirst(str_replace('tax_', '', $name)).':</dt><dd>'.ucfirst($value).'</dd>';
endif;
endforeach;
if ($flat) :
$return .= implode(', ', $varation_list);
else :
$return .= implode('', $varation_list);
endif;
if (!$flat) :
$return .= '</dl>';
endif;
return $return;
endif;
}
function jigoshop_let_to_num($v) {
$l = substr($v, -1);
$ret = substr($v, 0, -1);
switch(strtoupper($l)){
case 'P':
$ret *= 1024;
case 'T':
$ret *= 1024;
case 'G':
$ret *= 1024;
case 'M':
$ret *= 1024;
case 'K':
$ret *= 1024;
break;
}
return $ret;
}
function jigowatt_clean( $var ) {
return strip_tags(stripslashes(trim($var)));
}
global $jigoshop_body_classes;
function jigoshop_page_body_classes() {
global $jigoshop_body_classes;
$jigoshop_body_classes = (array) $jigoshop_body_classes;
if (is_checkout() || is_page(get_option('jigoshop_pay_page_id'))) jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-checkout' ) );
if (is_cart()) jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-cart' ) );
if (is_page(get_option('jigoshop_thanks_page_id'))) jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-thanks' ) );
if (is_page(get_option('jigoshop_shop_page_id'))) jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-shop' ) );
if (is_page(get_option('jigoshop_myaccount_page_id')) || is_page(get_option('jigoshop_edit_address_page_id')) || is_page(get_option('jigoshop_view_order_page_id')) || is_page(get_option('jigoshop_change_password_page_id'))) jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-myaccount' ) );
}
add_action('wp_head', 'jigoshop_page_body_classes');
function jigoshop_add_body_class( $class = array() ) {
global $jigoshop_body_classes;
$jigoshop_body_classes = (array) $jigoshop_body_classes;
$jigoshop_body_classes = array_merge($class, $jigoshop_body_classes);
}
function jigoshop_body_class($classes) {
global $jigoshop_body_classes;
$jigoshop_body_classes = (array) $jigoshop_body_classes;
$classes = array_merge($classes, $jigoshop_body_classes);
return $classes;
}
add_filter('body_class','jigoshop_body_class');
### Extra Review Field in comments #########################################################
function jigoshop_add_comment_rating($comment_id) {
if ( isset($_POST['rating']) ) :
if (!$_POST['rating'] || $_POST['rating'] > 5 || $_POST['rating'] < 0) $_POST['rating'] = 5;
add_comment_meta( $comment_id, 'rating', $_POST['rating'], true );
endif;
}
add_action( 'comment_post', 'jigoshop_add_comment_rating', 1 );
function jigoshop_check_comment_rating($comment_data) {
// If posting a comment (not trackback etc) and not logged in
if ( isset($_POST['rating']) && !jigoshop::verify_nonce('comment_rating') )
wp_die( __('You have taken too long. Please go back and refresh the page.', 'jigoshop') );
elseif ( isset($_POST['rating']) && empty($_POST['rating']) && $comment_data['comment_type']== '' ) {
wp_die( __('Please rate the product.',"jigowatt") );
exit;
}
return $comment_data;
}
add_filter('preprocess_comment', 'jigoshop_check_comment_rating', 0);
### Comments #########################################################
function jigoshop_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; global $post; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div id="comment-<?php comment_ID(); ?>" class="comment_container">
<?php echo get_avatar( $comment, $size='60' ); ?>
<div class="comment-text">
<div class="star-rating" title="<?php echo get_comment_meta( $comment->comment_ID, 'rating', true ); ?>">
<span style="width:<?php echo get_comment_meta( $comment->comment_ID, 'rating', true )*16; ?>px"><?php echo get_comment_meta( $comment->comment_ID, 'rating', true ); ?> <?php _e('out of 5', 'jigoshop'); ?></span>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<p class="meta"><em><?php _e('Your comment is awaiting approval','jigoshop'); ?></em></p>
<?php else : ?>
<p class="meta">
<?php _e('Rating by','jigoshop'); ?> <strong class="reviewer vcard"><span class="fn"><?php comment_author(); ?></span></strong> <?php _e('on','jigoshop'); ?> <?php echo get_comment_date('M jS Y'); ?>:
</p>
<?php endif; ?>
<div class="description"><?php comment_text(); ?></div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<?php
}
### Exclude order comments from front end #########################################################
function jigoshop_exclude_order_comments( $clauses ) {
global $wpdb;
$clauses['join'] = "
LEFT JOIN $wpdb->posts ON $wpdb->comments.comment_post_ID = $wpdb->posts.ID
";
if ($clauses['where']) $clauses['where'] .= ' AND ';
$clauses['where'] .= "
$wpdb->posts.post_type NOT IN ('shop_order')
";
return $clauses;
}
if (!is_admin()) add_filter('comments_clauses', 'jigoshop_exclude_order_comments');

View File

@ -1,632 +0,0 @@
<?php
/**
* ACTIONS
*
* Various hooks Jigoshop uses to do stuff. index:
*
* - Get variation
* - Add order item
* - When default permalinks are enabled, redirect shop page to post type archive url
* - Add to Cart
* - Clear cart
* - Restore an order via a link
* - Cancel a pending order
* - Download a file
* - Order Status completed - GIVE DOWNLOADABLE PRODUCT ACCESS TO CUSTOMER
*
**/
/**
* Get variation
*
* Get variation price etc when using frontend form
*
* @since 1.0
*/
add_action('wp_ajax_jigoshop_get_variation', 'display_variation_data');
add_action('wp_ajax_nopriv_jigoshop_get_variation', 'display_variation_data');
function display_variation_data() {
check_ajax_referer( 'get-variation', 'security' );
// get variation terms
$variation_query = array();
$variation_data = array();
parse_str( $_POST['variation_data'], $variation_data );
$variation_id = jigoshop_find_variation( $variation_data );
if (!$variation_id) die();
$_product = &new jigoshop_product_variation($variation_id);
$availability = $_product->get_availability();
if ($availability['availability']) :
$availability_html = '<p class="stock '.$availability['class'].'">'. $availability['availability'].'</p>';
else :
$availability_html = '';
endif;
if (has_post_thumbnail($variation_id)) :
$attachment_id = get_post_thumbnail_id( $variation_id );
$large_thumbnail_size = apply_filters('single_product_large_thumbnail_size', 'shop_large');
$image = current(wp_get_attachment_image_src( $attachment_id, $large_thumbnail_size));
$image_link = current(wp_get_attachment_image_src( $attachment_id, 'full'));
else :
$image = '';
$image_link = '';
endif;
$data = array(
'price_html' => '<span class="price">'.$_product->get_price_html().'</span>',
'availability_html' => $availability_html,
'image_src' => $image,
'image_link' => $image_link
);
echo json_encode( $data );
// Quit out
die();
}
/**
* Add order item
*
* Add order item via ajax
*
* @since 1.0
*/
add_action('wp_ajax_jigoshop_add_order_item', 'jigoshop_add_order_item');
function jigoshop_add_order_item() {
check_ajax_referer( 'add-order-item', 'security' );
global $wpdb;
$item_to_add = trim(stripslashes($_POST['item_to_add']));
$post = '';
// Find the item
if (is_numeric($item_to_add)) :
$post = get_post( $item_to_add );
endif;
if (!$post || ($post->post_type!=='product' && $post->post_type!=='product_variation')) :
$post_id = $wpdb->get_var($wpdb->prepare("
SELECT post_id
FROM $wpdb->posts
LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)
WHERE $wpdb->postmeta.meta_key = 'SKU'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->posts.post_type = 'shop_product'
AND $wpdb->postmeta.meta_value = '".$item_to_add."'
LIMIT 1
"));
$post = get_post( $post_id );
endif;
if (!$post || ($post->post_type!=='product' && $post->post_type!=='product_variation')) :
die();
endif;
if ($post->post_type=="product") :
$_product = &new jigoshop_product( $post->ID );
else :
$_product = &new jigoshop_product_variation( $post->ID );
endif;
$loop = 0;
?>
<tr class="item">
<td class="product-id">#<?php echo $_product->id; ?></td>
<td class="variation-id"><?php if (isset($_product->variation_id)) echo $_product->variation_id; else echo '-'; ?></td>
<td class="product-sku"><?php if ($_product->sku) echo $_product->sku; ?></td>
<td class="name"><a href="<?php echo admin_url('post.php?post='. $_product->id .'&action=edit'); ?>"><?php echo $_product->get_title(); ?></a></td>
<td class="variation"><?php
if (isset($_product->variation_data)) :
echo jigoshop_get_formatted_variation( $_product->variation_data, true );
else :
echo '-';
endif;
?></td>
<td>
<table class="meta" cellspacing="0">
<tfoot>
<tr>
<td colspan="3"><button class="add_meta button"><?php _e('Add meta', 'jigoshop'); ?></button></td>
</tr>
</tfoot>
<tbody></tbody>
</table>
</td>
<?php do_action('jigoshop_admin_order_item_values', $_product); ?>
<td class="quantity"><input type="text" name="item_quantity[]" placeholder="<?php _e('Quantity e.g. 2', 'jigoshop'); ?>" value="1" /></td>
<td class="cost"><input type="text" name="item_cost[]" placeholder="<?php _e('Cost per unit ex. tax e.g. 2.99', 'jigoshop'); ?>" value="<?php echo $_product->get_price(); ?>" /></td>
<td class="tax"><input type="text" name="item_tax_rate[]" placeholder="<?php _e('Tax Rate e.g. 20.0000', 'jigoshop'); ?>" value="<?php echo $_product->get_tax_base_rate(); ?>" /></td>
<td class="center">
<input type="hidden" name="item_id[]" value="<?php echo $_product->id; ?>" />
<input type="hidden" name="item_name[]" value="<?php echo $_product->get_title(); ?>" />
<button type="button" class="remove_row button">&times;</button>
</td>
</tr>
<?php
// Quit out
die();
}
/**
* When default permalinks are enabled, redirect shop page to post type archive url
**/
if (get_option( 'permalink_structure' )=="") add_action( 'init', 'jigoshop_shop_page_archive_redirect' );
function jigoshop_shop_page_archive_redirect() {
if ( isset($_GET['page_id']) && $_GET['page_id'] == get_option('jigoshop_shop_page_id') ) :
wp_safe_redirect( get_post_type_archive_link('product') );
exit;
endif;
}
/**
* Remove from cart/update
**/
add_action( 'init', 'jigoshop_update_cart_action' );
function jigoshop_update_cart_action() {
// Remove from cart
if ( isset($_GET['remove_item']) && is_numeric($_GET['remove_item']) && jigoshop::verify_nonce('cart', '_GET')) :
jigoshop_cart::set_quantity( $_GET['remove_item'], 0 );
// Re-calc price
//jigoshop_cart::calculate_totals();
jigoshop::add_message( __('Cart updated.', 'jigoshop') );
if ( isset($_SERVER['HTTP_REFERER'])) :
wp_safe_redirect($_SERVER['HTTP_REFERER']);
exit;
endif;
// Update Cart
elseif (isset($_POST['update_cart']) && $_POST['update_cart'] && jigoshop::verify_nonce('cart')) :
$cart_totals = $_POST['cart'];
if (sizeof(jigoshop_cart::$cart_contents)>0) :
foreach (jigoshop_cart::$cart_contents as $cart_item_key => $values) :
if (isset($cart_totals[$cart_item_key]['qty'])) jigoshop_cart::set_quantity( $cart_item_key, $cart_totals[$cart_item_key]['qty'] );
endforeach;
endif;
jigoshop::add_message( __('Cart updated.', 'jigoshop') );
endif;
}
/**
* Add to cart
**/
add_action( 'init', 'jigoshop_add_to_cart_action' );
function jigoshop_add_to_cart_action( $url = false ) {
if (isset($_GET['add-to-cart']) && $_GET['add-to-cart']) :
if ( !jigoshop::verify_nonce('add_to_cart', '_GET') ) :
elseif (is_numeric($_GET['add-to-cart'])) :
$quantity = 1;
if (isset($_POST['quantity'])) $quantity = $_POST['quantity'];
jigoshop_cart::add_to_cart($_GET['add-to-cart'], $quantity);
jigoshop::add_message( sprintf(__('<a href="%s" class="button">View Cart &rarr;</a> Product successfully added to your basket.', 'jigoshop'), jigoshop_cart::get_cart_url()) );
elseif ($_GET['add-to-cart']=='variation') :
// Variation add to cart
if (isset($_POST['quantity']) && $_POST['quantity']) :
$product_id = (int) $_GET['product'];
$quantity = ($_POST['quantity']) ? $_POST['quantity'] : 1;
$attributes = (array) maybe_unserialize( get_post_meta($product_id, 'product_attributes', true) );
$variations = array();
$all_variations_set = true;
$variation_id = 0;
foreach ($attributes as $attribute) :
if ( $attribute['variation']!=='yes' ) continue;
if (isset($_POST[ 'tax_' . sanitize_title($attribute['name']) ]) && $_POST[ 'tax_' . sanitize_title($attribute['name']) ]) :
$variations['tax_' .sanitize_title($attribute['name'])] = $_POST[ 'tax_' . sanitize_title($attribute['name']) ];
else :
$all_variations_set = false;
endif;
endforeach;
if (!$all_variations_set) :
jigoshop::add_error( __('Please choose product options&hellip;', 'jigoshop') );
else :
// Find matching variation
$variation_id = jigoshop_find_variation( $variations );
if ($variation_id>0) :
// Add to cart
jigoshop_cart::add_to_cart($product_id, $quantity, $variations, $variation_id);
jigoshop::add_message( sprintf(__('<a href="%s" class="button">View Cart &rarr;</a> Product successfully added to your basket.', 'jigoshop'), jigoshop_cart::get_cart_url()) );
else :
jigoshop::add_error( __('Sorry, this variation is not available.', 'jigoshop') );
endif;
endif;
elseif ($_GET['product']) :
/* Link on product pages */
jigoshop::add_error( __('Please choose product options&hellip;', 'jigoshop') );
wp_redirect( get_permalink( $_GET['product'] ) );
exit;
endif;
elseif ($_GET['add-to-cart']=='group') :
// Group add to cart
if (isset($_POST['quantity']) && is_array($_POST['quantity'])) :
$total_quantity = 0;
foreach ($_POST['quantity'] as $item => $quantity) :
if ($quantity>0) :
jigoshop_cart::add_to_cart($item, $quantity);
jigoshop::add_message( sprintf(__('<a href="%s" class="button">View Cart &rarr;</a> Product successfully added to your basket.', 'jigoshop'), jigoshop_cart::get_cart_url()) );
$total_quantity = $total_quantity + $quantity;
endif;
endforeach;
if ($total_quantity==0) :
jigoshop::add_error( __('Please choose a quantity&hellip;', 'jigoshop') );
endif;
elseif ($_GET['product']) :
/* Link on product pages */
jigoshop::add_error( __('Please choose a product&hellip;', 'jigoshop') );
wp_redirect( get_permalink( $_GET['product'] ) );
exit;
endif;
endif;
$url = apply_filters('add_to_cart_redirect', $url);
// If has custom URL redirect there
if ( $url ) {
wp_safe_redirect( $url );
exit;
}
// Otherwise redirect to where they came
else if ( isset($_SERVER['HTTP_REFERER'])) {
wp_safe_redirect($_SERVER['HTTP_REFERER']);
exit;
}
// If all else fails redirect to root
else {
wp_safe_redirect('/');
exit;
}
endif;
}
/**
* Clear cart
**/
add_action( 'wp_header', 'jigoshop_clear_cart_on_return' );
function jigoshop_clear_cart_on_return() {
if (is_page(get_option('jigoshop_thanks_page_id'))) :
if (isset($_GET['order'])) $order_id = $_GET['order']; else $order_id = 0;
if (isset($_GET['key'])) $order_key = $_GET['key']; else $order_key = '';
if ($order_id > 0) :
$order = &new jigoshop_order( $order_id );
if ($order->order_key == $order_key) :
jigoshop_cart::empty_cart();
endif;
endif;
endif;
}
/**
* Clear the cart after payment - order will be processing or complete
**/
add_action( 'init', 'jigoshop_clear_cart_after_payment' );
function jigoshop_clear_cart_after_payment( $url = false ) {
if (isset($_SESSION['order_awaiting_payment']) && $_SESSION['order_awaiting_payment'] > 0) :
$order = &new jigoshop_order($_SESSION['order_awaiting_payment']);
if ($order->id > 0 && ($order->status=='completed' || $order->status=='processing')) :
jigoshop_cart::empty_cart();
unset($_SESSION['order_awaiting_payment']);
endif;
endif;
}
/**
* Process the login form
**/
add_action('init', 'jigoshop_process_login');
function jigoshop_process_login() {
if (isset($_POST['login']) && $_POST['login']) :
jigoshop::verify_nonce('login');
if ( !isset($_POST['username']) || empty($_POST['username']) ) jigoshop::add_error( __('Username is required.', 'jigoshop') );
if ( !isset($_POST['password']) || empty($_POST['password']) ) jigoshop::add_error( __('Password is required.', 'jigoshop') );
if (jigoshop::error_count()==0) :
$creds = array();
$creds['user_login'] = $_POST['username'];
$creds['user_password'] = $_POST['password'];
$creds['remember'] = true;
$secure_cookie = is_ssl() ? true : false;
$user = wp_signon( $creds, $secure_cookie );
if ( is_wp_error($user) ) :
jigoshop::add_error( $user->get_error_message() );
else :
if ( isset($_SERVER['HTTP_REFERER'])) {
wp_safe_redirect($_SERVER['HTTP_REFERER']);
exit;
}
wp_redirect(get_permalink(get_option('jigoshop_myaccount_page_id')));
exit;
endif;
endif;
endif;
}
/**
* Process ajax checkout form
*/
add_action('wp_ajax_jigoshop-checkout', 'jigoshop_process_checkout');
add_action('wp_ajax_nopriv_jigoshop-checkout', 'jigoshop_process_checkout');
function jigoshop_process_checkout () {
include_once jigoshop::plugin_path() . '/classes/jigoshop_checkout.class.php';
jigoshop_checkout::instance()->process_checkout();
die(0);
}
/**
* Cancel a pending order - hook into init function
**/
add_action('init', 'jigoshop_cancel_order');
function jigoshop_cancel_order() {
if ( isset($_GET['cancel_order']) && isset($_GET['order']) && isset($_GET['order_id']) ) :
$order_key = urldecode( $_GET['order'] );
$order_id = (int) $_GET['order_id'];
$order = &new jigoshop_order( $order_id );
if ($order->id == $order_id && $order->order_key == $order_key && $order->status=='pending' && jigoshop::verify_nonce('cancel_order', '_GET')) :
// Cancel the order + restore stock
$order->cancel_order( __('Order cancelled by customer.', 'jigoshop') );
// Message
jigoshop::add_message( __('Your order was cancelled.', 'jigoshop') );
elseif ($order->status!='pending') :
jigoshop::add_error( __('Your order is no longer pending and could not be cancelled. Please contact us if you need assistance.', 'jigoshop') );
else :
jigoshop::add_error( __('Invalid order.', 'jigoshop') );
endif;
wp_safe_redirect(jigoshop_cart::get_cart_url());
exit;
endif;
}
/**
* Download a file - hook into init function
**/
add_action('init', 'jigoshop_download_product');
function jigoshop_download_product() {
if ( isset($_GET['download_file']) && isset($_GET['order']) && isset($_GET['email']) ) :
global $wpdb;
$download_file = (int) urldecode($_GET['download_file']);
$order = urldecode( $_GET['order'] );
$email = urldecode( $_GET['email'] );
if (!is_email($email)) wp_safe_redirect( home_url() );
$downloads_remaining = $wpdb->get_var( $wpdb->prepare("
SELECT downloads_remaining
FROM ".$wpdb->prefix."jigoshop_downloadable_product_permissions
WHERE user_email = '$email'
AND order_key = '$order'
AND product_id = '$download_file'
;") );
if ($downloads_remaining=='0') :
wp_die( sprintf(__('Sorry, you have reached your download limit for this file. <a href="%s">Go to homepage &rarr;</a>', 'jigoshop'), home_url()) );
else :
if ($downloads_remaining>0) :
$wpdb->update( $wpdb->prefix . "jigoshop_downloadable_product_permissions", array(
'downloads_remaining' => $downloads_remaining - 1,
), array(
'user_email' => $email,
'order_key' => $order,
'product_id' => $download_file
), array( '%d' ), array( '%s', '%s', '%d' ) );
endif;
// Download the file
$file_path = ABSPATH . get_post_meta($download_file, 'file_path', true);
$file_path = realpath($file_path);
$file_extension = strtolower(substr(strrchr($file_path,"."),1));
switch ($file_extension) :
case "pdf": $ctype="application/pdf"; break;
case "exe": $ctype="application/octet-stream"; break;
case "zip": $ctype="application/zip"; break;
case "doc": $ctype="application/msword"; break;
case "xls": $ctype="application/vnd.ms-excel"; break;
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpe": case "jpeg": case "jpg": $ctype="image/jpg"; break;
default: $ctype="application/force-download";
endswitch;
if (!file_exists($file_path)) wp_die( sprintf(__('File not found. <a href="%s">Go to homepage &rarr;</a>', 'jigoshop'), home_url()) );
@ini_set('zlib.output_compression', 'Off');
@set_time_limit(0);
@session_start();
@session_cache_limiter('none');
@set_magic_quotes_runtime(0);
@ob_end_clean();
@session_write_close();
header("Pragma: no-cache");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Robots: none");
header("Content-Type: ".$ctype."");
header("Content-Description: File Transfer");
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
// workaround for IE filename bug with multiple periods / multiple dots in filename
$iefilename = preg_replace('/\./', '%2e', basename($file_path), substr_count(basename($file_path), '.') - 1);
header("Content-Disposition: attachment; filename=\"".$iefilename."\";");
} else {
header("Content-Disposition: attachment; filename=\"".basename($file_path)."\";");
}
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".@filesize($file_path));
@readfile("$file_path") or wp_die( sprintf(__('File not found. <a href="%s">Go to homepage &rarr;</a>', 'jigoshop'), home_url()) );
exit;
endif;
endif;
}
/**
* Order Status completed - GIVE DOWNLOADABLE PRODUCT ACCESS TO CUSTOMER
**/
add_action('order_status_completed', 'jigoshop_downloadable_product_permissions');
function jigoshop_downloadable_product_permissions( $order_id ) {
global $wpdb;
$order = &new jigoshop_order( $order_id );
if (sizeof($order->items)>0) foreach ($order->items as $item) :
if ($item['id']>0) :
$_product = &new jigoshop_product( $item['id'] );
if ( $_product->exists && $_product->is_type('downloadable') ) :
$user_email = $order->billing_email;
if ($order->user_id>0) :
$user_info = get_userdata($order->user_id);
if ($user_info->user_email) :
$user_email = $user_info->user_email;
endif;
else :
$order->user_id = 0;
endif;
$limit = trim(get_post_meta($_product->id, 'download_limit', true));
if (!empty($limit)) :
$limit = (int) $limit;
else :
$limit = '';
endif;
// Downloadable product - give access to the customer
$wpdb->insert( $wpdb->prefix . 'jigoshop_downloadable_product_permissions', array(
'product_id' => $_product->id,
'user_id' => $order->user_id,
'user_email' => $user_email,
'order_key' => $order->order_key,
'downloads_remaining' => $limit
), array(
'%s',
'%s',
'%s',
'%s',
'%s'
) );
endif;
endif;
endforeach;
}

View File

@ -1,52 +0,0 @@
<?php
### Update price if on sale
function jigoshop_update_sale_prices() {
global $wpdb;
// On Sale Products
$on_sale = $wpdb->get_results("
SELECT post_id FROM $wpdb->postmeta
WHERE meta_key = 'sale_price_dates_from'
AND meta_value < ".strtotime('NOW')."
");
if ($on_sale) foreach ($on_sale as $product) :
$data = unserialize( get_post_meta($product, 'product_data', true) );
$price = get_post_meta($product, 'price', true);
if ($data['sale_price'] && $price!==$data['sale_price']) update_post_meta($product, 'price', $data['sale_price']);
endforeach;
// Expired Sales
$sale_expired = $wpdb->get_results("
SELECT post_id FROM $wpdb->postmeta
WHERE meta_key = 'sale_price_dates_to'
AND meta_value < ".strtotime('NOW')."
");
if ($sale_expired) foreach ($sale_expired as $product) :
$data = unserialize( get_post_meta($product, 'product_data', true) );
$price = get_post_meta($product, 'price', true);
if ($data['regular_price'] && $price!==$data['regular_price']) update_post_meta($product, 'price', $data['regular_price']);
// Sale has expired - clear the schedule boxes
update_post_meta($product, 'sale_price_dates_from', '');
update_post_meta($product, 'sale_price_dates_to', '');
endforeach;
}
function jigoshop_update_sale_prices_schedule_check(){
wp_schedule_event(time(), 'daily', 'jigoshop_update_sale_prices_schedule_check');
update_option('jigoshop_update_sale_prices', 'yes');
}
if (get_option('jigoshop_update_sale_prices')!='yes') jigoshop_update_sale_prices_schedule_check();
add_action('jigoshop_update_sale_prices_schedule_check', 'jigoshop_update_sale_prices');

View File

@ -1,260 +0,0 @@
<?php
/**
* Hooks for emails
**/
add_action('jigoshop_low_stock_notification', 'jigoshop_low_stock_notification');
add_action('jigoshop_no_stock_notification', 'jigoshop_no_stock_notification');
add_action('jigoshop_product_on_backorder_notification', 'jigoshop_product_on_backorder_notification', 1, 2);
/**
* New order notification email template
**/
add_action('order_status_pending_to_processing', 'jigoshop_new_order_notification');
add_action('order_status_pending_to_completed', 'jigoshop_new_order_notification');
add_action('order_status_pending_to_on-hold', 'jigoshop_new_order_notification');
function jigoshop_new_order_notification( $order_id ) {
$order = &new jigoshop_order( $order_id );
$subject = sprintf(__('[%s] New Customer Order (# %s)','jigoshop'), get_bloginfo('name'), $order->id);
$message = __("You have received an order from ",'jigoshop') . $order->billing_first_name . ' ' . $order->billing_last_name . __(". Their order is as follows:",'jigoshop') . PHP_EOL . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= __('ORDER #: ','jigoshop') . $order->id . '' . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= $order->email_order_items_list( false, true );
if ($order->customer_note) :
$message .= PHP_EOL . __('Note:','jigoshop') .$order->customer_note . PHP_EOL;
endif;
$message .= PHP_EOL . __('Subtotal:','jigoshop') . "\t\t\t" . $order->get_subtotal_to_display() . PHP_EOL;
if ($order->order_shipping > 0) $message .= __('Shipping:','jigoshop') . "\t\t\t" . $order->get_shipping_to_display() . PHP_EOL;
if ($order->order_discount > 0) $message .= __('Discount:','jigoshop') . "\t\t\t" . jigoshop_price($order->order_discount) . PHP_EOL;
if ($order->get_total_tax() > 0) $message .= __('Tax:','jigoshop') . "\t\t\t\t\t" . jigoshop_price($order->get_total_tax()) . PHP_EOL;
$message .= __('Total:','jigoshop') . "\t\t\t\t" . jigoshop_price($order->order_total) . ' - via ' . ucwords($order->payment_method) . PHP_EOL . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= __('CUSTOMER DETAILS','jigoshop') . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
if ($order->billing_email) $message .= __('Email:','jigoshop') . "\t\t\t\t" . $order->billing_email . PHP_EOL;
if ($order->billing_phone) $message .= __('Tel:','jigoshop') . "\t\t\t\t\t" . $order->billing_phone . PHP_EOL;
$message .= PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= __('BILLING ADDRESS','jigoshop') . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= $order->billing_first_name . ' ' . $order->billing_last_name . PHP_EOL;
if ($order->billing_company) $message .= $order->billing_company . PHP_EOL;
$message .= $order->formatted_billing_address . PHP_EOL . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= __('SHIPPING ADDRESS','jigoshop') . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= $order->shipping_first_name . ' ' . $order->shipping_last_name . PHP_EOL;
if ($order->shipping_company) $message .= $order->shipping_company . PHP_EOL;
$message .= $order->formatted_shipping_address . PHP_EOL . PHP_EOL;
$message = html_entity_decode( strip_tags( $message ) );
wp_mail( get_option('admin_email'), $subject, $message );
}
/**
* Processing order notification email template
**/
add_action('order_status_pending_to_processing', 'jigoshop_processing_order_customer_notification');
add_action('order_status_pending_to_on-hold', 'jigoshop_processing_order_customer_notification');
function jigoshop_processing_order_customer_notification( $order_id ) {
$order = &new jigoshop_order( $order_id );
$subject = '[' . get_bloginfo('name') . '] ' . __('Order Received','jigoshop');
$message = __("Thank you, we are now processing your order. Your order's details are below:",'jigoshop') . PHP_EOL . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= __('ORDER #: ','jigoshop') . $order->id . '' . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= $order->email_order_items_list();
if ($order->customer_note) :
$message .= PHP_EOL . __('Note:','jigoshop') .$order->customer_note . PHP_EOL;
endif;
$message .= PHP_EOL . __('Subtotal:','jigoshop') . "\t\t\t" . $order->get_subtotal_to_display() . PHP_EOL;
if ($order->order_shipping > 0) $message .= __('Shipping:','jigoshop') . "\t\t\t" . $order->get_shipping_to_display() . PHP_EOL;
if ($order->order_discount > 0) $message .= __('Discount:','jigoshop') . "\t\t\t" . jigoshop_price($order->order_discount) . PHP_EOL;
if ($order->get_total_tax() > 0) $message .= __('Tax:','jigoshop') . "\t\t\t\t\t" . jigoshop_price($order->get_total_tax()) . PHP_EOL;
$message .= __('Total:','jigoshop') . "\t\t\t\t" . jigoshop_price($order->order_total) . ' - via ' . ucwords($order->payment_method) . PHP_EOL . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= __('CUSTOMER DETAILS','jigoshop') . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
if ($order->billing_email) $message .= __('Email:','jigoshop') . "\t\t\t\t" . $order->billing_email . PHP_EOL;
if ($order->billing_phone) $message .= __('Tel:','jigoshop') . "\t\t\t\t\t" . $order->billing_phone . PHP_EOL;
$message .= PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= __('BILLING ADDRESS','jigoshop') . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= $order->billing_first_name . ' ' . $order->billing_last_name . PHP_EOL;
if ($order->billing_company) $message .= $order->billing_company . PHP_EOL;
$message .= $order->formatted_billing_address . PHP_EOL . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= __('SHIPPING ADDRESS','jigoshop') . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= $order->shipping_first_name . ' ' . $order->shipping_last_name . PHP_EOL;
if ($order->shipping_company) $message .= $order->shipping_company . PHP_EOL;
$message .= $order->formatted_shipping_address . PHP_EOL . PHP_EOL;
$message = html_entity_decode( strip_tags( $message ) );
wp_mail( $order->billing_email, $subject, $message );
}
/**
* Completed order notification email template - this one includes download links for downloadable products
**/
add_action('order_status_completed', 'jigoshop_completed_order_customer_notification');
function jigoshop_completed_order_customer_notification( $order_id ) {
$order = &new jigoshop_order( $order_id );
$subject = '[' . get_bloginfo('name') . '] ' . __('Order Complete','jigoshop');
$message = __("Your order is complete. Your order's details are below:",'jigoshop') . PHP_EOL . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= __('ORDER #: ','jigoshop') . $order->id . '' . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= $order->email_order_items_list( true );
if ($order->customer_note) :
$message .= PHP_EOL . __('Note:','jigoshop') .$order->customer_note . PHP_EOL;
endif;
$message .= PHP_EOL . __('Subtotal:','jigoshop') . "\t\t\t" . $order->get_subtotal_to_display() . PHP_EOL;
if ($order->order_shipping > 0) $message .= __('Shipping:','jigoshop') . "\t\t\t" . $order->get_shipping_to_display() . PHP_EOL;
if ($order->order_discount > 0) $message .= __('Discount:','jigoshop') . "\t\t\t" . jigoshop_price($order->order_discount) . PHP_EOL;
if ($order->get_total_tax() > 0) $message .= __('Tax:','jigoshop') . "\t\t\t\t\t" . jigoshop_price($order->get_total_tax()) . PHP_EOL;
$message .= __('Total:','jigoshop') . "\t\t\t\t" . jigoshop_price($order->order_total) . ' - via ' . ucwords($order->payment_method) . PHP_EOL . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= __('CUSTOMER DETAILS','jigoshop') . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
if ($order->billing_email) $message .= __('Email:','jigoshop') . "\t\t\t\t" . $order->billing_email . PHP_EOL;
if ($order->billing_phone) $message .= __('Tel:','jigoshop') . "\t\t\t\t\t" . $order->billing_phone . PHP_EOL;
$message .= PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= __('BILLING ADDRESS','jigoshop') . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= $order->billing_first_name . ' ' . $order->billing_last_name . PHP_EOL;
if ($order->billing_company) $message .= $order->billing_company . PHP_EOL;
$message .= $order->formatted_billing_address . PHP_EOL . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= __('SHIPPING ADDRESS','jigoshop') . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= $order->shipping_first_name . ' ' . $order->shipping_last_name . PHP_EOL;
if ($order->shipping_company) $message .= $order->shipping_company . PHP_EOL;
$message .= $order->formatted_shipping_address . PHP_EOL . PHP_EOL;
$message = html_entity_decode( strip_tags( $message ) );
wp_mail( $order->billing_email, $subject, $message );
}
/**
* Pay for order notification email template - this one includes a payment link
**/
function jigoshop_pay_for_order_customer_notification( $order_id ) {
$order = &new jigoshop_order( $order_id );
$subject = '[' . get_bloginfo('name') . '] ' . __('Pay for Order','jigoshop');
$customer_message = sprintf( __("An order has been created for you on &ldquo;%s&rdquo;. To pay for this order please use the following link: %s",'jigoshop') . PHP_EOL . PHP_EOL, get_bloginfo('name'), $order->get_checkout_payment_url() );
$message = '=====================================================================' . PHP_EOL;
$message .= __('ORDER #: ','jigoshop') . $order->id . '' . PHP_EOL;
$message .= '=====================================================================' . PHP_EOL;
$message .= $order->email_order_items_list();
if ($order->customer_note) :
$message .= PHP_EOL . __('Note:','jigoshop') .$order->customer_note . PHP_EOL;
endif;
$message .= PHP_EOL . __('Subtotal:','jigoshop') . "\t\t\t" . $order->get_subtotal_to_display() . PHP_EOL;
if ($order->order_shipping > 0) $message .= __('Shipping:','jigoshop') . "\t\t\t" . $order->get_shipping_to_display() . PHP_EOL;
if ($order->order_discount > 0) $message .= __('Discount:','jigoshop') . "\t\t\t" . jigoshop_price($order->order_discount) . PHP_EOL;
if ($order->get_total_tax() > 0) $message .= __('Tax:','jigoshop') . "\t\t\t\t\t" . jigoshop_price($order->get_total_tax()) . PHP_EOL;
$message .= __('Total:','jigoshop') . "\t\t\t\t" . jigoshop_price($order->order_total) . ' - via ' . ucwords($order->payment_method) . PHP_EOL . PHP_EOL;
$customer_message = html_entity_decode( strip_tags( $customer_message.$message ) );
wp_mail( $order->billing_email, $subject, $customer_message );
}
/**
* Low stock notification email
**/
function jigoshop_low_stock_notification( $product ) {
$_product = &new jigoshop_product($product);
$subject = '[' . get_bloginfo('name') . '] ' . __('Product low in stock','jigoshop');
$message = '#' . $_product->id .' '. $_product->get_title() . ' ('. $_product->sku.') ' . __('is low in stock.', 'jigoshop');
$message = wordwrap( html_entity_decode( strip_tags( $message ) ), 70 );
wp_mail( get_option('admin_email'), $subject, $message );
}
/**
* No stock notification email
**/
function jigoshop_no_stock_notification( $product ) {
$_product = &new jigoshop_product($product);
$subject = '[' . get_bloginfo('name') . '] ' . __('Product out of stock','jigoshop');
$message = '#' . $_product->id .' '. $_product->get_title() . ' ('. $_product->sku.') ' . __('is out of stock.', 'jigoshop');
$message = wordwrap( html_entity_decode( strip_tags( $message ) ), 70 );
wp_mail( get_option('admin_email'), $subject, $message );
}
/**
* Backorder notification email
**/
function jigoshop_product_on_backorder_notification( $product, $amount ) {
$_product = &new jigoshop_product($product);
$subject = '[' . get_bloginfo('name') . '] ' . __('Product Backorder','jigoshop');
$message = $amount . __(' units of #', 'jigoshop') . $_product->id .' '. $_product->get_title() . ' ('. $_product->sku.') ' . __('have been backordered.', 'jigoshop');
$message = wordwrap( html_entity_decode( strip_tags( $message ) ), 70 );
wp_mail( get_option('admin_email'), $subject, $message );
}

View File

@ -1,276 +0,0 @@
<?php
/**
* Find and get a specific variation
*
* @since 1.0
*/
function jigoshop_find_variation( $variation_data = array() ) {
foreach ($variation_data as $key => $value) :
if (!strstr($key, 'tax_')) continue;
$variation_query[] = array(
'key' => $key,
'value' => array( $value ),
'compare' => 'IN'
);
endforeach;
// do the query
$args = array(
'post_type' => 'product_variation',
'orderby' => 'id',
'order' => 'desc',
'posts_per_page' => 1,
'meta_query' => $variation_query
);
$posts = get_posts( $args );
if (!$posts) :
// Wildcard search
$variation_query = array();
foreach ($variation_data as $key => $value) :
if (!strstr($key, 'tax_')) continue;
$variation_query[] = array(
'key' => $key,
'value' => array( $value, '' ),
'compare' => 'IN'
);
endforeach;
$args['meta_query'] = $variation_query;
$posts = get_posts( $args );
endif;
if (!$posts) return false;
return $posts[0]->ID;
}
### Get unfiltered list of posts in current view for use in loop + widgets
function jigoshop_get_products_in_view() {
global $all_post_ids;
$all_post_ids = array();
if (is_tax( 'product_cat' ) || is_post_type_archive('product') || is_page( get_option('jigoshop_shop_page_id') ) || is_tax( 'product_tag' )) :
$all_post_ids = jigoshop_get_post_ids();
endif;
$all_post_ids[] = 0;
}
add_action('wp_head', 'jigoshop_get_products_in_view', 0);
### Do Filters/Layered Nav
function jigoshop_filter_loop() {
global $wp_query, $all_post_ids;
if (is_tax( 'product_cat' ) || is_post_type_archive('product') || is_page( get_option('jigoshop_shop_page_id') ) || is_tax( 'product_tag' )) :
$filters = array();
$filters = apply_filters('loop-shop-query', $filters);
//$post_ids = jigoshop_get_post_ids();
$post_ids = $all_post_ids;
$post_ids = apply_filters('loop-shop-posts-in', $post_ids);
$filters = array_merge($filters, array(
'post__in' => $post_ids
));
$args = array_merge( $wp_query->query, $filters );
query_posts( $args );
endif;
}
add_action('wp_head', 'jigoshop_filter_loop');
### Layered Nav Init
function jigoshop_layered_nav_init() {
global $_chosen_attributes, $wpdb;
$attribute_taxonomies = jigoshop::$attribute_taxonomies;
if ( $attribute_taxonomies ) :
foreach ($attribute_taxonomies as $tax) :
$attribute = strtolower(sanitize_title($tax->attribute_name));
$taxonomy = 'product_attribute_' . $attribute;
$name = 'filter_' . $attribute;
if (isset($_GET[$name]) && taxonomy_exists($taxonomy)) $_chosen_attributes[$taxonomy] = explode(',', $_GET[$name] );
endforeach;
endif;
}
add_action('init', 'jigoshop_layered_nav_init', 1);
### Get post ID's to filter from
function jigoshop_get_post_ids() {
global $wpdb;
$in = array('visible');
if (is_search()) $in[] = 'search';
if (!is_search()) $in[] = 'catalog';
// WP Query to get all queried post ids
global $wp_query;
$args = array_merge(
$wp_query->query,
array(
'page_id' => '',
'posts_per_page' => -1,
'post_type' => 'product',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'visibility',
'value' => $in,
'compare' => 'IN'
)
)
)
);
$custom_query = new WP_Query( $args );
$queried_post_ids = array();
foreach ($custom_query->posts as $p) $queried_post_ids[] = $p->ID;
wp_reset_query();
return $queried_post_ids;
}
### Layered Nav
function jigoshop_layered_nav_query( $filtered_posts ) {
global $_chosen_attributes, $wpdb;
if (sizeof($_chosen_attributes)>0) :
$matched_products = array();
$filtered = false;
foreach ($_chosen_attributes as $attribute => $values) :
if (sizeof($values)>0) :
foreach ($values as $value) :
$posts = get_objects_in_term( $value, $attribute );
if (!is_wp_error($posts) && (sizeof($matched_products)>0 || $filtered)) :
$matched_products = array_intersect($posts, $matched_products);
elseif (!is_wp_error($posts)) :
$matched_products = $posts;
endif;
$filtered = true;
endforeach;
endif;
endforeach;
if ($filtered) :
$matched_products[] = 0;
$filtered_posts = array_intersect($filtered_posts, $matched_products);
endif;
endif;
return $filtered_posts;
}
add_filter('loop-shop-posts-in', 'jigoshop_layered_nav_query');
### Price Filtering
function jigoshop_price_filter( $filtered_posts ) {
if (isset($_GET['max_price']) && isset($_GET['min_price'])) :
$matched_products = array( 0 );
$matched_products_query = get_posts(array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'price',
'value' => array( $_GET['min_price'], $_GET['max_price'] ),
'type' => 'NUMERIC',
'compare' => 'BETWEEN'
)
),
'tax_query' => array(
array(
'taxonomy' => 'product_type',
'field' => 'slug',
'terms' => 'grouped',
'operator' => 'NOT IN'
)
)
));
if ($matched_products_query) :
foreach ($matched_products_query as $product) :
$matched_products[] = $product->ID;
endforeach;
endif;
// Get grouped product ids
$grouped_products = get_objects_in_term( get_term_by('slug', 'grouped', 'product_type')->term_id, 'product_type' );
if ($grouped_products) foreach ($grouped_products as $grouped_product) :
$children = get_children( 'post_parent='.$grouped_product.'&post_type=product' );
if ($children) foreach ($children as $product) :
$price = get_post_meta( $product->ID, 'price', true);
if ($price<=$_GET['max_price'] && $price>=$_GET['min_price']) :
$matched_products[] = $grouped_product;
break;
endif;
endforeach;
endforeach;
$filtered_posts = array_intersect($matched_products, $filtered_posts);
endif;
return $filtered_posts;
}
add_filter('loop-shop-posts-in', 'jigoshop_price_filter');

View File

@ -1,187 +0,0 @@
<?php
foreach(glob( dirname(__FILE__)."/shortcodes/*.php" ) as $filename) include_once($filename);
### Recent Products #########################################################
function jigoshop_recent_products( $atts ) {
global $columns, $per_page;
extract(shortcode_atts(array(
'per_page' => '12',
'columns' => '4',
'orderby' => 'date',
'order' => 'desc'
), $atts));
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => $per_page,
'orderby' => $orderby,
'order' => $order,
'meta_query' => array(
array(
'key' => 'visibility',
'value' => array('catalog', 'visible'),
'compare' => 'IN'
)
)
);
query_posts($args);
ob_start();
jigoshop_get_template_part( 'loop', 'shop' );
wp_reset_query();
return ob_get_clean();
}
### Multiple Products #########################################################
function jigoshop_products($atts){
global $columns;
if (empty($atts)) return;
extract(shortcode_atts(array(
'columns' => '4',
'orderby' => 'title',
'order' => 'asc'
), $atts));
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'orderby' => $orderby,
'order' => $order,
'meta_query' => array(
array(
'key' => 'visibility',
'value' => array('catalog', 'visible'),
'compare' => 'IN'
)
)
);
if(isset($atts['skus'])){
$skus = explode(',', $atts['skus']);
array_walk($skus, create_function('&$val', '$val = trim($val);'));
$args['meta_query'][] = array(
'key' => 'sku',
'value' => $skus,
'compare' => 'IN'
);
}
if(isset($atts['ids'])){
$ids = explode(',', $atts['ids']);
array_walk($ids, create_function('&$val', '$val = trim($val);'));
$args['post__in'] = $ids;
}
query_posts($args);
ob_start();
jigoshop_get_template_part( 'loop', 'shop' );
wp_reset_query();
return ob_get_clean();
}
### Single Product ############################################################
function jigoshop_product($atts){
if (empty($atts)) return;
$args = array(
'post_type' => 'product',
'posts_per_page' => 1,
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'visibility',
'value' => array('catalog', 'visible'),
'compare' => 'IN'
)
)
);
if(isset($atts['sku'])){
$args['meta_query'][] = array(
'key' => 'sku',
'value' => $atts['sku'],
'compare' => '='
);
}
if(isset($atts['id'])){
$args['p'] = $atts['id'];
}
query_posts($args);
ob_start();
jigoshop_get_template_part( 'loop', 'shop' );
wp_reset_query();
return ob_get_clean();
}
### Featured Products #########################################################
function jigoshop_featured_products( $atts ) {
global $columns, $per_page;
extract(shortcode_atts(array(
'per_page' => '12',
'columns' => '4',
'orderby' => 'date',
'order' => 'desc'
), $atts));
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => $per_page,
'orderby' => $orderby,
'order' => $order,
'meta_query' => array(
array(
'key' => 'visibility',
'value' => array('catalog', 'visible'),
'compare' => 'IN'
),
array(
'key' => 'featured',
'value' => 'yes'
)
)
);
query_posts($args);
ob_start();
jigoshop_get_template_part( 'loop', 'shop' );
wp_reset_query();
return ob_get_clean();
}
### Shortcodes #########################################################
add_shortcode('product', 'jigoshop_product');
add_shortcode('products', 'jigoshop_products');
add_shortcode('recent_products', 'jigoshop_recent_products');
add_shortcode('featured_products', 'jigoshop_featured_products');
add_shortcode('jigoshop_cart', 'get_jigoshop_cart');
add_shortcode('jigoshop_checkout', 'get_jigoshop_checkout');
add_shortcode('jigoshop_order_tracking', 'get_jigoshop_order_tracking');
add_shortcode('jigoshop_my_account', 'get_jigoshop_my_account');
add_shortcode('jigoshop_edit_address', 'get_jigoshop_edit_address');
add_shortcode('jigoshop_change_password', 'get_jigoshop_change_password');
add_shortcode('jigoshop_view_order', 'get_jigoshop_view_order');
add_shortcode('jigoshop_pay', 'get_jigoshop_pay');
add_shortcode('jigoshop_thankyou', 'get_jigoshop_thankyou');

View File

@ -1,409 +0,0 @@
<?php
/**
* Custom Post Types
**/
function jigoshop_post_type() {
global $wpdb;
$shop_page_id = get_option('jigoshop_shop_page_id');
$base_slug = $shop_page_id && get_page_uri( $shop_page_id ) ? get_page_uri( $shop_page_id ) : 'shop';
if (get_option('jigoshop_prepend_shop_page_to_urls')=="yes") :
$category_base = trailingslashit($base_slug);
else :
$category_base = '';
endif;
register_taxonomy( 'product_cat',
array('product'),
array(
'hierarchical' => true,
'update_count_callback' => '_update_post_term_count',
'labels' => array(
'name' => __( 'Product Categories', 'jigoshop'),
'singular_name' => __( 'Product Category', 'jigoshop'),
'search_items' => __( 'Search Product Categories', 'jigoshop'),
'all_items' => __( 'All Product Categories', 'jigoshop'),
'parent_item' => __( 'Parent Product Category', 'jigoshop'),
'parent_item_colon' => __( 'Parent Product Category:', 'jigoshop'),
'edit_item' => __( 'Edit Product Category', 'jigoshop'),
'update_item' => __( 'Update Product Category', 'jigoshop'),
'add_new_item' => __( 'Add New Product Category', 'jigoshop'),
'new_item_name' => __( 'New Product Category Name', 'jigoshop')
),
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => $category_base . _x('product-category', 'slug', 'jigoshop'), 'with_front' => false ),
)
);
register_taxonomy( 'product_tag',
array('product'),
array(
'hierarchical' => false,
'labels' => array(
'name' => __( 'Product Tags', 'jigoshop'),
'singular_name' => __( 'Product Tag', 'jigoshop'),
'search_items' => __( 'Search Product Tags', 'jigoshop'),
'all_items' => __( 'All Product Tags', 'jigoshop'),
'parent_item' => __( 'Parent Product Tag', 'jigoshop'),
'parent_item_colon' => __( 'Parent Product Tag:', 'jigoshop'),
'edit_item' => __( 'Edit Product Tag', 'jigoshop'),
'update_item' => __( 'Update Product Tag', 'jigoshop'),
'add_new_item' => __( 'Add New Product Tag', 'jigoshop'),
'new_item_name' => __( 'New Product Tag Name', 'jigoshop')
),
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => $category_base . _x('product-tag', 'slug', 'jigoshop'), 'with_front' => false ),
)
);
$attribute_taxonomies = jigoshop::$attribute_taxonomies;
if ( $attribute_taxonomies ) :
foreach ($attribute_taxonomies as $tax) :
$name = 'product_attribute_'.strtolower(sanitize_title($tax->attribute_name));
$hierarchical = true;
if ($name) :
register_taxonomy( $name,
array('product'),
array(
'hierarchical' => $hierarchical,
'labels' => array(
'name' => $tax->attribute_name,
'singular_name' =>$tax->attribute_name,
'search_items' => __( 'Search ', 'jigoshop') . $tax->attribute_name,
'all_items' => __( 'All ', 'jigoshop') . $tax->attribute_name,
'parent_item' => __( 'Parent ', 'jigoshop') . $tax->attribute_name,
'parent_item_colon' => __( 'Parent ', 'jigoshop') . $tax->attribute_name . ':',
'edit_item' => __( 'Edit ', 'jigoshop') . $tax->attribute_name,
'update_item' => __( 'Update ', 'jigoshop') . $tax->attribute_name,
'add_new_item' => __( 'Add New ', 'jigoshop') . $tax->attribute_name,
'new_item_name' => __( 'New ', 'jigoshop') . $tax->attribute_name
),
'show_ui' => false,
'query_var' => true,
'show_in_nav_menus' => false,
'rewrite' => array( 'slug' => $category_base . strtolower(sanitize_title($tax->attribute_name)), 'with_front' => false, 'hierarchical' => $hierarchical ),
)
);
endif;
endforeach;
endif;
register_post_type( "product",
array(
'labels' => array(
'name' => __( 'Products', 'jigoshop' ),
'singular_name' => __( 'Product', 'jigoshop' ),
'add_new' => __( 'Add Product', 'jigoshop' ),
'add_new_item' => __( 'Add New Product', 'jigoshop' ),
'edit' => __( 'Edit', 'jigoshop' ),
'edit_item' => __( 'Edit Product', 'jigoshop' ),
'new_item' => __( 'New Product', 'jigoshop' ),
'view' => __( 'View Product', 'jigoshop' ),
'view_item' => __( 'View Product', 'jigoshop' ),
'search_items' => __( 'Search Products', 'jigoshop' ),
'not_found' => __( 'No Products found', 'jigoshop' ),
'not_found_in_trash' => __( 'No Products found in trash', 'jigoshop' ),
'parent' => __( 'Parent Product', 'jigoshop' )
),
'description' => __( 'This is where you can add new products to your store.', 'jigoshop' ),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'publicly_queryable' => true,
'exclude_from_search' => false,
'menu_position' => 57,
'hierarchical' => true,
'rewrite' => array( 'slug' => $base_slug, 'with_front' => false ),
'query_var' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments'/*, 'page-attributes'*/ ),
'has_archive' => $base_slug,
'show_in_nav_menus' => false,
)
);
register_post_type( "product_variation",
array(
'labels' => array(
'name' => __( 'Variations', 'jigoshop' ),
'singular_name' => __( 'Variation', 'jigoshop' ),
'add_new' => __( 'Add Variation', 'jigoshop' ),
'add_new_item' => __( 'Add New Variation', 'jigoshop' ),
'edit' => __( 'Edit', 'jigoshop' ),
'edit_item' => __( 'Edit Variation', 'jigoshop' ),
'new_item' => __( 'New Variation', 'jigoshop' ),
'view' => __( 'View Variation', 'jigoshop' ),
'view_item' => __( 'View Variation', 'jigoshop' ),
'search_items' => __( 'Search Variations', 'jigoshop' ),
'not_found' => __( 'No Variations found', 'jigoshop' ),
'not_found_in_trash' => __( 'No Variations found in trash', 'jigoshop' ),
'parent' => __( 'Parent Variation', 'jigoshop' )
),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'publicly_queryable' => true,
'exclude_from_search' => true,
'hierarchical' => false,
'rewrite' => false,
'query_var' => true,
'supports' => array( 'title', 'editor', 'custom-fields' ),
'show_in_nav_menus' => false,
'show_in_menu' => 'edit.php?post_type=product'
)
);
register_taxonomy( 'product_type',
array('product'),
array(
'hierarchical' => false,
'show_ui' => false,
'query_var' => true,
'show_in_nav_menus' => false,
)
);
register_post_type( "shop_order",
array(
'labels' => array(
'name' => __( 'Orders', 'jigoshop' ),
'singular_name' => __( 'Order', 'jigoshop' ),
'add_new' => __( 'Add Order', 'jigoshop' ),
'add_new_item' => __( 'Add New Order', 'jigoshop' ),
'edit' => __( 'Edit', 'jigoshop' ),
'edit_item' => __( 'Edit Order', 'jigoshop' ),
'new_item' => __( 'New Order', 'jigoshop' ),
'view' => __( 'View Order', 'jigoshop' ),
'view_item' => __( 'View Order', 'jigoshop' ),
'search_items' => __( 'Search Orders', 'jigoshop' ),
'not_found' => __( 'No Orders found', 'jigoshop' ),
'not_found_in_trash' => __( 'No Orders found in trash', 'jigoshop' ),
'parent' => __( 'Parent Orders', 'jigoshop' )
),
'description' => __( 'This is where store orders are stored.', 'jigoshop' ),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'publicly_queryable' => false,
'exclude_from_search' => true,
'menu_position' => 58,
'hierarchical' => false,
'show_in_nav_menus' => false,
'rewrite' => false,
'query_var' => true,
'supports' => array( 'title', 'comments' ),
'has_archive' => false
)
);
register_taxonomy( 'shop_order_status',
array('shop_order'),
array(
'hierarchical' => true,
'update_count_callback' => '_update_post_term_count',
'labels' => array(
'name' => __( 'Order statuses', 'jigoshop'),
'singular_name' => __( 'Order status', 'jigoshop'),
'search_items' => __( 'Search Order statuses', 'jigoshop'),
'all_items' => __( 'All Order statuses', 'jigoshop'),
'parent_item' => __( 'Parent Order status', 'jigoshop'),
'parent_item_colon' => __( 'Parent Order status:', 'jigoshop'),
'edit_item' => __( 'Edit Order status', 'jigoshop'),
'update_item' => __( 'Update Order status', 'jigoshop'),
'add_new_item' => __( 'Add New Order status', 'jigoshop'),
'new_item_name' => __( 'New Order status Name', 'jigoshop')
),
'show_ui' => false,
'show_in_nav_menus' => false,
'query_var' => true,
'rewrite' => false,
)
);
if (get_option('jigowatt_update_rewrite_rules')=='1') :
// Re-generate rewrite rules
global $wp_rewrite;
$wp_rewrite->flush_rules();
update_option('jigowatt_update_rewrite_rules', '0');
endif;
}
/**
* Categories ordering
*/
/**
* Add a table to $wpdb to benefit from wordpress meta api
*/
function taxonomy_metadata_wpdbfix() {
global $wpdb;
$wpdb->jigoshop_termmeta = "{$wpdb->prefix}jigoshop_termmeta";
}
add_action('init','taxonomy_metadata_wpdbfix');
add_action('switch_blog','taxonomy_metadata_wpdbfix');
/**
* Add product_cat ordering to get_terms
*
* It enables the support a 'menu_order' parameter to get_terms for the product_cat taxonomy.
* By default it is 'ASC'. It accepts 'DESC' too
*
* To disable it, set it ot false (or 0)
*
*/
function jigoshop_terms_clauses($clauses, $taxonomies, $args ) {
global $wpdb;
// wordpress should give us the taxonomies asked when calling the get_terms function
if( !in_array('product_cat', (array)$taxonomies) ) return $clauses;
// query order
if( isset($args['menu_order']) && !$args['menu_order']) return $clauses; // menu_order is false so we do not add order clause
// query fields
if( strpos('COUNT(*)', $clauses['fields']) === false ) $clauses['fields'] .= ', tm.* ';
//query join
$clauses['join'] .= " LEFT JOIN {$wpdb->jigoshop_termmeta} AS tm ON (t.term_id = tm.jigoshop_term_id AND tm.meta_key = 'order') ";
// default to ASC
if( ! isset($args['menu_order']) || ! in_array( strtoupper($args['menu_order']), array('ASC', 'DESC')) ) $args['menu_order'] = 'ASC';
$order = "ORDER BY CAST(tm.meta_value AS SIGNED) " . $args['menu_order'];
if ( $clauses['orderby'] ):
$clauses['orderby'] = str_replace ('ORDER BY', $order . ',', $clauses['orderby'] );
else:
$clauses['orderby'] = $order;
endif;
return $clauses;
}
add_filter( 'terms_clauses', 'jigoshop_terms_clauses', 10, 3);
/**
* Reorder on category insertion
*
* @param int $term_id
*/
function jigoshop_create_product_cat ($term_id) {
$next_id = null;
$term = get_term($term_id, 'product_cat');
// gets the sibling terms
$siblings = get_terms('product_cat', "parent={$term->parent}&menu_order=ASC&hide_empty=0");
foreach ($siblings as $sibling) {
if( $sibling->term_id == $term_id ) continue;
$next_id = $sibling->term_id; // first sibling term of the hierachy level
break;
}
// reorder
jigoshop_order_categories ( $term, $next_id );
}
add_action("create_product_cat", 'jigoshop_create_product_cat');
/**
* Delete terms metas on deletion
*
* @param int $term_id
*/
function jigoshop_delete_product_cat($term_id) {
$term_id = (int) $term_id;
if(!$term_id) return;
global $wpdb;
$wpdb->query("DELETE FROM {$wpdb->jigoshop_termmeta} WHERE `jigoshop_term_id` = " . $term_id);
}
add_action("delete_product_cat", 'jigoshop_delete_product_cat');
/**
* Move a category before the a given element of its hierarchy level
*
* @param object $the_term
* @param int $next_id the id of the next slibling element in save hierachy level
* @param int $index
* @param int $terms
*/
function jigoshop_order_categories ( $the_term, $next_id, $index=0, $terms=null ) {
if( ! $terms ) $terms = get_terms('product_cat', 'menu_order=ASC&hide_empty=0&parent=0');
if( empty( $terms ) ) return $index;
$id = $the_term->term_id;
$term_in_level = false; // flag: is our term to order in this level of terms
foreach ($terms as $term) {
if( $term->term_id == $id ) { // our term to order, we skip
$term_in_level = true;
continue; // our term to order, we skip
}
// the nextid of our term to order, lets move our term here
if(null !== $next_id && $term->term_id == $next_id) {
$index++;
$index = jigoshop_set_category_order($id, $index, true);
}
// set order
$index++;
$index = jigoshop_set_category_order($term->term_id, $index);
// if that term has children we walk through them
$children = get_terms('product_cat', "parent={$term->term_id}&menu_order=ASC&hide_empty=0");
if( !empty($children) ) {
$index = jigoshop_order_categories ( $the_term, $next_id, $index, $children );
}
}
// no nextid meaning our term is in last position
if( $term_in_level && null === $next_id )
$index = jigoshop_set_category_order($id, $index+1, true);
return $index;
}
/**
* Set the sort order of a category
*
* @param int $term_id
* @param int $index
* @param bool $recursive
*/
function jigoshop_set_category_order ($term_id, $index, $recursive=false) {
global $wpdb;
$term_id = (int) $term_id;
$index = (int) $index;
update_metadata('jigoshop_term', $term_id, 'order', $index);
if( ! $recursive ) return $index;
$children = get_terms('product_cat', "parent=$term_id&menu_order=ASC&hide_empty=0");
foreach ( $children as $term ) {
$index ++;
$index = jigoshop_set_category_order ($term->term_id, $index, true);
}
return $index;
}

View File

@ -1,79 +0,0 @@
<?php
/**
* ACTIONS USED IN TEMPLATE FILES
*
**/
/* Content Wrappers */
add_action( 'jigoshop_before_main_content', 'jigoshop_output_content_wrapper', 10);
add_action( 'jigoshop_after_main_content', 'jigoshop_output_content_wrapper_end', 10);
/* Shop Messages */
add_action( 'jigoshop_before_single_product', 'jigoshop::show_messages', 10);
add_action( 'jigoshop_before_shop_loop', 'jigoshop::show_messages', 10);
/* Sale flashes */
add_action( 'jigoshop_before_shop_loop_item_title', 'jigoshop_show_product_sale_flash', 10, 2);
add_action( 'jigoshop_before_single_product_summary', 'jigoshop_show_product_sale_flash', 10, 2);
/* Breadcrumbs */
add_action( 'jigoshop_before_main_content', 'jigoshop_breadcrumb', 20, 0);
/* Sidebar */
add_action( 'jigoshop_sidebar', 'jigoshop_get_sidebar', 10);
/* Products Loop */
add_action( 'jigoshop_after_shop_loop_item', 'jigoshop_template_loop_add_to_cart', 10, 2);
add_action( 'jigoshop_before_shop_loop_item_title', 'jigoshop_template_loop_product_thumbnail', 10, 2);
add_action( 'jigoshop_after_shop_loop_item_title', 'jigoshop_template_loop_price', 10, 2);
/* Before Single Products */
add_action( 'jigoshop_before_single_product', 'jigoshop_check_product_visibility', 10, 2);
/* Before Single Products Summary Div */
add_action( 'jigoshop_before_single_product_summary', 'jigoshop_show_product_images', 20);
add_action( 'jigoshop_product_thumbnails', 'jigoshop_show_product_thumbnails', 20 );
/* After Single Products Summary Div */
add_action( 'jigoshop_after_single_product_summary', 'jigoshop_output_product_data_tabs', 10);
add_action( 'jigoshop_after_single_product_summary', 'jigoshop_output_related_products', 20);
/* Product Summary Box */
add_action( 'jigoshop_template_single_summary', 'jigoshop_template_single_price', 10, 2);
add_action( 'jigoshop_template_single_summary', 'jigoshop_template_single_excerpt', 20, 2);
add_action( 'jigoshop_template_single_summary', 'jigoshop_template_single_meta', 40, 2);
add_action( 'jigoshop_template_single_summary', 'jigoshop_template_single_sharing', 50, 2);
/* Product Add to cart */
add_action( 'jigoshop_template_single_summary', 'jigoshop_template_single_add_to_cart', 30, 2 );
add_action( 'simple_add_to_cart', 'jigoshop_simple_add_to_cart' );
add_action( 'virtual_add_to_cart', 'jigoshop_simple_add_to_cart' );
add_action( 'downloadable_add_to_cart', 'jigoshop_downloadable_add_to_cart' );
add_action( 'grouped_add_to_cart', 'jigoshop_grouped_add_to_cart' );
add_action( 'variable_add_to_cart', 'jigoshop_variable_add_to_cart' );
/* Product Add to Cart forms */
add_action( 'jigoshop_add_to_cart_form', 'jigoshop_add_to_cart_form_nonce', 10);
/* Pagination in loop-shop */
add_action( 'jigoshop_pagination', 'jigoshop_pagination', 10 );
/* Product page tabs */
add_action( 'jigoshop_product_tabs', 'jigoshop_product_description_tab', 10 );
add_action( 'jigoshop_product_tabs', 'jigoshop_product_attributes_tab', 20 );
add_action( 'jigoshop_product_tabs', 'jigoshop_product_reviews_tab', 30 );
add_action( 'jigoshop_product_tab_panels', 'jigoshop_product_description_panel', 10 );
add_action( 'jigoshop_product_tab_panels', 'jigoshop_product_attributes_panel', 20 );
add_action( 'jigoshop_product_tab_panels', 'jigoshop_product_reviews_panel', 30 );
/* Checkout */
add_action( 'before_checkout_form', 'jigoshop_checkout_login_form', 10 );
/* Remove the singular class for jigoshop single product */
add_action( 'after_setup_theme', 'jigoshop_body_classes_check' );
function jigoshop_body_classes_check () {
if( has_filter( 'body_class', 'twentyeleven_body_classes' ) )
add_filter( 'body_class', 'jigoshop_body_classes' );
}

View File

@ -1,793 +0,0 @@
<?php
/**
* FUNCTIONS USED IN TEMPLATE FILES
**/
/**
* Front page archive/shop template
*/
if (!function_exists('jigoshop_front_page_archive')) {
function jigoshop_front_page_archive() {
global $paged;
if ( is_front_page() && is_page( get_option('jigoshop_shop_page_id') )) :
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} else if ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
query_posts( array( 'page_id' => '', 'post_type' => 'product', 'paged' => $paged ) );
define('SHOP_IS_ON_FRONT', true);
endif;
}
}
add_action('wp_head', 'jigoshop_front_page_archive', 0);
/**
* Content Wrappers
**/
if (!function_exists('jigoshop_output_content_wrapper')) {
function jigoshop_output_content_wrapper() {
if( get_option('template') === 'twentyeleven' ) echo '<section id="primary"><div id="content" role="main">';
else echo '<div id="container"><div id="content" role="main">';
}
}
if (!function_exists('jigoshop_output_content_wrapper_end')) {
function jigoshop_output_content_wrapper_end() {
if( get_option('template') === 'twentyeleven' ) echo '</section></div>';
else echo '</div></div>';
}
}
/**
* Sale Flash
**/
if (!function_exists('jigoshop_show_product_sale_flash')) {
function jigoshop_show_product_sale_flash( $post, $_product ) {
if ($_product->is_on_sale()) echo '<span class="onsale">'.__('Sale!', 'jigoshop').'</span>';
}
}
/**
* Sidebar
**/
if (!function_exists('jigoshop_get_sidebar')) {
function jigoshop_get_sidebar() {
get_sidebar('shop');
}
}
/**
* Products Loop
**/
if (!function_exists('jigoshop_template_loop_add_to_cart')) {
function jigoshop_template_loop_add_to_cart( $post, $_product ) {
?><a href="<?php echo $_product->add_to_cart_url(); ?>" class="button"><?php _e('Add to cart', 'jigoshop'); ?></a><?php
}
}
if (!function_exists('jigoshop_template_loop_product_thumbnail')) {
function jigoshop_template_loop_product_thumbnail( $post, $_product ) {
echo jigoshop_get_product_thumbnail();
}
}
if (!function_exists('jigoshop_template_loop_price')) {
function jigoshop_template_loop_price( $post, $_product ) {
?><span class="price"><?php echo $_product->get_price_html(); ?></span><?php
}
}
/**
* Check product visibility in loop
**/
if (!function_exists('jigoshop_check_product_visibility')) {
function jigoshop_check_product_visibility( $post, $_product ) {
if (!$_product->is_visible() && $post->post_parent > 0) : wp_safe_redirect(get_permalink($post->post_parent)); exit; endif;
if (!$_product->is_visible()) : wp_safe_redirect(home_url()); exit; endif;
}
}
/**
* Before Single Products Summary Div
**/
if (!function_exists('jigoshop_show_product_images')) {
function jigoshop_show_product_images() {
global $_product, $post;
echo '<div class="images">';
$thumb_id = 0;
if (has_post_thumbnail()) :
$thumb_id = get_post_thumbnail_id();
$large_thumbnail_size = apply_filters('single_product_large_thumbnail_size', 'shop_large');
echo '<a href="'.wp_get_attachment_url($thumb_id).'" class="zoom" rel="thumbnails">';
the_post_thumbnail($large_thumbnail_size);
echo '</a>';
else :
echo '<img src="'.jigoshop::plugin_url().'/assets/images/placeholder.png" alt="Placeholder" />';
endif;
do_action('jigoshop_product_thumbnails');
echo '</div>';
}
}
if (!function_exists('jigoshop_show_product_thumbnails')) {
function jigoshop_show_product_thumbnails() {
global $_product, $post;
echo '<div class="thumbnails">';
$thumb_id = get_post_thumbnail_id();
$small_thumbnail_size = apply_filters('single_product_small_thumbnail_size', 'shop_thumbnail');
$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );
$attachments = get_posts($args);
if ($attachments) :
$loop = 0;
$columns = 3;
foreach ( $attachments as $attachment ) :
if ($thumb_id==$attachment->ID) continue;
$loop++;
$_post = & get_post( $attachment->ID );
$url = wp_get_attachment_url($_post->ID);
$post_title = esc_attr($_post->post_title);
$image = wp_get_attachment_image($attachment->ID, $small_thumbnail_size);
echo '<a href="'.$url.'" title="'.$post_title.'" rel="thumbnails" class="zoom ';
if ($loop==1 || ($loop-1)%$columns==0) echo 'first';
if ($loop%$columns==0) echo 'last';
echo '">'.$image.'</a>';
endforeach;
endif;
wp_reset_query();
echo '</div>';
}
}
/**
* After Single Products Summary Div
**/
if (!function_exists('jigoshop_output_product_data_tabs')) {
function jigoshop_output_product_data_tabs() {
if (isset($_COOKIE["current_tab"])) $current_tab = $_COOKIE["current_tab"]; else $current_tab = '#tab-description';
?>
<div id="tabs">
<ul class="tabs">
<?php do_action('jigoshop_product_tabs', $current_tab); ?>
</ul>
<?php do_action('jigoshop_product_tab_panels'); ?>
</div>
<?php
}
}
/**
* Product summary box
**/
if (!function_exists('jigoshop_template_single_price')) {
function jigoshop_template_single_price( $post, $_product ) {
?><p class="price"><?php echo $_product->get_price_html(); ?></p><?php
}
}
if (!function_exists('jigoshop_template_single_excerpt')) {
function jigoshop_template_single_excerpt( $post, $_product ) {
if ($post->post_excerpt) echo wpautop(wptexturize($post->post_excerpt));
}
}
if (!function_exists('jigoshop_template_single_meta')) {
function jigoshop_template_single_meta( $post, $_product ) {
?>
<div class="product_meta"><?php if ($_product->is_type('simple') && get_option('jigoshop_enable_sku')=='yes') : ?><span class="sku">SKU: <?php echo $_product->sku; ?>.</span><?php endif; ?><?php echo $_product->get_categories( ', ', ' <span class="posted_in">Posted in ', '.</span>'); ?><?php echo $_product->get_tags( ', ', ' <span class="tagged_as">Tagged as ', '.</span>'); ?></div>
<?php
}
}
if (!function_exists('jigoshop_template_single_sharing')) {
function jigoshop_template_single_sharing( $post, $_product ) {
if (get_option('jigoshop_sharethis')) :
echo '<div class="social">
<iframe src="https://www.facebook.com/plugins/like.php?href='.urlencode(get_permalink($post->ID)).'&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>
<span class="st_twitter"></span><span class="st_email"></span><span class="st_sharethis"></span><span class="st_plusone_button"></span>
</div>';
endif;
}
}
/**
* Product Add to cart buttons
**/
if (!function_exists('jigoshop_template_single_add_to_cart')) {
function jigoshop_template_single_add_to_cart( $post, $_product ) {
do_action( $_product->product_type . '_add_to_cart' );
}
}
if (!function_exists('jigoshop_simple_add_to_cart')) {
function jigoshop_simple_add_to_cart() {
global $_product; $availability = $_product->get_availability();
if ($availability['availability']) : ?><p class="stock <?php echo $availability['class'] ?>"><?php echo $availability['availability']; ?></p><?php endif;
?>
<form action="<?php echo $_product->add_to_cart_url(); ?>" class="cart" method="post">
<div class="quantity"><input name="quantity" value="1" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div>
<button type="submit" class="button-alt"><?php _e('Add to cart', 'jigoshop'); ?></button>
<?php do_action('jigoshop_add_to_cart_form'); ?>
</form>
<?php
}
}
if (!function_exists('jigoshop_virtual_add_to_cart')) {
function jigoshop_virtual_add_to_cart() {
jigoshop_simple_add_to_cart();
}
}
if (!function_exists('jigoshop_downloadable_add_to_cart')) {
function jigoshop_downloadable_add_to_cart() {
global $_product; $availability = $_product->get_availability();
if ($availability['availability']) : ?><p class="stock <?php echo $availability['class'] ?>"><?php echo $availability['availability']; ?></p><?php endif;
?>
<form action="<?php echo $_product->add_to_cart_url(); ?>" class="cart" method="post">
<button type="submit" class="button-alt"><?php _e('Add to cart', 'jigoshop'); ?></button>
<?php do_action('jigoshop_add_to_cart_form'); ?>
</form>
<?php
}
}
if (!function_exists('jigoshop_grouped_add_to_cart')) {
function jigoshop_grouped_add_to_cart() {
global $_product;
?>
<form action="<?php echo $_product->add_to_cart_url(); ?>" class="cart" method="post">
<table cellspacing="0">
<tbody>
<?php foreach ($_product->children as $child) : $child_product = &new jigoshop_product( $child->ID ); $cavailability = $child_product->get_availability(); ?>
<tr>
<td><div class="quantity"><input name="quantity[<?php echo $child->ID; ?>]" value="0" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div></td>
<td><label for="product-<?php echo $child_product->id; ?>"><?php
if ($child_product->is_visible()) echo '<a href="'.get_permalink($child->ID).'">';
echo $child_product->get_title();
if ($child_product->is_visible()) echo '</a>';
?></label></td>
<td class="price"><?php echo $child_product->get_price_html(); ?><small class="stock <?php echo $cavailability['class'] ?>"><?php echo $cavailability['availability']; ?></small></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<button type="submit" class="button-alt"><?php _e('Add to cart', 'jigoshop'); ?></button>
<?php do_action('jigoshop_add_to_cart_form'); ?>
</form>
<?php
}
}
if (!function_exists('jigoshop_variable_add_to_cart')) {
function jigoshop_variable_add_to_cart() {
global $post, $_product;
$attributes = maybe_unserialize( get_post_meta($post->ID, 'product_attributes', true) );
if (!isset($attributes)) $attributes = array();
?>
<form action="<?php echo $_product->add_to_cart_url(); ?>" class="variations_form cart" method="post">
<table class="variations" cellspacing="0">
<tbody>
<?php
foreach ($attributes as $attribute) :
if ( $attribute['variation']!=='yes' ) continue;
$options = $attribute['value'];
if (!is_array($options)) $options = explode(',', $options);
echo '<tr><td><label for="'.sanitize_title($attribute['name']).'">'.ucfirst($attribute['name']).'</label></td><td><select id="'.sanitize_title($attribute['name']).'" name="tax_'.sanitize_title($attribute['name']).'"><option value="">'.__('Choose an option', 'jigoshop').'&hellip;</option><option>'.implode('</option><option>', $options).'</option></select></td></tr>';
endforeach;
?>
</tbody>
</table>
<div class="single_variation"></div>
<div class="variations_button" style="display:none;">
<div class="quantity"><input name="quantity" value="1" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div>
<button type="submit" class="button-alt"><?php _e('Add to cart', 'jigoshop'); ?></button>
</div>
<?php do_action('jigoshop_add_to_cart_form'); ?>
</form>
<?php
}
}
/**
* Product Add to Cart forms
**/
if (!function_exists('jigoshop_add_to_cart_form_nonce')) {
function jigoshop_add_to_cart_form_nonce() {
jigoshop::nonce_field('add_to_cart');
}
}
/**
* Pagination
**/
if (!function_exists('jigoshop_pagination')) {
function jigoshop_pagination() {
global $wp_query;
if ( $wp_query->max_num_pages > 1 ) :
?>
<div class="navigation">
<div class="nav-next"><?php next_posts_link( __( 'Next <span class="meta-nav">&rarr;</span>', 'jigoshop' ) ); ?></div>
<div class="nav-previous"><?php previous_posts_link( __( '<span class="meta-nav">&larr;</span> Previous', 'jigoshop' ) ); ?></div>
</div>
<?php
endif;
}
}
/**
* Product page tabs
**/
if (!function_exists('jigoshop_product_description_tab')) {
function jigoshop_product_description_tab( $current_tab ) {
?>
<li <?php if ($current_tab=='#tab-description') echo 'class="active"'; ?>><a href="#tab-description"><?php _e('Description', 'jigoshop'); ?></a></li>
<?php
}
}
if (!function_exists('jigoshop_product_attributes_tab')) {
function jigoshop_product_attributes_tab( $current_tab ) {
global $_product;
if ($_product->has_attributes()) : ?><li <?php if ($current_tab=='#tab-attributes') echo 'class="active"'; ?>><a href="#tab-attributes"><?php _e('Additional Information', 'jigoshop'); ?></a></li><?php endif;
}
}
if (!function_exists('jigoshop_product_reviews_tab')) {
function jigoshop_product_reviews_tab( $current_tab ) {
if ( comments_open() ) : ?><li <?php if ($current_tab=='#tab-reviews') echo 'class="active"'; ?>><a href="#tab-reviews"><?php _e('Reviews', 'jigoshop'); ?><?php echo comments_number(' (0)', ' (1)', ' (%)'); ?></a></li><?php endif;
}
}
/**
* Product page tab panels
**/
if (!function_exists('jigoshop_product_description_panel')) {
function jigoshop_product_description_panel() {
echo '<div class="panel" id="tab-description">';
echo '<h2>' . apply_filters('jigoshop_product_description_heading', __('Product Description', 'jigoshop')) . '</h2>';
the_content();
echo '</div>';
}
}
if (!function_exists('jigoshop_product_attributes_panel')) {
function jigoshop_product_attributes_panel() {
global $_product;
echo '<div class="panel" id="tab-attributes">';
echo '<h2>' . apply_filters('jigoshop_product_description_heading', __('Additional Information', 'jigoshop')) . '</h2>';
$_product->list_attributes();
echo '</div>';
}
}
if (!function_exists('jigoshop_product_reviews_panel')) {
function jigoshop_product_reviews_panel() {
echo '<div class="panel" id="tab-reviews">';
comments_template();
echo '</div>';
}
}
/**
* Jigoshop Product Thumbnail
**/
if (!function_exists('jigoshop_get_product_thumbnail')) {
function jigoshop_get_product_thumbnail( $size = 'shop_small', $placeholder_width = 0, $placeholder_height = 0 ) {
global $post;
if (!$placeholder_width) $placeholder_width = jigoshop::get_var('shop_small_w');
if (!$placeholder_height) $placeholder_height = jigoshop::get_var('shop_small_h');
if ( has_post_thumbnail() ) return get_the_post_thumbnail($post->ID, $size); else return '<img src="'.jigoshop::plugin_url(). '/assets/images/placeholder.png" alt="Placeholder" width="'.$placeholder_width.'" height="'.$placeholder_height.'" />';
}
}
/**
* Jigoshop Related Products
**/
if (!function_exists('jigoshop_output_related_products')) {
function jigoshop_output_related_products() {
// 4 Related Products in 4 columns
jigoshop_related_products( 2, 2 );
}
}
if (!function_exists('jigoshop_related_products')) {
function jigoshop_related_products( $posts_per_page = 4, $post_columns = 4, $orderby = 'rand' ) {
global $_product, $columns, $per_page;
// Pass vars to loop
$per_page = $posts_per_page;
$columns = $post_columns;
$related = $_product->get_related();
if (sizeof($related)>0) :
echo '<div class="related products"><h2>'.__('Related Products', 'jigoshop').'</h2>';
$args = array(
'post_type' => 'product',
'ignore_sticky_posts' => 1,
'posts_per_page' => $per_page,
'orderby' => $orderby,
'post__in' => $related
);
$args = apply_filters('jigoshop_related_products_args', $args);
query_posts($args);
jigoshop_get_template_part( 'loop', 'shop' );
echo '</div>';
endif;
wp_reset_query();
}
}
/**
* Jigoshop Shipping Calculator
**/
if (!function_exists('jigoshop_shipping_calculator')) {
function jigoshop_shipping_calculator() {
if (jigoshop_shipping::$enabled && get_option('jigoshop_enable_shipping_calc')=='yes' && jigoshop_cart::needs_shipping()) :
?>
<form class="shipping_calculator" action="<?php echo jigoshop_cart::get_cart_url(); ?>" method="post">
<h2><a href="#" class="shipping-calculator-button"><?php _e('Calculate Shipping', 'jigoshop'); ?> <span>&darr;</span></a></h2>
<section class="shipping-calculator-form">
<p class="form-row">
<select name="calc_shipping_country" id="calc_shipping_country" class="country_to_state" rel="calc_shipping_state">
<option value=""><?php _e('Select a country&hellip;', 'jigoshop'); ?></option>
<?php
foreach(jigoshop_countries::get_allowed_countries() as $key=>$value) :
echo '<option value="'.$key.'"';
if (jigoshop_customer::get_shipping_country()==$key) echo 'selected="selected"';
echo '>'.$value.'</option>';
endforeach;
?>
</select>
</p>
<div class="col2-set">
<p class="form-row col-1">
<?php
$current_cc = jigoshop_customer::get_shipping_country();
$current_r = jigoshop_customer::get_shipping_state();
$states = jigoshop_countries::$states;
if (isset( $states[$current_cc][$current_r] )) :
// Dropdown
?>
<span>
<select name="calc_shipping_state" id="calc_shipping_state"><option value=""><?php _e('Select a state&hellip;', 'jigoshop'); ?></option><?php
foreach($states[$current_cc] as $key=>$value) :
echo '<option value="'.$key.'"';
if ($current_r==$key) echo 'selected="selected"';
echo '>'.$value.'</option>';
endforeach;
?></select>
</span>
<?php
else :
// Input
?>
<input type="text" class="input-text" value="<?php echo $current_r; ?>" placeholder="<?php _e('state', 'jigoshop'); ?>" name="calc_shipping_state" id="calc_shipping_state" />
<?php
endif;
?>
</p>
<p class="form-row col-2">
<input type="text" class="input-text" value="<?php echo jigoshop_customer::get_shipping_postcode(); ?>" placeholder="<?php _e('Postcode/Zip', 'jigoshop'); ?>" title="<?php _e('Postcode', 'jigoshop'); ?>" name="calc_shipping_postcode" id="calc_shipping_postcode" />
</p>
</div>
<p><button type="submit" name="calc_shipping" value="1" class="button"><?php _e('Update Totals', 'jigoshop'); ?></button></p>
<?php jigoshop::nonce_field('cart') ?>
</section>
</form>
<?php
endif;
}
}
/**
* Jigoshop Login Form
**/
if (!function_exists('jigoshop_login_form')) {
function jigoshop_login_form() {
if (is_user_logged_in()) return;
?>
<form method="post" class="login">
<p class="form-row form-row-first">
<label for="username"><?php _e('Username', 'jigoshop'); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="username" id="username" />
</p>
<p class="form-row form-row-last">
<label for="password"><?php _e('Password', 'jigoshop'); ?> <span class="required">*</span></label>
<input class="input-text" type="password" name="password" id="password" />
</p>
<div class="clear"></div>
<p class="form-row">
<?php jigoshop::nonce_field('login', 'login') ?>
<input type="submit" class="button" name="login" value="<?php _e('Login', 'jigoshop'); ?>" />
<a class="lost_password" href="<?php echo home_url('wp-login.php?action=lostpassword'); ?>"><?php _e('Lost Password?', 'jigoshop'); ?></a>
</p>
</form>
<?php
}
}
/**
* Jigoshop Login Form
**/
if (!function_exists('jigoshop_checkout_login_form')) {
function jigoshop_checkout_login_form() {
if (is_user_logged_in()) return;
?><p class="info"><?php _e('Already registered?', 'jigoshop'); ?> <a href="#" class="showlogin"><?php _e('Click here to login', 'jigoshop'); ?></a></p><?php
jigoshop_login_form();
}
}
/**
* Jigoshop Breadcrumb
**/
if (!function_exists('jigoshop_breadcrumb')) {
function jigoshop_breadcrumb( $delimiter = ' &rsaquo; ', $wrap_before = '<div id="breadcrumb">', $wrap_after = '</div>', $before = '', $after = '', $home = null ) {
global $post, $wp_query, $author, $paged;
if( !$home ) $home = _x('Home', 'breadcrumb', 'jigoshop');
$home_link = home_url();
$prepend = '';
if ( get_option('jigoshop_prepend_shop_page_to_urls')=="yes" && get_option('jigoshop_shop_page_id') && get_option('page_on_front') !== get_option('jigoshop_shop_page_id') )
$prepend = $before . '<a href="' . get_permalink( get_option('jigoshop_shop_page_id') ) . '">' . get_the_title( get_option('jigoshop_shop_page_id') ) . '</a> ' . $after . $delimiter;
if ( (!is_home() && !is_front_page() && !(is_post_type_archive() && get_option('page_on_front')==get_option('jigoshop_shop_page_id'))) || is_paged() ) :
echo $wrap_before;
echo $before . '<a class="home" href="' . $home_link . '">' . $home . '</a> ' . $after . $delimiter ;
if ( is_category() ) :
$cat_obj = $wp_query->get_queried_object();
$this_category = $cat_obj->term_id;
$this_category = get_category( $this_category );
if ($thisCat->parent != 0) :
$parent_category = get_category( $this_category->parent );
echo get_category_parents($parent_category, TRUE, $delimiter );
endif;
echo $before . single_cat_title('', false) . $after;
elseif ( is_tax('product_cat') ) :
//echo $before . '<a href="' . get_post_type_archive_link('product') . '">' . ucwords(get_option('jigoshop_shop_slug')) . '</a>' . $after . $delimiter;
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$parents = array();
$parent = $term->parent;
while ($parent):
$parents[] = $parent;
$new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ));
$parent = $new_parent->parent;
endwhile;
if(!empty($parents)):
$parents = array_reverse($parents);
foreach ($parents as $parent):
$item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ));
echo $before . '<a href="' . get_term_link( $item->slug, 'product_cat' ) . '">' . $item->name . '</a>' . $after . $delimiter;
endforeach;
endif;
$queried_object = $wp_query->get_queried_object();
echo $prepend . $before . $queried_object->name . $after;
elseif ( is_tax('product_tag') ) :
$queried_object = $wp_query->get_queried_object();
echo $prepend . $before . __('Products tagged &ldquo;', 'jigoshop') . $queried_object->name . '&rdquo;' . $after;
elseif ( is_day() ) :
echo $before . '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $after . $delimiter;
echo $before . '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a>' . $after . $delimiter;
echo $before . get_the_time('d') . $after;
elseif ( is_month() ) :
echo $before . '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $after . $delimiter;
echo $before . get_the_time('F') . $after;
elseif ( is_year() ) :
echo $before . get_the_time('Y') . $after;
elseif ( is_post_type_archive('product') && get_option('page_on_front') !== get_option('jigoshop_shop_page_id') ) :
$_name = get_option('jigoshop_shop_page_id') ? get_the_title( get_option('jigoshop_shop_page_id') ) : ucwords(get_option('jigoshop_shop_slug'));
if (is_search()) :
echo $before . '<a href="' . get_post_type_archive_link('product') . '">' . $_name . '</a>' . $delimiter . __('Search results for &ldquo;', 'jigoshop') . get_search_query() . '&rdquo;' . $after;
else :
echo $before . '<a href="' . get_post_type_archive_link('product') . '">' . $_name . '</a>' . $after;
endif;
elseif ( is_single() && !is_attachment() ) :
if ( get_post_type() == 'product' ) :
//echo $before . '<a href="' . get_post_type_archive_link('product') . '">' . ucwords(get_option('jigoshop_shop_slug')) . '</a>' . $after . $delimiter;
echo $prepend;
if ($terms = wp_get_object_terms( $post->ID, 'product_cat' )) :
$term = current($terms);
$parents = array();
$parent = $term->parent;
while ($parent):
$parents[] = $parent;
$new_parent = get_term_by( 'id', $parent, 'product_cat');
$parent = $new_parent->parent;
endwhile;
if(!empty($parents)):
$parents = array_reverse($parents);
foreach ($parents as $parent):
$item = get_term_by( 'id', $parent, 'product_cat');
echo $before . '<a href="' . get_term_link( $item->slug, 'product_cat' ) . '">' . $item->name . '</a>' . $after . $delimiter;
endforeach;
endif;
echo $before . '<a href="' . get_term_link( $term->slug, 'product_cat' ) . '">' . $term->name . '</a>' . $after . $delimiter;
endif;
echo $before . get_the_title() . $after;
elseif ( get_post_type() != 'post' ) :
$post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite;
echo $before . '<a href="' . get_post_type_archive_link(get_post_type()) . '">' . $post_type->labels->singular_name . '</a>' . $after . $delimiter;
echo $before . get_the_title() . $after;
else :
$cat = current(get_the_category());
echo get_category_parents($cat, TRUE, $delimiter);
echo $before . get_the_title() . $after;
endif;
elseif ( is_404() ) :
echo $before . __('Error 404', 'jigoshop') . $after;
elseif ( !is_single() && !is_page() && get_post_type() != 'post' ) :
$post_type = get_post_type_object(get_post_type());
if ($post_type) : echo $before . $post_type->labels->singular_name . $after; endif;
elseif ( is_attachment() ) :
$parent = get_post($post->post_parent);
$cat = get_the_category($parent->ID); $cat = $cat[0];
echo get_category_parents($cat, TRUE, '' . $delimiter);
echo $before . '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>' . $after . $delimiter;
echo $before . get_the_title() . $after;
elseif ( is_page() && !$post->post_parent ) :
echo $before . get_the_title() . $after;
elseif ( is_page() && $post->post_parent ) :
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
foreach ($breadcrumbs as $crumb) :
echo $crumb . '' . $delimiter;
endforeach;
echo $before . get_the_title() . $after;
elseif ( is_search() ) :
echo $before . __('Search results for &ldquo;', 'jigoshop') . get_search_query() . '&rdquo;' . $after;
elseif ( is_tag() ) :
echo $before . __('Posts tagged &ldquo;', 'jigoshop') . single_tag_title('', false) . '&rdquo;' . $after;
elseif ( is_author() ) :
$userdata = get_userdata($author);
echo $before . __('Author: ', 'jigoshop') . $userdata->display_name . $after;
endif;
if ( get_query_var('paged') ) :
echo ' (' . __('Page', 'jigoshop') . ' ' . get_query_var('paged') .')';
endif;
echo $wrap_after;
endif;
}
}
function jigoshop_body_classes ($classes) {
if( ! is_singular('product') ) return $classes;
$key = array_search('singular', $classes);
if ( $key !== false ) unset($classes[$key]);
return $classes;
}

View File

@ -1,110 +0,0 @@
<?php
### Templates ##################################################################
/*
* Templates are in the 'templates' folder. jigoshop looks for theme
* overides in /theme/jigoshop/ by default but this can be overwritten with JIGOSHOP_TEMPLATE_URL
*/
################################################################################
function jigoshop_template_loader( $template ) {
if ( is_single() && get_post_type() == 'product' ) {
jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-product' ) );
$template = locate_template( array( 'single-product.php', JIGOSHOP_TEMPLATE_URL . 'single-product.php' ) );
if ( ! $template ) $template = jigoshop::plugin_path() . '/templates/single-product.php';
}
elseif ( is_tax('product_cat') ) {
jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-product_cat' ) );
$template = locate_template( array( 'taxonomy-product_cat.php', JIGOSHOP_TEMPLATE_URL . 'taxonomy-product_cat.php' ) );
if ( ! $template ) $template = jigoshop::plugin_path() . '/templates/taxonomy-product_cat.php';
}
elseif ( is_tax('product_tag') ) {
jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-product_tag' ) );
$template = locate_template( array( 'taxonomy-product_tag.php', JIGOSHOP_TEMPLATE_URL . 'taxonomy-product_tag.php' ) );
if ( ! $template ) $template = jigoshop::plugin_path() . '/templates/taxonomy-product_tag.php';
}
elseif ( is_post_type_archive('product') || is_page( get_option('jigoshop_shop_page_id') )) {
jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-products' ) );
$template = locate_template( array( 'archive-product.php', JIGOSHOP_TEMPLATE_URL . 'archive-product.php' ) );
if ( ! $template ) $template = jigoshop::plugin_path() . '/templates/archive-product.php';
}
return $template;
}
add_filter( 'template_include', 'jigoshop_template_loader' );
################################################################################
// Get template part (for templates like loop)
################################################################################
function jigoshop_get_template_part( $slug, $name = '' ) {
if ($name=='shop') :
if (!locate_template(array( 'loop-shop.php', JIGOSHOP_TEMPLATE_URL . 'loop-shop.php' ))) :
load_template( jigoshop::plugin_path() . '/templates/loop-shop.php',false );
return;
endif;
endif;
get_template_part( JIGOSHOP_TEMPLATE_URL . $slug, $name );
}
################################################################################
// Get the reviews template (comments)
################################################################################
function jigoshop_comments_template($template) {
if(get_post_type() !== 'product') return $template;
if (file_exists( STYLESHEETPATH . '/' . JIGOSHOP_TEMPLATE_URL . 'single-product-reviews.php' ))
return STYLESHEETPATH . '/' . JIGOSHOP_TEMPLATE_URL . 'single-product-reviews.php';
else
return jigoshop::plugin_path() . '/templates/single-product-reviews.php';
}
add_filter('comments_template', 'jigoshop_comments_template' );
################################################################################
// Get other templates (e.g. product attributes)
################################################################################
function jigoshop_get_template($template_name, $require_once = true) {
if (file_exists( STYLESHEETPATH . '/' . JIGOSHOP_TEMPLATE_URL . $template_name )) load_template( STYLESHEETPATH . '/' . JIGOSHOP_TEMPLATE_URL . $template_name, $require_once );
elseif (file_exists( STYLESHEETPATH . '/' . $template_name )) load_template( STYLESHEETPATH . '/' . $template_name , $require_once);
else load_template( jigoshop::plugin_path() . '/templates/' . $template_name , $require_once);
}
################################################################################
// Get other templates (e.g. product attributes) - path
################################################################################
function jigoshop_get_template_file_url($template_name, $ssl = false) {
if (file_exists( STYLESHEETPATH . '/' . JIGOSHOP_TEMPLATE_URL . $template_name ))
$return = get_bloginfo('template_url') . '/' . JIGOSHOP_TEMPLATE_URL . $template_name;
elseif (file_exists( STYLESHEETPATH . '/' . $template_name ))
$return = get_bloginfo('template_url') . '/' . $template_name;
else
$return = jigoshop::plugin_url() . '/templates/' . $template_name;
if (get_option('jigoshop_force_ssl_checkout')=='yes' || is_ssl()) :
if ($ssl) $return = str_replace('http:', 'https:', $return);
endif;
return $return;
}

View File

@ -1,14 +0,0 @@
<?php
foreach(glob( dirname(__FILE__)."/widgets/*.php" ) as $filename) include_once($filename);
function jigoshop_register_widgets() {
register_widget('Jigoshop_Widget_Recent_Products');
register_widget('Jigoshop_Widget_Featured_Products');
register_widget('Jigoshop_Widget_Product_Categories');
register_widget('Jigoshop_Widget_Tag_Cloud');
register_widget('Jigoshop_Widget_Cart');
register_widget('Jigoshop_Widget_Layered_Nav');
register_widget('Jigoshop_Widget_Price_Filter');
register_widget('Jigoshop_Widget_Product_Search');
}
add_action('widgets_init', 'jigoshop_register_widgets');

View File

@ -1,255 +0,0 @@
<?php
/* Countries translations.
* This file is not included anywhere. It exists solely for use by xgettext.
*
* Don't translate this file, all those strings are to be translated in the .po files
*
* @TODO write States translation strings
*/
__('Andorra', 'jigoshop');
__('United Arab Emirates', 'jigoshop');
__('Afghanistan', 'jigoshop');
__('Antigua and Barbuda', 'jigoshop');
__('Anguilla', 'jigoshop');
__('Albania', 'jigoshop');
__('Armenia', 'jigoshop');
__('Netherlands Antilles', 'jigoshop');
__('Angola', 'jigoshop');
__('Antarctica', 'jigoshop');
__('Argentina', 'jigoshop');
__('American Samoa', 'jigoshop');
__('Austria', 'jigoshop');
__('Australia', 'jigoshop');
__('Aruba', 'jigoshop');
__('Aland Islands', 'jigoshop');
__('Azerbaijan', 'jigoshop');
__('Bosnia and Herzegovina', 'jigoshop');
__('Barbados', 'jigoshop');
__('Bangladesh', 'jigoshop');
__('Belgium', 'jigoshop');
__('Burkina Faso', 'jigoshop');
__('Bulgaria', 'jigoshop');
__('Bahrain', 'jigoshop');
__('Burundi', 'jigoshop');
__('Benin', 'jigoshop');
__('Saint Barthélemy', 'jigoshop');
__('Bermuda', 'jigoshop');
__('Brunei', 'jigoshop');
__('Bolivia', 'jigoshop');
__('Brazil', 'jigoshop');
__('Bahamas', 'jigoshop');
__('Bhutan', 'jigoshop');
__('Bouvet Island', 'jigoshop');
__('Botswana', 'jigoshop');
__('Belarus', 'jigoshop');
__('Belize', 'jigoshop');
__('Canada', 'jigoshop');
__('Cocos (Keeling) Islands', 'jigoshop');
__('Congo (Kinshasa)', 'jigoshop');
__('Central African Republic', 'jigoshop');
__('Congo (Brazzaville)', 'jigoshop');
__('Switzerland', 'jigoshop');
__('Ivory Coast', 'jigoshop');
__('Cook Islands', 'jigoshop');
__('Chile', 'jigoshop');
__('Cameroon', 'jigoshop');
__('China', 'jigoshop');
__('Colombia', 'jigoshop');
__('Costa Rica', 'jigoshop');
__('Cuba', 'jigoshop');
__('Cape Verde', 'jigoshop');
__('Christmas Island', 'jigoshop');
__('Cyprus', 'jigoshop');
__('Czech Republic', 'jigoshop');
__('Germany', 'jigoshop');
__('Djibouti', 'jigoshop');
__('Denmark', 'jigoshop');
__('Dominica', 'jigoshop');
__('Dominican Republic', 'jigoshop');
__('Algeria', 'jigoshop');
__('Ecuador', 'jigoshop');
__('Estonia', 'jigoshop');
__('Egypt', 'jigoshop');
__('Western Sahara', 'jigoshop');
__('Eritrea', 'jigoshop');
__('Spain', 'jigoshop');
__('Ethiopia', 'jigoshop');
__('Finland', 'jigoshop');
__('Fiji', 'jigoshop');
__('Falkland Islands', 'jigoshop');
__('Micronesia', 'jigoshop');
__('Faroe Islands', 'jigoshop');
__('France', 'jigoshop');
__('Gabon', 'jigoshop');
__('United Kingdom', 'jigoshop');
__('Grenada', 'jigoshop');
__('Georgia', 'jigoshop');
__('French Guiana', 'jigoshop');
__('Guernsey', 'jigoshop');
__('Ghana', 'jigoshop');
__('Gibraltar', 'jigoshop');
__('Greenland', 'jigoshop');
__('Gambia', 'jigoshop');
__('Guinea', 'jigoshop');
__('Guadeloupe', 'jigoshop');
__('Equatorial Guinea', 'jigoshop');
__('Greece', 'jigoshop');
__('South Georgia and the South Sandwich Islands', 'jigoshop');
__('Guatemala', 'jigoshop');
__('Guam', 'jigoshop');
__('Guinea-Bissau', 'jigoshop');
__('Guyana', 'jigoshop');
__('Hong Kong S.A.R., China', 'jigoshop');
__('Heard Island and McDonald Islands', 'jigoshop');
__('Honduras', 'jigoshop');
__('Croatia', 'jigoshop');
__('Haiti', 'jigoshop');
__('Hungary', 'jigoshop');
__('Indonesia', 'jigoshop');
__('Ireland', 'jigoshop');
__('Israel', 'jigoshop');
__('Isle of Man', 'jigoshop');
__('India', 'jigoshop');
__('British Indian Ocean Territory', 'jigoshop');
__('Iraq', 'jigoshop');
__('Iran', 'jigoshop');
__('Iceland', 'jigoshop');
__('Italy', 'jigoshop');
__('Jersey', 'jigoshop');
__('Jamaica', 'jigoshop');
__('Jordan', 'jigoshop');
__('Japan', 'jigoshop');
__('Kenya', 'jigoshop');
__('Kyrgyzstan', 'jigoshop');
__('Cambodia', 'jigoshop');
__('Kiribati', 'jigoshop');
__('Comoros', 'jigoshop');
__('Saint Kitts and Nevis', 'jigoshop');
__('North Korea', 'jigoshop');
__('South Korea', 'jigoshop');
__('Kuwait', 'jigoshop');
__('Cayman Islands', 'jigoshop');
__('Kazakhstan', 'jigoshop');
__('Laos', 'jigoshop');
__('Lebanon', 'jigoshop');
__('Saint Lucia', 'jigoshop');
__('Liechtenstein', 'jigoshop');
__('Sri Lanka', 'jigoshop');
__('Liberia', 'jigoshop');
__('Lesotho', 'jigoshop');
__('Lithuania', 'jigoshop');
__('Luxembourg', 'jigoshop');
__('Latvia', 'jigoshop');
__('Libya', 'jigoshop');
__('Morocco', 'jigoshop');
__('Monaco', 'jigoshop');
__('Moldova', 'jigoshop');
__('Montenegro', 'jigoshop');
__('Saint Martin (French part)', 'jigoshop');
__('Madagascar', 'jigoshop');
__('Marshall Islands', 'jigoshop');
__('Macedonia', 'jigoshop');
__('Mali', 'jigoshop');
__('Myanmar', 'jigoshop');
__('Mongolia', 'jigoshop');
__('Macao S.A.R., China', 'jigoshop');
__('Northern Mariana Islands', 'jigoshop');
__('Martinique', 'jigoshop');
__('Mauritania', 'jigoshop');
__('Montserrat', 'jigoshop');
__('Malta', 'jigoshop');
__('Mauritius', 'jigoshop');
__('Maldives', 'jigoshop');
__('Malawi', 'jigoshop');
__('Mexico', 'jigoshop');
__('Malaysia', 'jigoshop');
__('Mozambique', 'jigoshop');
__('Namibia', 'jigoshop');
__('New Caledonia', 'jigoshop');
__('Niger', 'jigoshop');
__('Norfolk Island', 'jigoshop');
__('Nigeria', 'jigoshop');
__('Nicaragua', 'jigoshop');
__('Netherlands', 'jigoshop');
__('Norway', 'jigoshop');
__('Nepal', 'jigoshop');
__('Nauru', 'jigoshop');
__('Niue', 'jigoshop');
__('New Zealand', 'jigoshop');
__('Oman', 'jigoshop');
__('Panama', 'jigoshop');
__('Peru', 'jigoshop');
__('French Polynesia', 'jigoshop');
__('Papua New Guinea', 'jigoshop');
__('Philippines', 'jigoshop');
__('Pakistan', 'jigoshop');
__('Poland', 'jigoshop');
__('Saint Pierre and Miquelon', 'jigoshop');
__('Pitcairn', 'jigoshop');
__('Puerto Rico', 'jigoshop');
__('Palestinian Territory', 'jigoshop');
__('Portugal', 'jigoshop');
__('Palau', 'jigoshop');
__('Paraguay', 'jigoshop');
__('Qatar', 'jigoshop');
__('Reunion', 'jigoshop');
__('Romania', 'jigoshop');
__('Serbia', 'jigoshop');
__('Russia', 'jigoshop');
__('Rwanda', 'jigoshop');
__('Saudi Arabia', 'jigoshop');
__('Solomon Islands', 'jigoshop');
__('Seychelles', 'jigoshop');
__('Sudan', 'jigoshop');
__('Sweden', 'jigoshop');
__('Singapore', 'jigoshop');
__('Saint Helena', 'jigoshop');
__('Slovenia', 'jigoshop');
__('Svalbard and Jan Mayen', 'jigoshop');
__('Slovakia', 'jigoshop');
__('Sierra Leone', 'jigoshop');
__('San Marino', 'jigoshop');
__('Senegal', 'jigoshop');
__('Somalia', 'jigoshop');
__('Suriname', 'jigoshop');
__('Sao Tome and Principe', 'jigoshop');
__('El Salvador', 'jigoshop');
__('Syria', 'jigoshop');
__('Swaziland', 'jigoshop');
__('Turks and Caicos Islands', 'jigoshop');
__('Chad', 'jigoshop');
__('French Southern Territories', 'jigoshop');
__('Togo', 'jigoshop');
__('Thailand', 'jigoshop');
__('Tajikistan', 'jigoshop');
__('Tokelau', 'jigoshop');
__('Timor-Leste', 'jigoshop');
__('Turkmenistan', 'jigoshop');
__('Tunisia', 'jigoshop');
__('Tonga', 'jigoshop');
__('Turkey', 'jigoshop');
__('Trinidad and Tobago', 'jigoshop');
__('Tuvalu', 'jigoshop');
__('Taiwan', 'jigoshop');
__('Tanzania', 'jigoshop');
__('Ukraine', 'jigoshop');
__('Uganda', 'jigoshop');
__('United States Minor Outlying Islands', 'jigoshop');
__('United States', 'jigoshop');
__('Uruguay', 'jigoshop');
__('Uzbekistan', 'jigoshop');
__('Vatican', 'jigoshop');
__('Saint Vincent and the Grenadines', 'jigoshop');
__('Venezuela', 'jigoshop');
__('British Virgin Islands', 'jigoshop');
__('U.S. Virgin Islands', 'jigoshop');
__('Vietnam', 'jigoshop');
__('Vanuatu', 'jigoshop');
__('Wallis and Futuna', 'jigoshop');
__('Samoa', 'jigoshop');
__('Yemen', 'jigoshop');
__('Mayotte', 'jigoshop');
__('South Africa', 'jigoshop');
__('Zambia', 'jigoshop');
__('Zimbabwe', 'jigoshop');

View File

@ -1,172 +0,0 @@
<?php
function get_jigoshop_cart( $atts ) {
return jigoshop::shortcode_wrapper('jigoshop_cart', $atts);
}
function jigoshop_cart( $atts ) {
$errors = array();
// Process Discount Codes
if (isset($_POST['apply_coupon']) && $_POST['apply_coupon'] && jigoshop::verify_nonce('cart')) :
$coupon_code = stripslashes(trim($_POST['coupon_code']));
jigoshop_cart::add_discount($coupon_code);
// Update Shipping
elseif (isset($_POST['calc_shipping']) && $_POST['calc_shipping'] && jigoshop::verify_nonce('cart')) :
unset($_SESSION['_chosen_method_id']);
$country = $_POST['calc_shipping_country'];
$state = $_POST['calc_shipping_state'];
$postcode = $_POST['calc_shipping_postcode'];
if ($postcode && !jigoshop_validation::is_postcode( $postcode, $country )) :
jigoshop::add_error( __('Please enter a valid postcode/ZIP.','jigoshop') );
$postcode = '';
elseif ($postcode) :
$postcode = jigoshop_validation::format_postcode( $postcode, $country );
endif;
if ($country) :
// Update customer location
jigoshop_customer::set_location( $country, $state, $postcode );
jigoshop_customer::set_shipping_location( $country, $state, $postcode );
// Re-calc price
jigoshop_cart::calculate_totals();
jigoshop::add_message( __('Shipping costs updated.', 'jigoshop') );
else :
jigoshop_customer::set_shipping_location( '', '', '' );
jigoshop::add_message( __('Shipping costs updated.', 'jigoshop') );
endif;
endif;
$result = jigoshop_cart::check_cart_item_stock();
if (is_wp_error($result)) :
jigoshop::add_error( $result->get_error_message() );
endif;
jigoshop::show_messages();
if (sizeof(jigoshop_cart::$cart_contents)==0) :
echo '<p>'.__('Your cart is empty.', 'jigoshop').'</p>';
return;
endif;
?>
<form action="<?php echo jigoshop_cart::get_cart_url(); ?>" method="post">
<table class="shop_table cart" cellspacing="0">
<thead>
<tr>
<th class="product-remove"></th>
<th class="product-thumbnail"></th>
<th class="product-name"><span class="nobr"><?php _e('Product Name', 'jigoshop'); ?></span></th>
<th class="product-price"><span class="nobr"><?php _e('Unit Price', 'jigoshop'); ?></span></th>
<th class="product-quantity"><?php _e('Quantity', 'jigoshop'); ?></th>
<th class="product-subtotal"><?php _e('Price', 'jigoshop'); ?></th>
</tr>
</thead>
<tbody>
<?php
if (sizeof(jigoshop_cart::$cart_contents)>0) :
foreach (jigoshop_cart::$cart_contents as $cart_item_key => $values) :
$_product = $values['data'];
if ($_product->exists() && $values['quantity']>0) :
echo '
<tr>
<td class="product-remove"><a href="'.jigoshop_cart::get_remove_url($cart_item_key).'" class="remove" title="Remove this item">&times;</a></td>
<td class="product-thumbnail"><a href="'.get_permalink($values['product_id']).'">';
if ($values['variation_id'] && has_post_thumbnail($values['variation_id'])) echo get_the_post_thumbnail($values['variation_id'], 'shop_tiny');
elseif (has_post_thumbnail($values['product_id'])) echo get_the_post_thumbnail($values['product_id'], 'shop_tiny');
else echo '<img src="'.jigoshop::plugin_url(). '/assets/images/placeholder.png" alt="Placeholder" width="'.jigoshop::get_var('shop_tiny_w').'" height="'.jigoshop::get_var('shop_tiny_h').'" />';
echo ' </a></td>
<td class="product-name">
<a href="'.get_permalink($values['product_id']).'">' . apply_filters('jigoshop_cart_product_title', $_product->get_title(), $_product) . '</a>
'.jigoshop_get_formatted_variation( $values['variation'] ).'
</td>
<td class="product-price">'.jigoshop_price($_product->get_price()).'</td>
<td class="product-quantity"><div class="quantity"><input name="cart['.$cart_item_key.'][qty]" value="'.$values['quantity'].'" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div></td>
<td class="product-subtotal">'.jigoshop_price($_product->get_price()*$values['quantity']).'</td>
</tr>';
endif;
endforeach;
endif;
do_action( 'jigoshop_shop_table_cart' );
?>
<tr>
<td colspan="6" class="actions">
<div class="coupon">
<label for="coupon_code"><?php _e('Coupon', 'jigoshop'); ?>:</label> <input name="coupon_code" class="input-text" id="coupon_code" value="" /> <input type="submit" class="button" name="apply_coupon" value="<?php _e('Apply Coupon', 'jigoshop'); ?>" />
</div>
<?php jigoshop::nonce_field('cart') ?>
<input type="submit" class="button" name="update_cart" value="<?php _e('Update Shopping Cart', 'jigoshop'); ?>" /> <a href="<?php echo jigoshop_cart::get_checkout_url(); ?>" class="checkout-button button-alt"><?php _e('Proceed to Checkout &rarr;', 'jigoshop'); ?></a>
</td>
</tr>
</tbody>
</table>
</form>
<div class="cart-collaterals">
<?php do_action('cart-collaterals'); ?>
<div class="cart_totals">
<?php
// Hide totals if customer has set location and there are no methods going there
$available_methods = jigoshop_shipping::get_available_shipping_methods();
if ($available_methods || !jigoshop_customer::get_shipping_country() || !jigoshop_shipping::$enabled ) :
?>
<h2><?php _e('Cart Totals', 'jigoshop'); ?></h2>
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<th><?php _e('Subtotal', 'jigoshop'); ?></th>
<td><?php echo jigoshop_cart::get_cart_subtotal(); ?></td>
</tr>
<?php if (jigoshop_cart::get_cart_shipping_total()) : ?><tr>
<th><?php _e('Shipping', 'jigoshop'); ?> <small><?php echo jigoshop_countries::shipping_to_prefix().' '.jigoshop_countries::$countries[ jigoshop_customer::get_shipping_country() ]; ?></small></th>
<td><?php echo jigoshop_cart::get_cart_shipping_total(); ?> <small><?php echo jigoshop_cart::get_cart_shipping_title(); ?></small></td>
</tr><?php endif; ?>
<?php if (jigoshop_cart::get_cart_tax()) : ?><tr>
<th><?php _e('Tax', 'jigoshop'); ?> <?php if (jigoshop_customer::is_customer_outside_base()) : ?><small><?php echo sprintf(__('estimated for %s', 'jigoshop'), jigoshop_countries::estimated_for_prefix() . jigoshop_countries::$countries[ jigoshop_countries::get_base_country() ] ); ?></small><?php endif; ?></th>
<td><?php
echo jigoshop_cart::get_cart_tax();
?></td>
</tr><?php endif; ?>
<?php if (jigoshop_cart::get_total_discount()) : ?><tr class="discount">
<th><?php _e('Discount', 'jigoshop'); ?></th>
<td>-<?php echo jigoshop_cart::get_total_discount(); ?></td>
</tr><?php endif; ?>
<tr>
<th><strong><?php _e('Total', 'jigoshop'); ?></strong></th>
<td><strong><?php echo jigoshop_cart::get_total(); ?></strong></td>
</tr>
</tbody>
</table>
<?php
else :
echo '<p>'.__('Sorry, it seems that there are no available shipping methods to your location. Please contact us if you require assistance or wish to make alternate arrangements.', 'jigoshop').'</p>';
endif;
?>
</div>
<?php jigoshop_shipping_calculator(); ?>
</div>
<?php
}

View File

@ -1,32 +0,0 @@
<?php
function get_jigoshop_checkout( $atts ) {
return jigoshop::shortcode_wrapper('jigoshop_checkout', $atts);
}
function jigoshop_checkout( $atts ) {
if (!defined('JIGOSHOP_CHECKOUT')) define('JIGOSHOP_CHECKOUT', true);
if (sizeof(jigoshop_cart::$cart_contents)==0) :
wp_redirect(get_permalink(get_option('jigoshop_cart_page_id')));
exit;
endif;
$non_js_checkout = (isset($_POST['update_totals']) && $_POST['update_totals']) ? true : false;
$_checkout = jigoshop_checkout::instance();
$_checkout->process_checkout();
$result = jigoshop_cart::check_cart_item_stock();
if (is_wp_error($result)) jigoshop::add_error( $result->get_error_message() );
if ( jigoshop::error_count()==0 && $non_js_checkout) jigoshop::add_message( __('The order totals have been updated. Please confirm your order by pressing the Place Order button at the bottom of the page.', 'jigoshop') );
jigoshop::show_messages();
jigoshop_get_template('checkout/form.php', false);
}

View File

@ -1,520 +0,0 @@
<?php
function get_jigoshop_my_account ( $atts ) {
return jigoshop::shortcode_wrapper('jigoshop_my_account', $atts);
}
function jigoshop_my_account( $atts ) {
extract(shortcode_atts(array(
'recent_orders' => 5
), $atts));
$recent_orders = ('all' == $recent_orders) ? -1 : $recent_orders;
global $post, $current_user;
get_currentuserinfo();
jigoshop::show_messages();
if (is_user_logged_in()) :
?>
<p><?php echo sprintf( __('Hello, <strong>%s</strong>. From your account dashboard you can view your recent orders, manage your shipping and billing addresses and <a href="%s">change your password</a>.', 'jigoshop'), $current_user->display_name, get_permalink(get_option('jigoshop_change_password_page_id'))); ?></p>
<?php if ($downloads = jigoshop_customer::get_downloadable_products()) : ?>
<h2><?php _e('Available downloads', 'jigoshop'); ?></h2>
<ul class="digital-downloads">
<?php foreach ($downloads as $download) : ?>
<li><?php if (is_numeric($download['downloads_remaining'])) : ?><span class="count"><?php echo $download['downloads_remaining'] . _n(' download Remaining', ' downloads Remaining', $download['downloads_remaining'], 'jigoshop'); ?></span><?php endif; ?> <a href="<?php echo $download['download_url']; ?>"><?php echo $download['download_name']; ?></a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<h2><?php _e('Recent Orders', 'jigoshop'); ?></h2>
<table class="shop_table my_account_orders">
<thead>
<tr>
<th><span class="nobr"><?php _e('#', 'jigoshop'); ?></span></th>
<th><span class="nobr"><?php _e('Date', 'jigoshop'); ?></span></th>
<th><span class="nobr"><?php _e('Ship to', 'jigoshop'); ?></span></th>
<th><span class="nobr"><?php _e('Total', 'jigoshop'); ?></span></th>
<th colspan="2"><span class="nobr"><?php _e('Status', 'jigoshop'); ?></span></th>
</tr>
</thead>
<tbody><?php
$jigoshop_orders = &new jigoshop_orders();
$jigoshop_orders->get_customer_orders( get_current_user_id(), $recent_orders );
if ($jigoshop_orders->orders) foreach ($jigoshop_orders->orders as $order) :
?><tr class="order">
<td><?php echo $order->id; ?></td>
<td><time title="<?php echo strtotime($order->order_date); ?>"><?php echo date('d.m.Y', strtotime($order->order_date)); ?></time></td>
<td><address><?php if ($order->formatted_shipping_address) echo $order->formatted_shipping_address; else echo '&ndash;'; ?></address></td>
<td><?php echo jigoshop_price($order->order_total); ?></td>
<td><?php echo $order->status; ?></td>
<td style="text-align:right; white-space:nowrap;">
<?php if ($order->status=='pending') : ?>
<a href="<?php echo $order->get_checkout_payment_url(); ?>" class="button pay"><?php _e('Pay', 'jigoshop'); ?></a>
<a href="<?php echo $order->get_cancel_order_url(); ?>" class="button cancel"><?php _e('Cancel', 'jigoshop'); ?></a>
<?php endif; ?>
<a href="<?php echo add_query_arg('order', $order->id, get_permalink(get_option('jigoshop_view_order_page_id'))); ?>" class="button"><?php _e('View', 'jigoshop'); ?></a>
</td>
</tr><?php
endforeach;
?></tbody>
</table>
<h2><?php _e('My Addresses', 'jigoshop'); ?></h2>
<p><?php _e('The following addresses will be used on the checkout page by default.', 'jigoshop'); ?></p>
<div class="col2-set addresses">
<div class="col-1">
<header class="title">
<h3><?php _e('Billing Address', 'jigoshop'); ?></h3>
<a href="<?php echo add_query_arg('address', 'billing', get_permalink(get_option('jigoshop_edit_address_page_id'))); ?>" class="edit"><?php _e('Edit', 'jigoshop'); ?></a>
</header>
<address>
<?php
if (isset(jigoshop_countries::$countries->countries[get_user_meta( get_current_user_id(), 'billing-country', true )])) $country = jigoshop_countries::$countries->countries[get_user_meta( get_current_user_id(), 'billing-country', true )]; else $country = '';
$address = array(
get_user_meta( get_current_user_id(), 'billing-first_name', true ) . ' ' . get_user_meta( get_current_user_id(), 'billing-last_name', true )
,get_user_meta( get_current_user_id(), 'billing-company', true )
,get_user_meta( get_current_user_id(), 'billing-address', true )
,get_user_meta( get_current_user_id(), 'billing-address-2', true )
,get_user_meta( get_current_user_id(), 'billing-city', true )
,get_user_meta( get_current_user_id(), 'billing-state', true )
,get_user_meta( get_current_user_id(), 'billing-postcode', true )
,$country
);
$address = array_map('trim', $address);
$formatted_address = array();
foreach ($address as $part) if (!empty($part)) $formatted_address[] = $part;
$formatted_address = implode(', ', $formatted_address);
if (!$formatted_address) _e('You have not set up a billing address yet.', 'jigoshop'); else echo $formatted_address;
?>
</address>
</div><!-- /.col-1 -->
<div class="col-2">
<header class="title">
<h3><?php _e('Shipping Address', 'jigoshop'); ?></h3>
<a href="<?php echo add_query_arg('address', 'shipping', get_permalink(get_option('jigoshop_edit_address_page_id'))); ?>" class="edit"><?php _e('Edit', 'jigoshop'); ?></a>
</header>
<address>
<?php
if (isset(jigoshop_countries::$countries->countries[get_user_meta( get_current_user_id(), 'shipping-country', true )])) $country = jigoshop_countries::$countries->countries[get_user_meta( get_current_user_id(), 'shipping-country', true )]; else $country = '';
$address = array(
get_user_meta( get_current_user_id(), 'shipping-first_name', true ) . ' ' . get_user_meta( get_current_user_id(), 'shipping-last_name', true )
,get_user_meta( get_current_user_id(), 'shipping-company', true )
,get_user_meta( get_current_user_id(), 'shipping-address', true )
,get_user_meta( get_current_user_id(), 'shipping-address-2', true )
,get_user_meta( get_current_user_id(), 'shipping-city', true )
,get_user_meta( get_current_user_id(), 'shipping-state', true )
,get_user_meta( get_current_user_id(), 'shipping-postcode', true )
,$country
);
$address = array_map('trim', $address);
$formatted_address = array();
foreach ($address as $part) if (!empty($part)) $formatted_address[] = $part;
$formatted_address = implode(', ', $formatted_address);
if (!$formatted_address) _e('You have not set up a shipping address yet.', 'jigoshop'); else echo $formatted_address;
?>
</address>
</div><!-- /.col-2 -->
</div><!-- /.col2-set -->
<?php
else :
jigoshop_login_form();
endif;
}
function get_jigoshop_edit_address () {
return jigoshop::shortcode_wrapper('jigoshop_edit_address');
}
function jigoshop_edit_address() {
$user_id = get_current_user_id();
if (is_user_logged_in()) :
if (isset($_GET['address'])) $load_address = $_GET['address']; else $load_address = 'billing';
if ($load_address == 'billing') $load_address = 'billing'; else $load_address = 'shipping';
if ($_POST) :
if ($user_id>0 && jigoshop::verify_nonce('edit_address') ) :
update_user_meta( $user_id, $load_address . '-first_name', jigowatt_clean($_POST['address-first_name']) );
update_user_meta( $user_id, $load_address . '-last_name', jigowatt_clean($_POST['address-last_name']) );
update_user_meta( $user_id, $load_address . '-company', jigowatt_clean($_POST['address-company']) );
update_user_meta( $user_id, $load_address . '-email', jigowatt_clean($_POST['address-email']) );
update_user_meta( $user_id, $load_address . '-address', jigowatt_clean($_POST['address-address']) );
update_user_meta( $user_id, $load_address . '-address2', jigowatt_clean($_POST['address-address2']) );
update_user_meta( $user_id, $load_address . '-city', jigowatt_clean($_POST['address-city']) );
update_user_meta( $user_id, $load_address . '-postcode', jigowatt_clean($_POST['address-postcode']) );
update_user_meta( $user_id, $load_address . '-country', jigowatt_clean($_POST['address-country']) );
update_user_meta( $user_id, $load_address . '-state', jigowatt_clean($_POST['address-state']) );
update_user_meta( $user_id, $load_address . '-phone', jigowatt_clean($_POST['address-phone']) );
update_user_meta( $user_id, $load_address . '-fax', jigowatt_clean($_POST['address-fax']) );
endif;
wp_safe_redirect( get_permalink(get_option('jigoshop_myaccount_page_id')) );
exit;
endif;
$address = array(
'first_name' => get_user_meta( get_current_user_id(), $load_address . '-first_name', true ),
'last_name' => get_user_meta( get_current_user_id(), $load_address . '-last_name', true ),
'company' => get_user_meta( get_current_user_id(), $load_address . '-company', true ),
'email' => get_user_meta( get_current_user_id(), $load_address . '-email', true ),
'phone' => get_user_meta( get_current_user_id(), $load_address . '-phone', true ),
'fax' => get_user_meta( get_current_user_id(), $load_address . '-fax', true ),
'address' => get_user_meta( get_current_user_id(), $load_address . '-address', true ),
'address2' => get_user_meta( get_current_user_id(), $load_address . '-address2', true ),
'city' => get_user_meta( get_current_user_id(), $load_address . '-city', true ),
'state' => get_user_meta( get_current_user_id(), $load_address . '-state', true ),
'postcode' => get_user_meta( get_current_user_id(), $load_address . '-postcode', true ),
'country' => get_user_meta( get_current_user_id(), $load_address . '-country', true )
);
?>
<form action="<?php echo add_query_arg('address', $load_address, get_permalink(get_option('jigoshop_edit_address_page_id'))); ?>" method="post">
<h3><?php if ($load_address=='billing') _e('Billing Address', 'jigoshop'); else _e('Shipping Address', 'jigoshop'); ?></h3>
<p class="form-row form-row-first">
<label for="address-first_name"><?php _e('First Name', 'jigoshop'); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="address-first_name" id="address-first_name" placeholder="<?php _e('First Name', 'jigoshop'); ?>" value="<?php echo $address['first_name']; ?>" />
</p>
<p class="form-row form-row-last">
<label for="address-last_name"><?php _e('Last Name', 'jigoshop'); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="address-last_name" id="address-last_name" placeholder="<?php _e('Last Name', 'jigoshop'); ?>" value="<?php echo $address['last_name']; ?>" />
</p>
<div class="clear"></div>
<p class="form-row columned">
<label for="address-company"><?php _e('Company', 'jigoshop'); ?></label>
<input type="text" class="input-text" name="address-company" id="address-company" placeholder="<?php _e('Company', 'jigoshop'); ?>" value="<?php echo $address['company']; ?>" />
</p>
<p class="form-row form-row-first">
<label for="address-address"><?php _e('Address', 'jigoshop'); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="address-address" id="address-address" placeholder="<?php _e('1 Infinite Loop', 'jigoshop'); ?>" value="<?php echo $address['address']; ?>" />
</p>
<p class="form-row form-row-last">
<label for="address-address2" class="hidden"><?php _e('Address 2', 'jigoshop'); ?></label>
<input type="text" class="input-text" name="address-address2" id="address-address2" placeholder="<?php _e('Cupertino', 'jigoshop'); ?>" value="<?php echo $address['address2']; ?>" />
</p>
<div class="clear"></div>
<p class="form-row form-row-first">
<label for="address-city"><?php _e('City', 'jigoshop'); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="address-city" id="address-city" placeholder="<?php _e('City', 'jigoshop'); ?>" value="<?php echo $address['city']; ?>" />
</p>
<p class="form-row form-row-last">
<label for="address-postcode"><?php _e('Postcode', 'jigoshop'); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="address-postcode" id="address-postcode" placeholder="123456" value="<?php echo $address['postcode']; ?>" />
</p>
<div class="clear"></div>
<p class="form-row form-row-first">
<label for="address-country"><?php _e('Country', 'jigoshop'); ?> <span class="required">*</span></label>
<select name="address-country" id="address-country" class="country_to_state" rel="address-state">
<option value=""><?php _e('Select a country&hellip;', 'jigoshop'); ?></option>
<?php
foreach(jigoshop_countries::$countries as $key=>$value) :
echo '<option value="'.$key.'"';
if ($address['country']==$key) echo 'selected="selected"';
elseif (!$address['country'] && jigoshop_customer::get_country()==$key) echo 'selected="selected"';
echo '>'.$value.'</option>';
endforeach;
?>
</select>
</p>
<p class="form-row form-row-last">
<label for="address-state"><?php _e('state', 'jigoshop'); ?> <span class="required">*</span></label>
<?php
$current_cc = $address['country'];
if (!$current_cc) $current_cc = jigoshop_customer::get_country();
$current_r = $address['state'];
if (!$current_r) $current_r = jigoshop_customer::get_state();
$states = jigoshop_countries::$states;
if (isset( $states[$current_cc][$current_r] )) :
// Dropdown
?>
<select name="address-state" id="address-state"><option value=""><?php _e('Select a state&hellip;', 'jigoshop'); ?></option><?php
foreach($states[$current_cc] as $key=>$value) :
echo '<option value="'.$key.'"';
if ($current_r==$key) echo 'selected="selected"';
echo '>'.$value.'</option>';
endforeach;
?></select>
<?php
else :
// Input
?><input type="text" class="input-text" value="<?php echo $current_r; ?>" placeholder="<?php _e('state', 'jigoshop'); ?>" name="address-state" id="address-state" /><?php
endif;
?>
</p>
<div class="clear"></div>
<?php if ($load_address=='billing') : ?>
<p class="form-row columned">
<label for="address-email"><?php _e('Email Address', 'jigoshop'); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="address-email" id="address-email" placeholder="<?php _e('you@yourdomain.com', 'jigoshop'); ?>" value="<?php echo $address['email']; ?>" />
</p>
<p class="form-row form-row-first">
<label for="address-phone"><?php _e('Phone', 'jigoshop'); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="address-phone" id="address-phone" placeholder="0123456789" value="<?php echo $address['phone']; ?>" />
</p>
<p class="form-row form-row-last">
<label for="address-fax"><?php _e('Fax', 'jigoshop'); ?></label>
<input type="text" class="input-text" name="address-fax" id="address-fax" placeholder="0123456789" value="<?php echo $address['fax']; ?>" />
</p>
<div class="clear"></div>
<?php endif; ?>
<?php jigoshop::nonce_field('edit_address') ?>
<input type="submit" class="button" name="save_address" value="<?php _e('Save Address', 'jigoshop'); ?>" />
</form>
<?php
else :
wp_safe_redirect( get_permalink(get_option('jigoshop_myaccount_page_id')) );
exit;
endif;
}
function get_jigoshop_change_password () {
return jigoshop::shortcode_wrapper('jigoshop_change_password');
}
function jigoshop_change_password() {
$user_id = get_current_user_id();
if (is_user_logged_in()) :
if ($_POST) :
if ($user_id>0 && jigoshop::verify_nonce('change_password')) :
if ( $_POST['password-1'] && $_POST['password-2'] ) :
if ( $_POST['password-1']==$_POST['password-2'] ) :
wp_update_user( array ('ID' => $user_id, 'user_pass' => $_POST['password-1']) ) ;
wp_safe_redirect( get_permalink(get_option('jigoshop_myaccount_page_id')) );
exit;
else :
jigoshop::add_error( __('Passwords do not match.','jigoshop') );
endif;
else :
jigoshop::add_error( __('Please enter your password.','jigoshop') );
endif;
endif;
endif;
jigoshop::show_messages();
?>
<form action="<?php echo get_permalink(get_option('jigoshop_change_password_page_id')); ?>" method="post">
<p class="form-row form-row-first">
<label for="password-1"><?php _e('New password', 'jigoshop'); ?> <span class="required">*</span></label>
<input type="password" class="input-text" name="password-1" id="password-1" />
</p>
<p class="form-row form-row-last">
<label for="password-2"><?php _e('Re-enter new password', 'jigoshop'); ?> <span class="required">*</span></label>
<input type="password" class="input-text" name="password-2" id="password-2" />
</p>
<div class="clear"></div>
<?php jigoshop::nonce_field('change_password')?>
<p><input type="submit" class="button" name="save_password" value="<?php _e('Save', 'jigoshop'); ?>" /></p>
</form>
<?php
else :
wp_safe_redirect( get_permalink(get_option('jigoshop_myaccount_page_id')) );
exit;
endif;
}
function get_jigoshop_view_order () {
return jigoshop::shortcode_wrapper('jigoshop_view_order');
}
function jigoshop_view_order() {
$user_id = get_current_user_id();
if (is_user_logged_in()) :
if (isset($_GET['order'])) $order_id = (int) $_GET['order']; else $order_id = 0;
$order = &new jigoshop_order( $order_id );
if ( $order_id>0 && $order->user_id == get_current_user_id() ) :
echo '<p>' . sprintf( __('Order <mark>#%s</mark> made on <mark>%s</mark>', 'jigoshop'), $order->id, date('d.m.Y', strtotime($order->order_date)) );
echo sprintf( __('. Order status: <mark>%s</mark>', 'jigoshop'), $order->status );
echo '.</p>';
?>
<table class="shop_table">
<thead>
<tr>
<th><?php _e('Product', 'jigoshop'); ?></th>
<th><?php _e('Qty', 'jigoshop'); ?></th>
<th><?php _e('Totals', 'jigoshop'); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="2"><?php _e('Subtotal', 'jigoshop'); ?></td>
<td><?php echo $order->get_subtotal_to_display(); ?></td>
</tr>
<?php if ($order->order_shipping>0) : ?><tr>
<td colspan="2"><?php _e('Shipping', 'jigoshop'); ?></td>
<td><?php echo $order->get_shipping_to_display(); ?></small></td>
</tr><?php endif; ?>
<?php if ($order->get_total_tax()>0) : ?><tr>
<td colspan="2"><?php _e('Tax', 'jigoshop'); ?></td>
<td><?php echo jigoshop_price($order->get_total_tax()); ?></td>
</tr><?php endif; ?>
<?php if ($order->order_discount>0) : ?><tr class="discount">
<td colspan="2"><?php _e('Discount', 'jigoshop'); ?></td>
<td>-<?php echo jigoshop_price($order->order_discount); ?></td>
</tr><?php endif; ?>
<tr>
<td colspan="2"><strong><?php _e('Grand Total', 'jigoshop'); ?></strong></td>
<td><strong><?php echo jigoshop_price($order->order_total); ?></strong></td>
</tr>
<?php if ($order->customer_note) : ?>
<tr>
<td><?php _e('Note:', 'jigoshop'); ?></td>
<td colspan="2"><?php echo wpautop(wptexturize($order->customer_note)); ?></td>
</tr>
<?php endif; ?>
</tfoot>
<tbody>
<?php
if (sizeof($order->items)>0) :
foreach($order->items as $item) :
if (isset($item['variation_id']) && $item['variation_id'] > 0) :
$_product = &new jigoshop_product_variation( $item['variation_id'] );
else :
$_product = &new jigoshop_product( $item['id'] );
endif;
echo '
<tr>
<td class="product-name">'.$item['name'];
if (isset($_product->variation_data)) :
echo jigoshop_get_formatted_variation( $_product->variation_data );
endif;
echo ' </td>
<td>'.$item['qty'].'</td>
<td>'.jigoshop_price( $item['cost']*$item['qty'], array('ex_tax_label' => 1) ).'</td>
</tr>';
endforeach;
endif;
?>
</tbody>
</table>
<header>
<h2><?php _e('Customer details', 'jigoshop'); ?></h2>
</header>
<dl>
<?php
if ($order->billing_email) echo '<dt>'.__('Email:', 'jigoshop').'</dt><dd>'.$order->billing_email.'</dd>';
if ($order->billing_phone) echo '<dt>'.__('Telephone:', 'jigoshop').'</dt><dd>'.$order->billing_phone.'</dd>';
?>
</dl>
<div class="col2-set addresses">
<div class="col-1">
<header class="title">
<h3><?php _e('Shipping Address', 'jigoshop'); ?></h3>
</header>
<address><p>
<?php
if (!$order->formatted_shipping_address) _e('N/A', 'jigoshop'); else echo $order->formatted_shipping_address;
?>
</p></address>
</div><!-- /.col-1 -->
<div class="col-2">
<header class="title">
<h3><?php _e('Billing Address', 'jigoshop'); ?></h3>
</header>
<address><p>
<?php
if (!$order->formatted_billing_address) _e('N/A', 'jigoshop'); else echo $order->formatted_billing_address;
?>
</p></address>
</div><!-- /.col-2 -->
</div><!-- /.col2-set -->
<div class="clear"></div>
<?php
else :
wp_safe_redirect( get_permalink(get_option('jigoshop_myaccount_page_id')) );
exit;
endif;
else :
wp_safe_redirect( get_permalink(get_option('jigoshop_myaccount_page_id')) );
exit;
endif;
}

View File

@ -1,143 +0,0 @@
<?php
function get_jigoshop_order_tracking ($atts) {
return jigoshop::shortcode_wrapper('jigoshop_order_tracking', $atts);
}
function jigoshop_order_tracking( $atts ) {
extract(shortcode_atts(array(
), $atts));
global $post;
if ($_POST) :
$order = &new jigoshop_order();
if (isset($_POST['orderid']) && $_POST['orderid'] > 0) $order->id = (int) $_POST['orderid']; else $order->id = 0;
if (isset($_POST['order_email']) && $_POST['order_email']) $order_email = trim($_POST['order_email']); else $order_email = '';
if ( !jigoshop::verify_nonce('order_tracking') ):
echo '<p>'.__('You have taken too long. Please refresh the page and retry.', 'jigoshop').'</p>';
elseif ($order->id && $order_email && $order->get_order( $order->id )) :
if ($order->billing_email == $order_email) :
echo '<p>'.sprintf( __('Order #%s which was made %s has the status &ldquo;%s&rdquo;', 'jigoshop'), $order->id, human_time_diff(strtotime($order->order_date), current_time('timestamp')).__(' ago', 'jigoshop'), $order->status );
if ($order->status == 'completed') echo __(' and was completed ', 'jigoshop').human_time_diff(strtotime($order->completed_date), current_time('timestamp')).__(' ago', 'jigoshop');
echo '.</p>';
?>
<h2><?php _e('Order Details', 'jigoshop'); ?></h2>
<table class="shop_table">
<thead>
<tr>
<th><?php _e('Title', 'jigoshop'); ?></th>
<th><?php _e('SKU', 'jigoshop'); ?></th>
<th><?php _e('Price', 'jigoshop'); ?></th>
<th><?php _e('Quantity', 'jigoshop'); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3"><?php _e('Subtotal', 'jigoshop'); ?></td>
<td><?php echo $order->get_subtotal_to_display(); ?></td>
</tr>
<?php if ($order->order_shipping>0) : ?><tr>
<td colspan="3"><?php _e('Shipping', 'jigoshop'); ?></td>
<td><?php echo $order->get_shipping_to_display(); ?></small></td>
</tr><?php endif; ?>
<?php if ($order->get_total_tax()>0) : ?><tr>
<td colspan="3"><?php _e('Tax', 'jigoshop'); ?></td>
<td><?php echo jigoshop_price($order->get_total_tax()); ?></td>
</tr><?php endif; ?>
<?php if ($order->order_discount>0) : ?><tr class="discount">
<td colspan="3"><?php _e('Discount', 'jigoshop'); ?></td>
<td>-<?php echo jigoshop_price($order->order_discount); ?></td>
</tr><?php endif; ?>
<tr>
<td colspan="3"><strong><?php _e('Grand Total', 'jigoshop'); ?></strong></td>
<td><strong><?php echo jigoshop_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 jigoshop_product_variation( $order_item['variation_id'] );
else :
$_product = &new jigoshop_product( $order_item['id'] );
endif;
echo '<tr>';
echo '<td class="product-name">'.$_product->get_title();
if (isset($_product->variation_data)) :
echo jigoshop_get_formatted_variation( $_product->variation_data );
endif;
echo '</td>';
echo '<td>'.$_product->sku.'</td>';
echo '<td>'.jigoshop_price($_product->get_price()).'</td>';
echo '<td>'.$order_item['qty'].'</td>';
echo '</tr>';
endforeach;
?>
</tbody>
</table>
<div style="width: 49%; float:left;">
<h2><?php _e('Billing Address', 'jigoshop'); ?></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', 'jigoshop'); ?></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>', 'jigoshop').'</p>';
endif;
else :
echo '<p>'.__('Sorry, we could not find that order id in our database. <a href="'.get_permalink($post->ID).'">Want to retry?</a>', 'jigoshop').'</p>';
endif;
else :
?>
<form action="<?php echo get_permalink($post->ID); ?>" method="post" class="track_order">
<p><?php _e('To track your order please enter your Order ID in the box below and press return. This was given to you on your receipt and in the confirmation email you should have received.', 'jigoshop'); ?></p>
<p class="form-row form-row-first"><label for="orderid"><?php _e('Order ID', 'jigoshop'); ?></label> <input class="input-text" type="text" name="orderid" id="orderid" placeholder="<?php _e('Found in your order confirmation email.', 'jigoshop'); ?>" /></p>
<p class="form-row form-row-last"><label for="order_email"><?php _e('Billing Email', 'jigoshop'); ?></label> <input class="input-text" type="text" name="order_email" id="order_email" placeholder="<?php _e('Email you used during checkout.', 'jigoshop'); ?>" /></p>
<div class="clear"></div>
<p class="form-row"><input type="submit" class="button" name="track" value="<?php _e('Track"', 'jigoshop'); ?>" /></p>
<?php jigoshop::nonce_field('order_tracking') ?>
</form>
<?php
endif;
}

View File

@ -1,145 +0,0 @@
<?php
function get_jigoshop_pay( $atts ) {
return jigoshop::shortcode_wrapper('jigoshop_pay', $atts);
}
/**
* Outputs the pay page - payment gateways can hook in here to show payment forms etc
**/
function jigoshop_pay() {
if ( isset($_GET['pay_for_order']) && isset($_GET['order']) && isset($_GET['order_id']) ) :
// Pay for existing order
$order_key = urldecode( $_GET['order'] );
$order_id = (int) $_GET['order_id'];
$order = &new jigoshop_order( $order_id );
if ($order->id == $order_id && $order->order_key == $order_key && $order->status=='pending') :
// Set customer location to order location
if ($order->billing_country) jigoshop_customer::set_country( $order->billing_country );
if ($order->billing_state) jigoshop_customer::set_state( $order->billing_state );
if ($order->billing_postcode) jigoshop_customer::set_postcode( $order->billing_postcode );
// Pay form was posted - process payment
if (isset($_POST['pay']) && jigoshop::verify_nonce('pay')) :
// Update payment method
if ($order->order_total > 0 ) :
$payment_method = jigowatt_clean($_POST['payment_method']);
$data = (array) maybe_unserialize( get_post_meta( $order_id, 'order_data', true ) );
$data['payment_method'] = $payment_method;
update_post_meta( $order_id, 'order_data', $data );
$available_gateways = jigoshop_payment_gateways::get_available_payment_gateways();
$result = $available_gateways[$payment_method]->process_payment( $order_id );
// Redirect to success/confirmation/payment page
if ($result['result']=='success') :
wp_safe_redirect( $result['redirect'] );
exit;
endif;
else :
// No payment was required for order
$order->payment_complete();
wp_safe_redirect( get_permalink(get_option('jigoshop_thanks_page_id')) );
exit;
endif;
endif;
// Show messages
jigoshop::show_messages();
// Show form
jigoshop_pay_for_existing_order( $order );
elseif ($order->status!='pending') :
jigoshop::add_error( __('Your order has already been paid for. Please contact us if you need assistance.', 'jigoshop') );
jigoshop::show_messages();
else :
jigoshop::add_error( __('Invalid order.', 'jigoshop') );
jigoshop::show_messages();
endif;
else :
// Pay for order after checkout step
if (isset($_GET['order'])) $order_id = $_GET['order']; else $order_id = 0;
if (isset($_GET['key'])) $order_key = $_GET['key']; else $order_key = '';
if ($order_id > 0) :
$order = &new jigoshop_order( $order_id );
if ($order->order_key == $order_key && $order->status=='pending') :
?>
<ul class="order_details">
<li class="order">
<?php _e('Order:', 'jigoshop'); ?>
<strong># <?php echo $order->id; ?></strong>
</li>
<li class="date">
<?php _e('Date:', 'jigoshop'); ?>
<strong><?php echo date('d.m.Y', strtotime($order->order_date)); ?></strong>
</li>
<li class="total">
<?php _e('Total:', 'jigoshop'); ?>
<strong><?php echo jigoshop_price($order->order_total); ?></strong>
</li>
<li class="method">
<?php _e('Payment method:', 'jigoshop'); ?>
<strong><?php
$gateways = jigoshop_payment_gateways::payment_gateways();
if (isset($gateways[$order->payment_method])) echo $gateways[$order->payment_method]->title;
else echo $order->payment_method;
?></strong>
</li>
</ul>
<?php do_action( 'receipt_' . $order->payment_method, $order_id ); ?>
<div class="clear"></div>
<?php
else :
wp_safe_redirect( get_permalink(get_option('jigoshop_myaccount_page_id')) );
exit;
endif;
else :
wp_safe_redirect( get_permalink(get_option('jigoshop_myaccount_page_id')) );
exit;
endif;
endif;
}
/**
* Outputs the payment page when a user comes to pay from a link (for an existing/past created order)
**/
function jigoshop_pay_for_existing_order( $pay_for_order ) {
global $order;
$order = $pay_for_order;
jigoshop_get_template('checkout/pay_for_order.php');
}

View File

@ -1,56 +0,0 @@
<?php
function get_jigoshop_thankyou( $atts ) {
return jigoshop::shortcode_wrapper('jigoshop_thankyou', $atts);
}
/**
* Outputs the thankyou page
**/
function jigoshop_thankyou() {
_e('<p>Thank you. Your order has been processed successfully.</p>', 'jigoshop');
// Pay for order after checkout step
if (isset($_GET['order'])) $order_id = $_GET['order']; else $order_id = 0;
if (isset($_GET['key'])) $order_key = $_GET['key']; else $order_key = '';
if ($order_id > 0) :
$order = &new jigoshop_order( $order_id );
if ($order->order_key == $order_key) :
?>
<ul class="order_details">
<li class="order">
<?php _e('Order:', 'jigoshop'); ?>
<strong># <?php echo $order->id; ?></strong>
</li>
<li class="date">
<?php _e('Date:', 'jigoshop'); ?>
<strong><?php echo date('d.m.Y', strtotime($order->order_date)); ?></strong>
</li>
<li class="total">
<?php _e('Total:', 'jigoshop'); ?>
<strong><?php echo jigoshop_price($order->order_total); ?></strong>
</li>
<li class="method">
<?php _e('Payment method:', 'jigoshop'); ?>
<strong><?php
$gateways = jigoshop_payment_gateways::payment_gateways();
if (isset($gateways[$order->payment_method])) echo $gateways[$order->payment_method]->title;
else echo $order->payment_method;
?></strong>
</li>
</ul>
<div class="clear"></div>
<?php
do_action( 'thankyou_' . $order->payment_method, $order_id );
endif;
endif;
}

View File

@ -1,83 +0,0 @@
<?php
/**
* Shopping Cart Widget
*
* Displays shopping cart widget
*
* @package JigoShop
* @category Widgets
* @author Jigowatt
* @since 1.0
*
*/
class Jigoshop_Widget_Cart extends WP_Widget {
/** constructor */
function Jigoshop_Widget_Cart() {
$widget_ops = array( 'description' => __( "Shopping Cart for the sidebar.", 'jigoshop') );
parent::WP_Widget('shopping_cart', __('Shopping Cart', 'jigoshop'), $widget_ops);
}
/** @see WP_Widget::widget */
function widget( $args, $instance ) {
if (is_cart()) return;
extract($args);
if ( !empty($instance['title']) ) $title = $instance['title']; else $title = __('Cart', 'jigoshop');
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
echo $before_widget;
if ( $title ) echo $before_title . $title . $after_title;
echo '<ul class="cart_list">';
if (sizeof(jigoshop_cart::$cart_contents)>0) : foreach (jigoshop_cart::$cart_contents as $item_id => $values) :
$_product = $values['data'];
if ($_product->exists() && $values['quantity']>0) :
echo '<li><a href="'.get_permalink($item_id).'">';
if (has_post_thumbnail($item_id)) echo get_the_post_thumbnail($item_id, 'shop_tiny');
else echo '<img src="'.jigoshop::plugin_url(). '/assets/images/placeholder.png" alt="Placeholder" width="'.jigoshop::get_var('shop_tiny_w').'" height="'.jigoshop::get_var('shop_tiny_h').'" />';
echo apply_filters('jigoshop_cart_widget_product_title', $_product->get_title(), $_product).'</a> '.$values['quantity'].' &times; '.jigoshop_price($_product->get_price()).'</li>';
endif;
endforeach;
else: echo '<li class="empty">'.__('No products in the cart.','jigoshop').'</li>'; endif;
echo '</ul>';
if (sizeof(jigoshop_cart::$cart_contents)>0) :
echo '<p class="total"><strong>';
if (get_option('js_prices_include_tax')=='yes') :
_e('Total', 'jigoshop');
else :
_e('Subtotal', 'jigoshop');
endif;
echo ':</strong> '.jigoshop_cart::get_cart_total();
echo '</p>';
do_action( 'jigoshop_widget_shopping_cart_before_buttons' );
echo '<p class="buttons"><a href="'.jigoshop_cart::get_cart_url().'" class="button">'.__('View Cart &rarr;','jigoshop').'</a> <a href="'.jigoshop_cart::get_checkout_url().'" class="button checkout">'.__('Checkout &rarr;','jigoshop').'</a></p>';
endif;
echo $after_widget;
}
/** @see WP_Widget::update */
function update( $new_instance, $old_instance ) {
$instance['title'] = strip_tags(stripslashes($new_instance['title']));
return $instance;
}
/** @see WP_Widget::form */
function form( $instance ) {
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'jigoshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );} ?>" /></p>
<?php
}
} // class Jigoshop_Widget_Cart

View File

@ -1,103 +0,0 @@
<?php
/**
* Featured Products Widget
*
* Gets and displays featured products in an unordered list
*
* @package JigoShop
* @category Widgets
* @author Jigowatt
* @since 1.0
*
*/
class Jigoshop_Widget_Featured_Products extends WP_Widget {
/** constructor */
function Jigoshop_Widget_Featured_Products() {
$widget_ops = array('classname' => 'widget_featured_products', 'description' => __( "Featured products on your site", 'jigoshop') );
parent::WP_Widget('featured-products', __('Featured Products', 'jigoshop'), $widget_ops);
$this->alt_option_name = 'widget_featured_products';
add_action( 'save_post', array(&$this, 'flush_widget_cache') );
add_action( 'deleted_post', array(&$this, 'flush_widget_cache') );
add_action( 'switch_theme', array(&$this, 'flush_widget_cache') );
}
/** @see WP_Widget::widget */
function widget($args, $instance) {
$cache = wp_cache_get('widget_featured_products', 'widget');
if ( !is_array($cache) ) $cache = array();
if ( isset($cache[$args['widget_id']]) ) {
echo $cache[$args['widget_id']];
return;
}
ob_start();
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? __('Featured Products', 'jigoshop') : $instance['title'], $instance, $this->id_base);
if ( !$number = (int) $instance['number'] )
$number = 10;
else if ( $number < 1 )
$number = 1;
else if ( $number > 15 )
$number = 15;
$featured_posts = get_posts(array('numberposts' => $number, 'post_status' => 'publish', 'post_type' => 'product', 'meta_key' => 'featured', 'meta_value' => 'yes' ));
if ($featured_posts) :
?>
<?php echo $before_widget; ?>
<?php if ( $title ) echo $before_title . $title . $after_title; ?>
<ul class="product_list_widget">
<?php foreach ($featured_posts as $r) : $_product = &new jigoshop_product( $r->ID ); ?>
<li><a href="<?php echo get_permalink( $r->ID ) ?>" title="<?php echo esc_attr($r->post_title ? $r->post_title : $r->ID); ?>">
<?php if (has_post_thumbnail( $r->ID )) echo get_the_post_thumbnail($r->ID, 'shop_tiny'); else echo '<img src="'.jigoshop::plugin_url().'/assets/images/placeholder.png" alt="Placeholder" width="'.jigoshop::get_var('shop_tiny_w').'px" height="'.jigoshop::get_var('shop_tiny_h').'px" />'; ?>
<?php if ( $r->post_title ) echo $r->post_title; else echo $r->ID; ?>
</a> <?php echo $_product->get_price_html(); ?></li>
<?php endforeach; ?>
</ul>
<?php echo $after_widget; ?>
<?php
endif;
$cache[$args['widget_id']] = ob_get_flush();
wp_cache_set('widget_featured_products', $cache, 'widget');
}
/** @see WP_Widget::update */
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['number'] = (int) $new_instance['number'];
$this->flush_widget_cache();
$alloptions = wp_cache_get( 'alloptions', 'options' );
if ( isset($alloptions['widget_featured_products']) ) delete_option('widget_featured_products');
return $instance;
}
function flush_widget_cache() {
wp_cache_delete('widget_featured_products', 'widget');
}
/** @see WP_Widget::form */
function form( $instance ) {
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
if ( !isset($instance['number']) || !$number = (int) $instance['number'] )
$number = 2;
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'jigoshop'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of products to show:', 'jigoshop'); ?></label>
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
<?php
}
} // class Jigoshop_Widget_Featured_Products

View File

@ -1,175 +0,0 @@
<?php
/**
* Layered Navigation Widget
*
* @package JigoShop
* @category Widgets
* @author Jigowatt
* @since 1.0
*
*/
class Jigoshop_Widget_Layered_Nav extends WP_Widget {
/** constructor */
function Jigoshop_Widget_Layered_Nav() {
$widget_ops = array( 'description' => __( "Shows a custom attribute in a widget which lets you narrow down the list of shown products in categories.", 'jigoshop') );
parent::WP_Widget('layered_nav', __('Layered Nav', 'jigoshop'), $widget_ops);
}
/** @see WP_Widget::widget */
function widget( $args, $instance ) {
extract($args);
if (!is_tax( 'product_cat' ) && !is_post_type_archive('product') && !is_tax( 'product_tag' )) return;
global $_chosen_attributes, $wpdb, $all_post_ids;
$title = $instance['title'];
$taxonomy = 'product_attribute_'.strtolower(sanitize_title($instance['attribute']));
if (!taxonomy_exists($taxonomy)) return;
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
$args = array(
'hide_empty' => '1'
);
$terms = get_terms( $taxonomy, $args );
$count = count($terms);
if($count > 0){
$found = false;
ob_start();
echo $before_widget . $before_title . $title . $after_title;
echo "<ul>";
// Reduce count based on chosen attributes
$all_post_ids = jigoshop_layered_nav_query( $all_post_ids );
$all_post_ids = jigoshop_price_filter( $all_post_ids );
foreach ($terms as $term) {
$_products_in_term = get_objects_in_term( $term->term_id, $taxonomy );
$count = sizeof(array_intersect($_products_in_term, $all_post_ids));
if ($count>0) $found = true;
$class = '';
$arg = 'filter_'.strtolower(sanitize_title($instance['attribute']));
if (isset($_GET[ $arg ])) $current_filter = explode(',', $_GET[ $arg ]); else $current_filter = array();
if (!is_array($current_filter)) $current_filter = array();
if (!in_array($term->term_id, $current_filter)) $current_filter[] = $term->term_id;
// Base Link decided by current page
if (defined('SHOP_IS_ON_FRONT')) :
$link = '';
elseif (is_post_type_archive('product') || is_page( get_option('jigoshop_shop_page_id') )) :
$link = get_post_type_archive_link('product');
else :
$link = get_term_link( get_query_var('term'), get_query_var('taxonomy') );
endif;
// All current filters
if ($_chosen_attributes) foreach ($_chosen_attributes as $name => $value) :
if ($name!==$taxonomy) :
$link = add_query_arg( strtolower(sanitize_title(str_replace('product_attribute_', 'filter_', $name))), implode(',', $value), $link );
endif;
endforeach;
// Min/Max
if (isset($_GET['min_price'])) :
$link = add_query_arg( 'min_price', $_GET['min_price'], $link );
endif;
if (isset($_GET['max_price'])) :
$link = add_query_arg( 'max_price', $_GET['max_price'], $link );
endif;
// Current Filter = this widget
if (isset( $_chosen_attributes[$taxonomy] ) && is_array($_chosen_attributes[$taxonomy]) && in_array($term->term_id, $_chosen_attributes[$taxonomy])) :
$class = 'class="chosen"';
else :
$link = add_query_arg( $arg, implode(',', $current_filter), $link );
endif;
// Search Arg
if (get_search_query()) :
$link = add_query_arg( 's', get_search_query(), $link );
endif;
// Post Type Arg
if (isset($_GET['post_type'])) :
$link = add_query_arg( 'post_type', $_GET['post_type'], $link );
endif;
echo '<li '.$class.'>';
if ($count>0) echo '<a href="'.$link.'">'; else echo '<span>';
echo $term->name;
if ($count>0) echo '</a>'; else echo '</span>';
echo ' <small class="count">'.$count.'</small></li>';
}
echo "</ul>";
echo $after_widget;
if (!$found) :
ob_clean();
return;
else :
$widget = ob_get_clean();
echo $widget;
endif;
}
}
/** @see WP_Widget::update */
function update( $new_instance, $old_instance ) {
if (!isset($new_instance['title']) || empty($new_instance['title'])) $new_instance['title'] = ucwords($new_instance['attribute']);
$instance['title'] = strip_tags(stripslashes($new_instance['title']));
$instance['attribute'] = stripslashes($new_instance['attribute']);
return $instance;
}
/** @see WP_Widget::form */
function form( $instance ) {
global $wpdb;
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'jigoshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );} ?>" /></p>
<p><label for="<?php echo $this->get_field_id('attribute'); ?>"><?php _e('Attribute:', 'jigoshop') ?></label>
<select id="<?php echo $this->get_field_id('attribute'); ?>" name="<?php echo $this->get_field_name('attribute'); ?>">
<?php
$attribute_taxonomies = jigoshop::$attribute_taxonomies;
if ( $attribute_taxonomies ) :
foreach ($attribute_taxonomies as $tax) :
if (taxonomy_exists('product_attribute_'.strtolower(sanitize_title($tax->attribute_name)))) :
echo '<option value="'.$tax->attribute_name.'" ';
if (isset($instance['attribute']) && $instance['attribute']==$tax->attribute_name) :
echo 'selected="selected"';
endif;
echo '>'.$tax->attribute_name.'</option>';
endif;
endforeach;
endif;
?>
</select>
<?php
}
} // class Jigoshop_Widget_Layered_Nav

View File

@ -1,117 +0,0 @@
<?php
function jigoshop_price_filter_init() {
unset($_SESSION['min_price']);
unset($_SESSION['max_price']);
if (isset($_GET['min_price'])) :
$_SESSION['min_price'] = $_GET['min_price'];
endif;
if (isset($_GET['max_price'])) :
$_SESSION['max_price'] = $_GET['max_price'];
endif;
}
add_action('init', 'jigoshop_price_filter_init');
/**
* Price Filter Widget
*
* Generates a range slider to filter products by price
*
* @package JigoShop
* @category Widgets
* @author Jigowatt
* @since 1.0
*
*/
class Jigoshop_Widget_Price_Filter extends WP_Widget {
/** constructor */
function Jigoshop_Widget_Price_Filter() {
$widget_ops = array( 'description' => __( "Shows a price filter slider in a widget which lets you narrow down the list of shown products in categories.", 'jigoshop') );
parent::WP_Widget('price_filter', __('Price Filter', 'jigoshop'), $widget_ops);
}
/** @see WP_Widget::widget */
function widget( $args, $instance ) {
extract($args);
if (!is_tax( 'product_cat' ) && !is_post_type_archive('product') && !is_tax( 'product_tag' )) return;
global $_chosen_attributes, $wpdb, $all_post_ids;
$title = $instance['title'];
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
echo $before_widget . $before_title . $title . $after_title;
// Remember current filters/search
$fields = '';
if (get_search_query()) $fields = '<input type="hidden" name="s" value="'.get_search_query().'" />';
if (isset($_GET['post_type'])) $fields .= '<input type="hidden" name="post_type" value="'.$_GET['post_type'].'" />';
if ($_chosen_attributes) foreach ($_chosen_attributes as $attribute => $value) :
$fields .= '<input type="hidden" name="'.str_replace('product_attribute_', 'filter_', $attribute).'" value="'.implode(',', $value).'" />';
endforeach;
$min = 0;
$max = ceil($wpdb->get_var("SELECT max(meta_value + 0)
FROM $wpdb->posts
LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id
WHERE meta_key = 'price' AND (
$wpdb->posts.ID IN (".implode(',', $all_post_ids).")
OR (
$wpdb->posts.post_parent IN (".implode(',', $all_post_ids).")
AND $wpdb->posts.post_parent != 0
)
)"));
if (defined('SHOP_IS_ON_FRONT')) :
$link = '';
elseif (is_post_type_archive('product') || is_page( get_option('jigoshop_shop_page_id') )) :
$link = get_post_type_archive_link('product');
else :
$link = get_term_link( get_query_var('term'), get_query_var('taxonomy') );
endif;
echo '<form method="get" action="'.$link.'">
<div class="price_slider_wrapper">
<div class="price_slider"></div>
<div class="price_slider_amount">
<button type="submit" class="button">Filter</button>'.__('Price: ', 'jigoshop').'<span></span>
<input type="hidden" id="max_price" name="max_price" value="'.$max.'" />
<input type="hidden" id="min_price" name="min_price" value="'.$min.'" />
'.$fields.'
</div>
</div>
</form>';
echo $after_widget;
}
/** @see WP_Widget::update */
function update( $new_instance, $old_instance ) {
if (!isset($new_instance['title']) || empty($new_instance['title'])) $new_instance['title'] = __('Filter by price', 'jigoshop');
$instance['title'] = strip_tags(stripslashes($new_instance['title']));
return $instance;
}
/** @see WP_Widget::form */
function form( $instance ) {
global $wpdb;
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'jigoshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );} ?>" /></p>
<?php
}
} // class Jigoshop_Widget_Price_Filter

View File

@ -1,113 +0,0 @@
<?php
/**
* Product Search Widget
*
* @package JigoShop
* @category Widgets
* @author Jigowatt
* @since 1.0
*
*/
class Jigoshop_Widget_Product_Categories extends WP_Widget {
/** constructor */
function Jigoshop_Widget_Product_Categories() {
$widget_ops = array( 'classname' => 'widget_product_categories', 'description' => __( "A list or dropdown of product categories", 'jigoshop' ) );
parent::WP_Widget('product_categories', __('Product Categories', 'jigoshop'), $widget_ops);
}
/** @see WP_Widget::widget */
function widget( $args, $instance ) {
extract( $args );
$title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Product Categories', 'jigoshop' ) : $instance['title'], $instance, $this->id_base);
$c = $instance['count'] ? '1' : '0';
$h = $instance['hierarchical'] ? '1' : '0';
$d = $instance['dropdown'] ? '1' : '0';
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h, 'taxonomy' => 'product_cat');
if ( $d ) {
$terms = get_terms('product_cat');
$output = "<select name='product_cat' id='dropdown_product_cat'>";
$output .= '<option value="">'.__('Select Category', 'jigoshop').'</option>';
foreach($terms as $term){
$root_url = get_bloginfo('url');
$term_taxonomy=$term->taxonomy;
$term_slug=$term->slug;
$term_name =$term->name;
$link = $term_slug;
$output .="<option value='".$link."'>".$term_name."</option>";
}
$output .="</select>";
echo $output;
?>
<script type='text/javascript'>
/* <![CDATA[ */
var dropdown = document.getElementById("dropdown_product_cat");
function onCatChange() {
if ( dropdown.options[dropdown.selectedIndex].value !=='' ) {
location.href = "<?php echo home_url(); ?>/?product_cat="+dropdown.options[dropdown.selectedIndex].value;
}
}
dropdown.onchange = onCatChange;
/* ]]> */
</script>
<?php
} else {
?>
<ul>
<?php
$cat_args['title_li'] = '';
wp_list_categories(apply_filters('widget_product_categories_args', $cat_args));
?>
</ul>
<?php
}
echo $after_widget;
}
/** @see WP_Widget::update */
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['count'] = !empty($new_instance['count']) ? 1 : 0;
$instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0;
$instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
return $instance;
}
/** @see WP_Widget::form */
function form( $instance ) {
//Defaults
$instance = wp_parse_args( (array) $instance, array( 'title' => '') );
$title = esc_attr( $instance['title'] );
$count = isset($instance['count']) ? (bool) $instance['count'] :false;
$hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
$dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', 'jigoshop' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
<p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>"<?php checked( $dropdown ); ?> />
<label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Show as dropdown', 'jigoshop' ); ?></label><br />
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked( $count ); ?> />
<label for="<?php echo $this->get_field_id('count'); ?>"><?php _e( 'Show post counts', 'jigoshop' ); ?></label><br />
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked( $hierarchical ); ?> />
<label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e( 'Show hierarchy', 'jigoshop' ); ?></label></p>
<?php
}
} // class Jigoshop_Widget_Product_Categories

View File

@ -1,59 +0,0 @@
<?php
/**
* Product Search Widget
*
* @package JigoShop
* @category Widgets
* @author Jigowatt
* @since 1.0
*
*/
class Jigoshop_Widget_Product_Search extends WP_Widget {
/** constructor */
function Jigoshop_Widget_Product_Search() {
$widget_ops = array( 'description' => __( "Search box for products only.", 'jigoshop') );
parent::WP_Widget('product_search', __('Product Search', 'jigoshop'), $widget_ops);
}
/** @see WP_Widget::widget */
function widget( $args, $instance ) {
extract($args);
$title = $instance['title'];
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
echo $before_widget;
if ($title) echo $before_title . $title . $after_title;
?>
<form role="search" method="get" id="searchform" action="<?php echo home_url(); ?>">
<div>
<label class="screen-reader-text" for="s"><?php _e('Search for:', 'jigoshop'); ?></label>
<input type="text" value="<?php the_search_query(); ?>" name="s" id="s" placeholder="<?php _e('Search for products', 'jigoshop'); ?>" />
<input type="submit" id="searchsubmit" value="<?php _e('Search', 'jigoshop'); ?>" />
<input type="hidden" name="post_type" value="product" />
</div>
</form>
<?php
echo $after_widget;
}
/** @see WP_Widget::update */
function update( $new_instance, $old_instance ) {
$instance['title'] = strip_tags(stripslashes($new_instance['title']));
return $instance;
}
/** @see WP_Widget::form */
function form( $instance ) {
global $wpdb;
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'jigoshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );} ?>" /></p>
<?php
}
} // Jigoshop_Widget_Product_Search

View File

@ -1,64 +0,0 @@
<?php
/**
* Tag Cloud Widget
*
* @package JigoShop
* @category Widgets
* @author Jigowatt
* @since 1.0
*
*/
class Jigoshop_Widget_Tag_Cloud extends WP_Widget {
/** constructor */
function Jigoshop_Widget_Tag_Cloud() {
$widget_ops = array( 'description' => __( "Your most used product tags in cloud format", 'jigoshop') );
parent::WP_Widget('tag_cloud', __('Product Tag Cloud', 'jigoshop'), $widget_ops);
}
/** @see WP_Widget::widget */
function widget( $args, $instance ) {
extract($args);
$current_taxonomy = $this->_get_current_taxonomy($instance);
if ( !empty($instance['title']) ) {
$title = $instance['title'];
} else {
if ( 'product_tag' == $current_taxonomy ) {
$title = __('Product Tags', 'jigoshop');
} else {
$tax = get_taxonomy($current_taxonomy);
$title = $tax->labels->name;
}
}
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
echo '<div class="tagcloud">';
wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) );
echo "</div>\n";
echo $after_widget;
}
/** @see WP_Widget::update */
function update( $new_instance, $old_instance ) {
$instance['title'] = strip_tags(stripslashes($new_instance['title']));
$instance['taxonomy'] = stripslashes($new_instance['taxonomy']);
return $instance;
}
/** @see WP_Widget::form */
function form( $instance ) {
$current_taxonomy = $this->_get_current_taxonomy($instance);
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'jigoshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );} ?>" /></p>
<?php
}
function _get_current_taxonomy($instance) {
return 'product_tag';
}
} // class Jigoshop_Widget_Tag_Cloud

View File

@ -1,125 +0,0 @@
<?php
/**
* Recent Products Widget
*
* @package JigoShop
* @category Widgets
* @author Jigowatt
* @since 1.0
*
*/
class Jigoshop_Widget_Recent_Products extends WP_Widget {
/** constructor */
function Jigoshop_Widget_Recent_Products() {
$widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "The most recent products on your site", 'jigoshop') );
parent::WP_Widget('recent-products', __('New Products', 'jigoshop'), $widget_ops);
$this->alt_option_name = 'widget_recent_entries';
add_action( 'save_post', array(&$this, 'flush_widget_cache') );
add_action( 'deleted_post', array(&$this, 'flush_widget_cache') );
add_action( 'switch_theme', array(&$this, 'flush_widget_cache') );
}
/** @see WP_Widget::widget */
function widget($args, $instance) {
$cache = wp_cache_get('widget_recent_products', 'widget');
if ( !is_array($cache) ) $cache = array();
if ( isset($cache[$args['widget_id']]) ) {
echo $cache[$args['widget_id']];
return;
}
ob_start();
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? __('New Products', 'jigoshop') : $instance['title'], $instance, $this->id_base);
if ( !$number = (int) $instance['number'] )
$number = 10;
else if ( $number < 1 )
$number = 1;
else if ( $number > 15 )
$number = 15;
$show_variations = $instance['show_variations'] ? '1' : '0';
$args = array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'post_type' => 'product');
if($show_variations=='0'){
$args['meta_query'] = array(
array(
'key' => 'visibility',
'value' => array('catalog', 'visible'),
'compare' => 'IN'
)
);
$args['parent'] = '0';
}
$r = new WP_Query($args);
if ($r->have_posts()) :
?>
<?php echo $before_widget; ?>
<?php if ( $title ) echo $before_title . $title . $after_title; ?>
<ul class="product_list_widget">
<?php while ($r->have_posts()) : $r->the_post(); $_product = &new jigoshop_product(get_the_ID()); ?>
<li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>">
<?php if (has_post_thumbnail()) the_post_thumbnail('shop_tiny'); else echo '<img src="'.jigoshop::plugin_url().'/assets/images/placeholder.png" alt="Placeholder" width="'.jigoshop::get_var('shop_tiny_w').'px" height="'.jigoshop::get_var('shop_tiny_h').'px" />'; ?>
<?php if ( get_the_title() ) the_title(); else the_ID(); ?>
</a> <?php echo $_product->get_price_html(); ?></li>
<?php endwhile; ?>
</ul>
<?php echo $after_widget; ?>
<?php
// Reset the global $the_post as this query will have stomped on it
//wp_reset_postdata();
endif;
if (isset($args['widget_id']) && isset($cache[$args['widget_id']])) $cache[$args['widget_id']] = ob_get_flush();
wp_cache_set('widget_recent_products', $cache, 'widget');
}
/** @see WP_Widget::update */
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['number'] = (int) $new_instance['number'];
$instance['show_variations'] = !empty($new_instance['show_variations']) ? 1 : 0;
$this->flush_widget_cache();
$alloptions = wp_cache_get( 'alloptions', 'options' );
if ( isset($alloptions['widget_recent_products']) ) delete_option('widget_recent_products');
return $instance;
}
function flush_widget_cache() {
wp_cache_delete('widget_recent_products', 'widget');
}
/** @see WP_Widget::form */
function form( $instance ) {
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
if ( !isset($instance['number']) || !$number = (int) $instance['number'] )
$number = 5;
$show_variations = isset( $instance['show_variations'] ) ? (bool) $instance['show_variations'] : false;
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'jigoshop'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of products to show:', 'jigoshop'); ?></label>
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
<p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_variations'); ?>" name="<?php echo $this->get_field_name('show_variations'); ?>"<?php checked( $show_variations ); ?> />
<label for="<?php echo $this->get_field_id('show_variations'); ?>"><?php _e( 'Show hidden product variations', 'jigoshop' ); ?></label><br />
<?php
}
} // class Jigoshop_Widget_Recent_Products