First Commit - from Jigoshop Source

This commit is contained in:
Mike Jolley 2011-08-09 16:16:18 +01:00
commit 8e8613b116
158 changed files with 41285 additions and 0 deletions

View File

@ -0,0 +1,249 @@
<?php
/**
* Functions used for the attributes section in WordPress Admin
*
* The attributes section lets users add custom attributes to assign to products - they can also be used in the layered nav widgets.
*
* @author Jigowatt
* @category Admin
* @package JigoShop
*/
/**
* Attributes admin panel
*
* Shows the created attributes and lets you add new ones.
* The added attributes are stored in the database and can be used for layered navigation.
*
* @since 1.0
* @usedby jigoshop_admin_menu2()
*/
function jigoshop_attributes() {
global $wpdb;
if (isset($_POST['add_new_attribute']) && $_POST['add_new_attribute']) :
$attribute_name = (string) $_POST['attribute_name'];
$attribute_type = (string) $_POST['attribute_type'];
if (isset($_POST['show-on-product-page']) && $_POST['show-on-product-page']) $product_page = 1; else $product_page = 0;
if ($attribute_name && $attribute_type && !taxonomy_exists('product_attribute_'.strtolower(sanitize_title($attribute_name)))) :
$wpdb->insert( $wpdb->prefix . "jigoshop_attribute_taxonomies", array( 'attribute_name' => $attribute_name, 'attribute_type' => $attribute_type ), array( '%s', '%s' ) );
update_option('jigowatt_update_rewrite_rules', '1');
wp_safe_redirect( get_admin_url() . 'admin.php?page=attributes' );
exit;
endif;
elseif (isset($_POST['save_attribute']) && $_POST['save_attribute'] && isset($_GET['edit'])) :
$edit = absint($_GET['edit']);
if ($edit>0) :
$attribute_type = $_POST['attribute_type'];
$wpdb->update( $wpdb->prefix . "jigoshop_attribute_taxonomies", array( 'attribute_type' => $attribute_type ), array( 'attribute_id' => $_GET['edit'] ), array( '%s' ) );
endif;
wp_safe_redirect( get_admin_url() . 'admin.php?page=attributes' );
exit;
elseif (isset($_GET['delete'])) :
$delete = absint($_GET['delete']);
if ($delete>0) :
$att_name = $wpdb->get_var("SELECT attribute_name FROM " . $wpdb->prefix . "jigoshop_attribute_taxonomies WHERE attribute_id = '$delete'");
if ($att_name && $wpdb->query("DELETE FROM " . $wpdb->prefix . "jigoshop_attribute_taxonomies WHERE attribute_id = '$delete'")) :
$taxonomy = 'product_attribute_'.strtolower(sanitize_title($att_name));
if (taxonomy_exists($taxonomy)) :
$terms = get_terms($taxonomy, 'orderby=name&hide_empty=0');
foreach ($terms as $term) {
wp_delete_term( $term->term_id, $taxonomy );
}
endif;
wp_safe_redirect( get_admin_url() . 'admin.php?page=attributes' );
exit;
endif;
endif;
endif;
if (isset($_GET['edit']) && $_GET['edit'] > 0) :
jigoshop_edit_attribute();
else :
jigoshop_add_attribute();
endif;
}
/**
* Edit Attribute admin panel
*
* Shows the interface for changing an attributes type between select, multiselect and text
*
* @since 1.0
* @usedby jigoshop_attributes()
*/
function jigoshop_edit_attribute() {
global $wpdb;
$edit = absint($_GET['edit']);
$att_type = $wpdb->get_var("SELECT attribute_type FROM " . $wpdb->prefix . "jigoshop_attribute_taxonomies WHERE attribute_id = '$edit'");
?>
<div class="wrap jigoshop">
<div class="icon32 icon32-attributes" id="icon-jigoshop"><br/></div>
<h2><?php _e('Attributes','jigoshop') ?></h2>
<br class="clear" />
<div id="col-container">
<div id="col-left">
<div class="col-wrap">
<div class="form-wrap">
<h3><?php _e('Edit Attribute','jigoshop') ?></h3>
<p><?php _e('Attribute taxonomy names cannot be changed; you may only change an attributes type.','jigoshop') ?></p>
<form action="admin.php?page=attributes&amp;edit=<?php echo $edit; ?>" method="post">
<div class="form-field">
<label for="attribute_type"><?php _e('Attribute type', 'jigoshop'); ?></label>
<select name="attribute_type" id="attribute_type" style="width: 100%;">
<option value="select" <?php if ($att_type=='select') echo 'selected="selected"'; ?>><?php _e('Select','jigoshop') ?></option>
<option value="multiselect" <?php if ($att_type=='multiselect') echo 'selected="selected"'; ?>><?php _e('Multiselect','jigoshop') ?></option>
<option value="text" <?php if ($att_type=='text') echo 'selected="selected"'; ?>><?php _e('Text','jigoshop') ?></option>
</select>
</div>
<p class="submit"><input type="submit" name="save_attribute" id="submit" class="button" value="<?php _e('Save Attribute', 'jigoshop'); ?>"></p>
</form>
</div>
</div>
</div>
</div>
</div>
<?php
}
/**
* Add Attribute admin panel
*
* Shows the interface for adding new attributes
*
* @since 1.0
* @usedby jigoshop_attributes()
*/
function jigoshop_add_attribute() {
?>
<div class="wrap jigoshop">
<div class="icon32 icon32-attributes" id="icon-jigoshop"><br/></div>
<h2><?php _e('Attributes','jigoshop') ?></h2>
<br class="clear" />
<div id="col-container">
<div id="col-right">
<div class="col-wrap">
<table class="widefat fixed" style="width:100%">
<thead>
<tr>
<th scope="col"><?php _e('Name','jigoshop') ?></th>
<th scope="col"><?php _e('Type','jigoshop') ?></th>
<th scope="col"><?php _e('Terms','jigoshop') ?></th>
</tr>
</thead>
<tbody>
<?php
$attribute_taxonomies = jigoshop::$attribute_taxonomies;
if ( $attribute_taxonomies ) :
foreach ($attribute_taxonomies as $tax) :
?><tr>
<td><a href="edit-tags.php?taxonomy=product_attribute_<?php echo strtolower(sanitize_title($tax->attribute_name)); ?>&amp;post_type=product"><?php echo $tax->attribute_name; ?></a>
<div class="row-actions"><span class="edit"><a href="<?php echo add_query_arg('edit', $tax->attribute_id, 'admin.php?page=attributes') ?>"><?php _e('Edit', 'jigoshop'); ?></a> | </span><span class="delete"><a class="delete" href="<?php echo add_query_arg('delete', $tax->attribute_id, 'admin.php?page=attributes') ?>"><?php _e('Delete', 'jigoshop'); ?></a></span></div>
</td>
<td><?php echo ucwords($tax->attribute_type); ?></td>
<td><?php
if (taxonomy_exists('product_attribute_'.strtolower(sanitize_title($tax->attribute_name)))) :
$terms_array = array();
$terms = get_terms( 'product_attribute_'.strtolower(sanitize_title($tax->attribute_name)), 'orderby=name&hide_empty=0' );
if ($terms) :
foreach ($terms as $term) :
$terms_array[] = $term->name;
endforeach;
echo implode(', ', $terms_array);
else :
echo '<span class="na">&ndash;</span>';
endif;
else :
echo '<span class="na">&ndash;</span>';
endif;
?></td>
</tr><?php
endforeach;
else :
?><tr><td colspan="5"><?php _e('No attributes currently exist.','jigoshop') ?></td></tr><?php
endif;
?>
</tbody>
</table>
</div>
</div>
<div id="col-left">
<div class="col-wrap">
<div class="form-wrap">
<h3><?php _e('Add New Attribute','jigoshop') ?></h3>
<p><?php _e('Attributes let you define extra product data, such as size or colour. You can use these attributes in the shop sidebar using the "layered nav" widgets. Please note: you cannot rename an attribute later on.','jigoshop') ?></p>
<form action="admin.php?page=attributes" method="post">
<div style="width:47%; float:left; margin:0 1% 0 0;">
<div class="form-field">
<label for="attribute_name"><?php _e('Attribute Name', 'jigoshop'); ?></label>
<input name="attribute_name" id="attribute_name" type="text" value="" />
</div>
</div>
<div style="width:47%; float:left; margin:0 1% 0 0;">
<div class="form-field">
<label for="attribute_type"><?php _e('Attribute type', 'jigoshop'); ?></label>
<select name="attribute_type" id="attribute_type" style="width: 100%;">
<option value="select"><?php _e('Select','jigoshop') ?></option>
<option value="multiselect"><?php _e('Multiselect','jigoshop') ?></option>
<option value="text"><?php _e('Text','jigoshop') ?></option>
</select>
</div>
</div>
<div class="clear"></div>
<p class="submit"><input type="submit" name="add_new_attribute" id="submit" class="button" value="<?php _e('Add Attribute', 'jigoshop'); ?>"></p>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
/* <![CDATA[ */
jQuery('a.delete').click(function(){
var answer = confirm ("<?php _e('Are you sure you want to delete this?', 'jigoshop'); ?>");
if (answer) return true;
return false;
});
/* ]]> */
</script>
</div>
<?php
}

View File

@ -0,0 +1,564 @@
<?php
/**
* Functions used for displaying the jigoshop dashboard
*
* @author Jigowatt
* @category Admin
* @package JigoShop
*/
/**
* Function for showing the dashboard
*
* The dashboard shows widget for things such as:
* - Products
* - Sales
* - Recent reviews
*
* @since 1.0
* @usedby jigoshop_admin_menu()
*/
function jigoshop_dashboard() {
?>
<div class="wrap jigoshop">
<div class="icon32 jigoshop_icon"><br/></div>
<h2><?php _e('Jigoshop Dashboard','jigoshop'); ?></h2>
<div id="jigoshop_dashboard">
<div id="dashboard-widgets" class="metabox-holder">
<div class="postbox-container" style="width:49%;">
<div id="jigoshop_right_now" class="jigoshop_right_now postbox">
<h3><?php _e('Right Now', 'jigoshop') ?></h3>
<div class="inside">
<div class="table table_content">
<p class="sub"><?php _e('Shop Content', 'jigoshop'); ?></p>
<table>
<tbody>
<tr class="first">
<td class="first b"><a href="edit.php?post_type=product"><?php
$num_posts = wp_count_posts( 'product' );
$num = number_format_i18n( $num_posts->publish );
echo $num;
?></a></td>
<td class="t"><a href="edit.php?post_type=product"><?php _e('Products', 'jigoshop'); ?></a></td>
</tr>
<tr>
<td class="first b"><a href="edit-tags.php?taxonomy=product_cat&post_type=product"><?php
echo wp_count_terms('product_cat');
?></a></td>
<td class="t"><a href="edit-tags.php?taxonomy=product_cat&post_type=product"><?php _e('Product Categories', 'jigoshop'); ?></a></td>
</tr>
<tr>
<td class="first b"><a href="edit-tags.php?taxonomy=product_tag&post_type=product"><?php
echo wp_count_terms('product_tag');
?></a></td>
<td class="t"><a href="edit-tags.php?taxonomy=product_tag&post_type=product"><?php _e('Product Tag', 'jigoshop'); ?></a></td>
</tr>
<tr>
<td class="first b"><a href="admin.php?page=attributes"><?php
echo sizeof(jigoshop::$attribute_taxonomies);
?></a></td>
<td class="t"><a href="admin.php?page=attributes"><?php _e('Attribute taxonomies', 'jigoshop'); ?></a></td>
</tr>
</tbody>
</table>
</div>
<div class="table table_discussion">
<p class="sub"><?php _e('Orders', 'jigoshop'); ?></p>
<table>
<tbody>
<?php $jigoshop_orders = &new jigoshop_orders(); ?>
<tr class="first">
<td class="b"><a href="edit.php?post_type=shop_order&shop_order_status=pending"><span class="total-count"><?php echo $jigoshop_orders->pending_count; ?></span></a></td>
<td class="last t"><a class="pending" href="edit.php?post_type=shop_order&shop_order_status=pending"><?php _e('Pending', 'jigoshop'); ?></a></td>
</tr>
<tr>
<td class="b"><a href="edit.php?post_type=shop_order&shop_order_status=on-hold"><span class="total-count"><?php echo $jigoshop_orders->on_hold_count; ?></span></a></td>
<td class="last t"><a class="onhold" href="edit.php?post_type=shop_order&shop_order_status=on-hold"><?php _e('On-Hold', 'jigoshop'); ?></a></td>
</tr>
<tr>
<td class="b"><a href="edit.php?post_type=shop_order&shop_order_status=processing"><span class="total-count"><?php echo $jigoshop_orders->processing_count; ?></span></a></td>
<td class="last t"><a class="processing" href="edit.php?post_type=shop_order&shop_order_status=processing"><?php _e('Processing', 'jigoshop'); ?></a></td>
</tr>
<tr>
<td class="b"><a href="edit.php?post_type=shop_order&shop_order_status=completed"><span class="total-count"><?php echo $jigoshop_orders->completed_count; ?></span></a></td>
<td class="last t"><a class="complete" href="edit.php?post_type=shop_order&shop_order_status=completed"><?php _e('Completed', 'jigoshop'); ?></a></td>
</tr>
</tbody>
</table>
</div>
<div class="versions">
<p id="wp-version-message"><?php _e('You are using', 'jigoshop'); ?> <strong>JigoShop <?php echo JIGOSHOP_VERSION; ?>.</strong></p>
</div>
<div class="clear"></div>
</div>
</div><!-- postbox end -->
<div class="postbox">
<h3 class="hndle" id="poststuff"><span><?php _e('Recent Orders', 'jigoshop') ?></span></h3>
<div class="inside">
<?php
$args = array(
'numberposts' => 10,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'shop_order',
'post_status' => 'publish'
);
$orders = get_posts( $args );
if ($orders) :
echo '<ul class="recent-orders">';
foreach ($orders as $order) :
$this_order = &new jigoshop_order( $order->ID );
echo '
<li>
<span class="order-status '.sanitize_title($this_order->status).'">'.ucwords($this_order->status).'</span> <a href="'.admin_url('post.php?post='.$order->ID).'&action=edit">'.date_i18n('l jS \of F Y h:i:s A', strtotime($this_order->order_date)).'</a><br />
<small>'.sizeof($this_order->items).' '._n('item', 'items', sizeof($this_order->items), 'jigoshop').' <span class="order-cost">'.__('Total: ', 'jigoshop').jigoshop_price($this_order->order_total).'</span></small>
</li>';
endforeach;
echo '</ul>';
endif;
?>
</div>
</div><!-- postbox end -->
<?php if (get_option('jigoshop_manage_stock')=='yes') : ?>
<div class="postbox jigoshop_right_now">
<h3 class="hndle" id="poststuff"><span><?php _e('Stock Report', 'jigoshop') ?></span></h3>
<div class="inside">
<?php
$lowstockamount = get_option('jigoshop_notify_low_stock_amount');
if (!is_numeric($lowstockamount)) $lowstockamount = 1;
$nostockamount = get_option('jigoshop_notify_no_stock_amount');
if (!is_numeric($nostockamount)) $nostockamount = 1;
$outofstock = array();
$lowinstock = array();
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => -1
);
$my_query = new WP_Query($args);
if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post();
$_product = &new jigoshop_product( $my_query->post->ID );
if (!$_product->managing_stock()) continue;
$thisitem = '<tr class="first">
<td class="first b"><a href="post.php?post='.$my_query->post->ID.'&action=edit">'.$_product->stock.'</a></td>
<td class="t"><a href="post.php?post='.$my_query->post->ID.'&action=edit">'.$my_query->post->post_title.'</a></td>
</tr>';
if ($_product->stock<=$nostockamount) :
$outofstock[] = $thisitem;
continue;
endif;
if ($_product->stock<=$lowstockamount) $lowinstock[] = $thisitem;
endwhile; endif;
wp_reset_query();
if (sizeof($lowinstock)==0) :
$lowinstock[] = '<tr><td colspan="2">'.__('No products are low in stock.', 'jigoshop').'</td></tr>';
endif;
if (sizeof($outofstock)==0) :
$outofstock[] = '<tr><td colspan="2">'.__('No products are out of stock.', 'jigoshop').'</td></tr>';
endif;
?>
<div class="table table_content">
<p class="sub"><?php _e('Low Stock', 'jigoshop'); ?></p>
<table>
<tbody>
<?php echo implode('', $lowinstock); ?>
</tbody>
</table>
</div>
<div class="table table_discussion">
<p class="sub"><?php _e('Out of Stock/Backorders', 'jigoshop'); ?></p>
<table>
<tbody>
<?php echo implode('', $outofstock); ?>
</tbody>
</table>
</div>
<div class="clear"></div>
</div>
</div><!-- postbox end -->
<?php endif; ?>
</div>
<div class="postbox-container" style="width:49%; float:right;">
<?php
global $current_month_offset;
$current_month_offset = (int) date('m');
if (isset($_GET['month'])) $current_month_offset = (int) $_GET['month'];
?>
<div class="postbox stats" id="jigoshop-stats">
<h3 class="hndle" id="poststuff">
<?php if ($current_month_offset!=date('m')) : ?><a href="admin.php?page=jigoshop&amp;month=<?php echo $current_month_offset+1; ?>" class="next">Next Month &rarr;</a><?php endif; ?>
<a href="admin.php?page=jigoshop&amp;month=<?php echo $current_month_offset-1; ?>" class="previous">&larr; Previous Month</a>
<span><?php _e('Monthly Sales', 'jigoshop') ?></span></h3>
<div class="inside">
<div id="placeholder" style="width:100%; height:300px; position:relative;"></div>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(function(){
function weekendAreas(axes) {
var markings = [];
var d = new Date(axes.xaxis.min);
// go to the first Saturday
d.setUTCDate(d.getUTCDate() - ((d.getUTCDay() + 1) % 7))
d.setUTCSeconds(0);
d.setUTCMinutes(0);
d.setUTCHours(0);
var i = d.getTime();
do {
// when we don't set yaxis, the rectangle automatically
// extends to infinity upwards and downwards
markings.push({ xaxis: { from: i, to: i + 2 * 24 * 60 * 60 * 1000 } });
i += 7 * 24 * 60 * 60 * 1000;
} while (i < axes.xaxis.max);
return markings;
}
<?php
function orders_this_month( $where = '' ) {
global $current_month_offset;
$month = $current_month_offset;
$year = (int) date('Y');
$first_day = strtotime("{$year}-{$month}-01");
$last_day = strtotime('-1 second', strtotime('+1 month', $first_day));
$after = date('Y-m-d', $first_day);
$before = date('Y-m-d', $last_day);
$where .= " AND post_date > '$after'";
$where .= " AND post_date < '$before'";
return $where;
}
add_filter( 'posts_where', 'orders_this_month' );
$args = array(
'numberposts' => -1,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'shop_order',
'post_status' => 'publish' ,
'suppress_filters' => false
);
$orders = get_posts( $args );
$order_counts = array();
$order_amounts = array();
// Blank date ranges to begin
$month = $current_month_offset;
$year = (int) date('Y');
$first_day = strtotime("{$year}-{$month}-01");
$last_day = strtotime('-1 second', strtotime('+1 month', $first_day));
if ((date('m') - $current_month_offset)==0) :
$up_to = date('d', strtotime('NOW'));
else :
$up_to = date('d', $last_day);
endif;
$count = 0;
while ($count < $up_to) :
$time = strtotime(date('Ymd', strtotime('+ '.$count.' DAY', $first_day))).'000';
$order_counts[$time] = 0;
$order_amounts[$time] = 0;
$count++;
endwhile;
if ($orders) :
foreach ($orders as $order) :
$order_data = &new jigoshop_order($order->ID);
if ($order_data->status=='cancelled' || $order_data->status=='refunded') continue;
$time = strtotime(date('Ymd', strtotime($order->post_date))).'000';
if (isset($order_counts[$time])) :
$order_counts[$time]++;
else :
$order_counts[$time] = 1;
endif;
if (isset($order_amounts[$time])) :
$order_amounts[$time] = $order_amounts[$time] + $order_data->order_total;
else :
$order_amounts[$time] = (float) $order_data->order_total;
endif;
endforeach;
endif;
remove_filter( 'posts_where', 'orders_this_month' );
?>
var d = [
<?php
$values = array();
foreach ($order_counts as $key => $value) $values[] = "[$key, $value]";
echo implode(',', $values);
?>
];
for (var i = 0; i < d.length; ++i) d[i][0] += 60 * 60 * 1000;
var d2 = [
<?php
$values = array();
foreach ($order_amounts as $key => $value) $values[] = "[$key, $value]";
echo implode(',', $values);
?>
];
for (var i = 0; i < d2.length; ++i) d2[i][0] += 60 * 60 * 1000;
var plot = jQuery.plot(jQuery("#placeholder"), [ { label: "Number of sales", data: d }, { label: "Sales amount", data: d2, yaxis: 2 } ], {
series: {
lines: { show: true },
points: { show: true }
},
grid: {
show: true,
aboveData: false,
color: '#ccc',
backgroundColor: '#fff',
borderWidth: 2,
borderColor: '#ccc',
clickable: false,
hoverable: true,
markings: weekendAreas
},
xaxis: {
mode: "time",
timeformat: "%d %b",
tickLength: 1,
minTickSize: [1, "day"]
},
yaxes: [ { min: 0, tickSize: 1, tickDecimals: 0 }, { position: "right", min: 0, tickDecimals: 2 } ],
colors: ["#21759B", "#ed8432"]
});
function showTooltip(x, y, contents) {
jQuery('<div id="tooltip">' + contents + '</div>').css( {
position: 'absolute',
display: 'none',
top: y + 5,
left: x + 5,
border: '1px solid #fdd',
padding: '2px',
'background-color': '#fee',
opacity: 0.80
}).appendTo("body").fadeIn(200);
}
var previousPoint = null;
jQuery("#placeholder").bind("plothover", function (event, pos, item) {
if (item) {
if (previousPoint != item.dataIndex) {
previousPoint = item.dataIndex;
jQuery("#tooltip").remove();
if (item.series.label=="Number of sales") {
var y = item.datapoint[1];
showTooltip(item.pageX, item.pageY, item.series.label + " - " + y);
} else {
var y = item.datapoint[1].toFixed(2);
showTooltip(item.pageX, item.pageY, item.series.label + " - <?php echo get_jigoshop_currency_symbol(); ?>" + y);
}
}
}
else {
jQuery("#tooltip").remove();
previousPoint = null;
}
});
});
/* ]]> */
</script>
</div>
</div><!-- postbox end -->
<div class="postbox">
<h3 class="hndle" id="poststuff"><span><?php _e('Recent Product Reviews', 'jigoshop') ?></span></h3>
<div class="inside jigoshop-reviews-widget">
<?php
global $wpdb;
$comments = $wpdb->get_results("SELECT *, SUBSTRING(comment_content,1,100) AS comment_excerpt
FROM $wpdb->comments
LEFT JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID)
WHERE comment_approved = '1'
AND comment_type = ''
AND post_password = ''
AND post_type = 'product'
ORDER BY comment_date_gmt DESC
LIMIT 5" );
if ($comments) :
echo '<ul>';
foreach ($comments as $comment) :
echo '<li>';
echo get_avatar($comment->comment_author, '32');
$rating = get_comment_meta( $comment->comment_ID, 'rating', true );
echo '<div class="star-rating" title="'.$rating.'">
<span style="width:'.($rating*16).'px">'.$rating.' '.__('out of 5', 'jigoshop').'</span></div>';
echo '<h4 class="meta"><a href="'.get_permalink($comment->ID).'#comment-'.$comment->comment_ID .'">'.$comment->post_title.'</a> reviewed by ' .strip_tags($comment->comment_author) .'</h4>';
echo '<blockquote>'.strip_tags($comment->comment_excerpt).' [...]</blockquote></li>';
endforeach;
echo '</ul>';
else :
echo '<p>'.__('There are no product reviews yet.', 'jigoshop').'</p>';
endif;
?>
</div>
</div><!-- postbox end -->
<div class="postbox">
<h3 class="hndle" id="poststuff"><span><?php _e('Latest News', 'jigoshop') ?></span></h3>
<div class="inside jigoshop-rss-widget">
<?php
if (file_exists(ABSPATH.WPINC.'/class-simplepie.php')) {
include_once(ABSPATH.WPINC.'/class-simplepie.php');
$rss = fetch_feed('http://jigoshop.com/feed');
if (!is_wp_error( $rss ) ) :
$maxitems = $rss->get_item_quantity(5);
$rss_items = $rss->get_items(0, $maxitems);
if ( $maxitems > 0 ) :
echo '<ul>';
foreach ( $rss_items as $item ) :
$title = wptexturize($item->get_title(), ENT_QUOTES, "UTF-8");
$link = $item->get_permalink();
$date = $item->get_date('U');
if ( ( abs( time() - $date) ) < 86400 ) : // 1 Day
$human_date = sprintf(__('%s ago','jigoshop'), human_time_diff($date));
else :
$human_date = date(__('F jS Y','jigoshop'), $date);
endif;
echo '<li><a href="'.$link.'">'.$title.'</a> &ndash; <span class="rss-date">'.$human_date.'</span></li>';
endforeach;
echo '</ul>';
else :
echo '<ul><li>'.__('No items found.','jigoshop').'</li></ul>';
endif;
else :
echo '<ul><li>'.__('No items found.','jigoshop').'</li></ul>';
endif;
}
?>
</div>
</div><!-- postbox end -->
<div class="postbox">
<h3 class="hndle" id="poststuff"><span><?php _e('Useful Links', 'jigoshop') ?></span></h3>
<div class="inside jigoshop-links-widget">
<ul class="links">
<li><a href="http://jigoshop.com/"><?php _e('Jigoshop', 'jigoshop'); ?></a> &ndash; <?php _e('Learn more about the Jigoshop plugin', 'jigoshop'); ?></li>
<li><a href="http://jigoshop.com/tour/"><?php _e('Tour', 'jigoshop'); ?></a> &ndash; <?php _e('Take a tour of the plugin', 'jigoshop'); ?></li>
<li><a href="http://jigoshop.com/user-guide/"><?php _e('Documentation', 'jigoshop'); ?></a> &ndash; <?php _e('Stuck? Read the plugin\'s documentation.', 'jigoshop'); ?></li>
<li><a href="http://jigoshop.com/forums/"><?php _e('Forums', 'jigoshop'); ?></a> &ndash; <?php _e('Help from the community or our dedicated support team.', 'jigoshop'); ?></li>
<li><a href="http://jigoshop.com/extend/extensions/"><?php _e('Jigoshop Extensions', 'jigoshop'); ?></a> &ndash; <?php _e('Extend Jigoshop with extra plugins and modules.', 'jigoshop'); ?></li>
<li><a href="http://jigoshop.com/extend/themes/"><?php _e('Jigoshop Themes', 'jigoshop'); ?></a> &ndash; <?php _e('Extend Jigoshop with themes.', 'jigoshop'); ?></li>
<li><a href="http://twitter.com/#!/jigoshop"><?php _e('@Jigoshop', 'jigoshop'); ?></a> &ndash; <?php _e('Follow us on Twitter.', 'jigoshop'); ?></li>
<li><a href="https://github.com/mikejolley/Jigoshop"><?php _e('Jigoshop on Github', 'jigoshop'); ?></a> &ndash; <?php _e('Help extend Jigoshop.', 'jigoshop'); ?></li>
<li><a href="http://wordpress.org/extend/plugins/jigoshop/"><?php _e('Jigoshop on WordPress.org', 'jigoshop'); ?></a> &ndash; <?php _e('Leave us a rating!', 'jigoshop'); ?></li>
</ul>
<div class="social">
<h4 class="first"><?php _e('Show your support &amp; Help promote Jigoshop!', 'jigoshop'); ?></h4>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="margin: 0 0 1em 0;">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="TKRER2WH7UAD6">
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online." style="margin:0; padding:0; ">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjigoshop.com&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=segoe+ui&amp;height=24" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:24px;" allowTransparency="true"></iframe>
<p><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://jigoshop.com/" data-text="Jigoshop: A WordPress eCommerce solution that works" data-count="horizontal" data-via="jigoshop" data-related="Jigowatt:Creators">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></p>
<p><g:plusone size="medium" href="http://jigoshop.com/"></g:plusone><script type="text/javascript" src="https://apis.google.com/js/plusone.js">{lang: 'en-GB'}</script></p>
<h4><?php _e('Jigoshop is bought to you by&hellip;', 'jigoshop'); ?></h4>
<p><a href="http://jigowatt.co.uk/"><img src="<?php echo jigoshop::plugin_url(); ?>/assets/images/jigowatt.png" alt="Jigowatt" /></a></p>
<p>From design to deployment Jigowatt delivers expert solutions to enterprise customers using Magento & WordPress open source platforms.</p>
</div>
<div class="clear"></div>
</div>
</div><!-- postbox end -->
</div>
</div>
</div>
</div>
<?php
}

View File

@ -0,0 +1,343 @@
<?php
/**
* Functions used for custom post types in admin
*
* These functions control columns in admin, and other admin interface bits
*
* @author Jigowatt
* @category Admin
* @package JigoShop
*/
/**
* Custom columns
**/
function jigoshop_edit_variation_columns($columns){
$columns = array();
$columns["cb"] = "<input type=\"checkbox\" />";
$columns["thumb"] = __("Thumb", 'jigoshop');
$columns["id"] = __("ID", 'jigoshop');
$columns["title"] = __("Name", 'jigoshop');
$columns["parent"] = __("Parent Product", 'jigoshop');
return $columns;
}
add_filter('manage_edit-product_variation_columns', 'jigoshop_edit_variation_columns');
function jigoshop_custom_variation_columns($column) {
global $post;
$product = &new jigoshop_product($post->ID);
switch ($column) {
case "thumb" :
if (has_post_thumbnail($post->ID)) :
echo get_the_post_thumbnail($post->ID, 'shop_tiny');
endif;
break;
case "id" :
echo '#'.$post->ID;
break;
case "parent" :
if ($post->post_parent) :
$parent = get_post( $post->post_parent );
echo '#'.$parent->ID.' &mdash; <a href="'.admin_url('post.php?post='.$parent->ID.'&action=edit').'">'.$parent->post_title.'</a>';
endif;
break;
}
}
add_action('manage_product_variation_posts_custom_column', 'jigoshop_custom_variation_columns', 2);
function jigoshop_edit_product_columns($columns){
$columns = array();
$columns["cb"] = "<input type=\"checkbox\" />";
$columns["thumb"] = __("Thumb", 'jigoshop');
$columns["title"] = __("Name", 'jigoshop');
$columns["product_type"] = __("Type", 'jigoshop');
$columns["sku"] = __("ID/SKU", 'jigoshop');
$columns["product_cat"] = __("Category", 'jigoshop');
$columns["product_tags"] = __("Tags", 'jigoshop');
$columns["visibility"] = __("Visibility", 'jigoshop');
$columns["featured"] = __("Featured", 'jigoshop');
if (get_option('jigoshop_manage_stock')=='yes') :
$columns["is_in_stock"] = __("In Stock?", 'jigoshop');
$columns["inventory"] = __("Inventory", 'jigoshop');
endif;
$columns["price"] = __("Price", 'jigoshop');
return $columns;
}
add_filter('manage_edit-product_columns', 'jigoshop_edit_product_columns');
function jigoshop_custom_product_columns($column) {
global $post;
$product = &new jigoshop_product($post->ID);
switch ($column) {
case "thumb" :
if (has_post_thumbnail($post->ID)) :
echo get_the_post_thumbnail($post->ID, 'shop_tiny');
endif;
break;
case "summary" :
echo $post->post_excerpt;
break;
case "price":
echo $product->get_price_html();
break;
case "product_cat" :
echo get_the_term_list($post->ID, 'product_cat', '', ', ','');
break;
case "product_tags" :
echo get_the_term_list($post->ID, 'product_tag', '', ', ','');
break;
case "sku" :
if ( $sku = get_post_meta( $post->ID, 'SKU', true )) :
echo '#'.$post->ID.' - SKU: ' . $sku;
else :
echo '#'.$post->ID;
endif;
break;
case "featured" :
$url = wp_nonce_url( admin_url('admin-ajax.php?action=jigoshop-feature-product&product_id=' . $post->ID) );
echo '<a href="'.$url.'" title="'.__('Change','jigoshop') .'">';
if ($product->is_featured()) echo '<a href="'.$url.'"><img src="'.jigoshop::plugin_url().'/assets/images/success.gif" alt="yes" />';
else echo '<img src="'.jigoshop::plugin_url().'/assets/images/success-off.gif" alt="no" />';
echo '</a>';
break;
case "visibility" :
if ( $this_data = $product->visibility ) :
echo $this_data;
else :
echo '<span class="na">&ndash;</span>';
endif;
break;
case "is_in_stock" :
if ( !$product->is_type( 'grouped' ) && $product->is_in_stock() ) echo '<img src="'.jigoshop::plugin_url().'/assets/images/success.gif" alt="yes" />';
else echo '<span class="na">&ndash;</span>';
break;
case "inventory" :
if ( $product->managing_stock() ) :
echo $product->stock.' in stock';
else :
echo '<span class="na">&ndash;</span>';
endif;
break;
case "product_type" :
echo ucwords($product->product_type);
break;
case "id" :
echo '#'.$post->ID;
break;
}
}
add_action('manage_product_posts_custom_column', 'jigoshop_custom_product_columns', 2);
function jigoshop_edit_order_columns($columns){
$columns = array();
//$columns["cb"] = "<input type=\"checkbox\" />";
$columns["order_status"] = __("Status", 'jigoshop');
$columns["order_title"] = __("Order", 'jigoshop');
$columns["customer"] = __("Customer", 'jigoshop');
$columns["billing_address"] = __("Billing Address", 'jigoshop');
$columns["shipping_address"] = __("Shipping Address", 'jigoshop');
$columns["billing_and_shipping"] = __("Billing & Shipping", 'jigoshop');
$columns["total_cost"] = __("Order Cost", 'jigoshop');
return $columns;
}
add_filter('manage_edit-shop_order_columns', 'jigoshop_edit_order_columns');
function jigoshop_custom_order_columns($column) {
global $post;
$order = &new jigoshop_order( $post->ID );
switch ($column) {
case "order_status" :
echo sprintf( __('<mark class="%s">%s</mark>', 'jigoshop'), sanitize_title($order->status), $order->status );
break;
case "order_title" :
echo '<a href="'.admin_url('post.php?post='.$post->ID.'&action=edit').'">'.sprintf( __('Order #%s', 'jigoshop'), $post->ID ).'</a>';
echo '<time title="'.date_i18n('c', strtotime($post->post_date)).'">'.date_i18n('F j, Y, g:i a', strtotime($post->post_date)).'</time>';
break;
case "customer" :
if ($order->user_id) $user_info = get_userdata($order->user_id);
?>
<dl>
<dt><?php _e('User:', 'jigoshop'); ?></dt>
<dd><?php
if (isset($user_info) && $user_info) :
echo '<a href="user-edit.php?user_id='.$user_info->ID.'">#'.$user_info->ID.' &ndash; <strong>';
if ($user_info->first_name || $user_info->last_name) echo $user_info->first_name.' '.$user_info->last_name;
else echo $user_info->display_name;
echo '</strong></a>';
else :
_e('Guest', 'jigoshop');
endif;
?></dd>
<?php if ($order->billing_email) : ?><dt><?php _e('Billing Email:', 'jigoshop'); ?></dt>
<dd><a href="mailto:<?php echo $order->billing_email; ?>"><?php echo $order->billing_email; ?></a></dd><?php endif; ?>
<?php if ($order->billing_phone) : ?><dt><?php _e('Billing Tel:', 'jigoshop'); ?></dt>
<dd><?php echo $order->billing_phone; ?></dd><?php endif; ?>
</dl>
<?php
break;
case "billing_address" :
echo '<strong>'.$order->billing_first_name . ' ' . $order->billing_last_name;
if ($order->billing_company) echo ', '.$order->billing_company;
echo '</strong><br/>';
echo '<a target="_blank" href="http://maps.google.co.uk/maps?&q='.urlencode($order->formatted_billing_address).'&z=16">'.$order->formatted_billing_address.'</a>';
break;
case "shipping_address" :
if ($order->formatted_shipping_address) :
echo '<strong>'.$order->shipping_first_name . ' ' . $order->shipping_last_name;
if ($order->shipping_company) : echo ', '.$order->shipping_company; endif;
echo '</strong><br/>';
echo '<a target="_blank" href="http://maps.google.co.uk/maps?&q='.urlencode($order->formatted_shipping_address).'&z=16">'.$order->formatted_shipping_address.'</a>';
else :
echo '&ndash;';
endif;
break;
case "billing_and_shipping" :
?>
<dl>
<dt><?php _e('Payment:', 'jigoshop'); ?></dt>
<dd><?php echo $order->payment_method; ?></dd>
<dt><?php _e('Shipping:', 'jigoshop'); ?></dt>
<dd><?php echo $order->shipping_method; ?></dd>
</dl>
<?php
break;
case "total_cost" :
?>
<table cellpadding="0" cellspacing="0" class="cost">
<tr>
<th><?php _e('Subtotal', 'jigoshop'); ?></th>
<td><?php echo jigoshop_price($order->order_subtotal); ?></td>
</tr>
<?php if ($order->order_shipping>0) : ?><tr>
<th><?php _e('Shipping', 'jigoshop'); ?></th>
<td><?php echo jigoshop_price($order->order_shipping); ?></td>
</tr><?php endif; ?>
<?php if ($order->get_total_tax()>0) : ?><tr>
<th><?php _e('Tax', 'jigoshop'); ?></th>
<td><?php echo jigoshop_price($order->get_total_tax()); ?></td>
</tr><?php endif; ?>
<?php if ($order->order_discount>0) : ?><tr>
<th><?php _e('Discount', 'jigoshop'); ?></th>
<td><?php echo jigoshop_price($order->order_discount); ?></td>
</tr><?php endif; ?>
<tr>
<th><?php _e('Total', 'jigoshop'); ?></th>
<td><?php echo jigoshop_price($order->order_total); ?></td>
</tr>
</table>
<?php
break;
}
}
add_action('manage_shop_order_posts_custom_column', 'jigoshop_custom_order_columns', 2);
/**
* Order page filters
**/
function jigoshop_custom_order_views( $views ) {
$jigoshop_orders = &new jigoshop_orders();
$pending = (isset($_GET['shop_order_status']) && $_GET['shop_order_status']=='pending') ? 'current' : '';
$onhold = (isset($_GET['shop_order_status']) && $_GET['shop_order_status']=='on-hold') ? 'current' : '';
$processing = (isset($_GET['shop_order_status']) && $_GET['shop_order_status']=='processing') ? 'current' : '';
$completed = (isset($_GET['shop_order_status']) && $_GET['shop_order_status']=='completed') ? 'current' : '';
$cancelled = (isset($_GET['shop_order_status']) && $_GET['shop_order_status']=='cancelled') ? 'current' : '';
$refunded = (isset($_GET['shop_order_status']) && $_GET['shop_order_status']=='refunded') ? 'current' : '';
$views['pending'] = '<a class="'.$pending.'" href="?post_type=shop_order&amp;shop_order_status=pending">Pending <span class="count">('.$jigoshop_orders->pending_count.')</span></a>';
$views['onhold'] = '<a class="'.$onhold.'" href="?post_type=shop_order&amp;shop_order_status=on-hold">On-Hold <span class="count">('.$jigoshop_orders->on_hold_count.')</span></a>';
$views['processing'] = '<a class="'.$processing.'" href="?post_type=shop_order&amp;shop_order_status=processing">Processing <span class="count">('.$jigoshop_orders->processing_count.')</span></a>';
$views['completed'] = '<a class="'.$completed.'" href="?post_type=shop_order&amp;shop_order_status=completed">Completed <span class="count">('.$jigoshop_orders->completed_count.')</span></a>';
$views['cancelled'] = '<a class="'.$cancelled.'" href="?post_type=shop_order&amp;shop_order_status=cancelled">Cancelled <span class="count">('.$jigoshop_orders->cancelled_count.')</span></a>';
$views['refunded'] = '<a class="'.$refunded.'" href="?post_type=shop_order&amp;shop_order_status=refunded">Refunded <span class="count">('.$jigoshop_orders->refunded_count.')</span></a>';
if ($pending || $onhold || $processing || $completed || $cancelled || $refunded) :
$views['all'] = str_replace('current', '', $views['all']);
endif;
unset($views['publish']);
if (isset($views['trash'])) :
$trash = $views['trash'];
unset($views['draft']);
unset($views['trash']);
$views['trash'] = $trash;
endif;
return $views;
}
add_filter('views_edit-shop_order', 'jigoshop_custom_order_views');
/**
* Order page actions
**/
function jigoshop_remove_row_actions( $actions ) {
if( get_post_type() === 'shop_order' ) :
unset( $actions['view'] );
unset( $actions['inline hide-if-no-js'] );
endif;
return $actions;
}
add_filter( 'post_row_actions', 'jigoshop_remove_row_actions', 10, 1 );
/**
* Order page views
**/
function jigoshop_bulk_actions( $actions ) {
return array();
}
add_filter( 'bulk_actions-edit-shop_order', 'jigoshop_bulk_actions' );
/**
* Order messages
**/
function jigoshop_post_updated_messages( $messages ) {
if( get_post_type() === 'shop_order' ) :
$messages['post'][1] = sprintf( __('Order updated.', 'jigoshop') );
$messages['post'][4] = sprintf( __('Order updated.', 'jigoshop') );
$messages['post'][6] = sprintf( __('Order published.', 'jigoshop') );
$messages['post'][8] = sprintf( __('Order submitted.', 'jigoshop') );
$messages['post'][10] = sprintf( __('Order draft updated.', 'jigoshop') );
endif;
return $messages;
}
add_filter( 'post_updated_messages', 'jigoshop_post_updated_messages' );

View File

@ -0,0 +1,583 @@
<?php
/**
* options_settings
*
* This variable contains all the options used on the jigpshop settings page
*
* @since 1.0
* @category Admin
* @usedby jigoshop_settings(), jigoshop_default_options()
*/
global $options_settings;
$options_settings = apply_filters('jigoshop_options_settings', array(
array( 'type' => 'tab', 'tabname' => __('General', 'jigoshop') ),
array( 'name' => __('General Options', 'jigoshop'), 'type' => 'title', 'desc' => '' ),
array(
'name' => __('Demo store','jigoshop'),
'desc' => '',
'tip' => __('Enable this option to show a banner at the top of the page stating its a demo store.','jigoshop'),
'id' => 'jigoshop_demo_store',
'css' => 'min-width:100px;',
'std' => 'no',
'type' => 'select',
'options' => array(
'yes' => __('Yes', 'jigoshop'),
'no' => __('No', 'jigoshop')
)
),
array(
'name' => __('Enable SKU field','jigoshop'),
'desc' => '',
'tip' => __('Turning off the SKU field will give products an SKU of their post id.','jigoshop'),
'id' => 'jigoshop_enable_sku',
'css' => 'min-width:100px;',
'std' => 'yes',
'type' => 'select',
'options' => array(
'yes' => __('Yes', 'jigoshop'),
'no' => __('No', 'jigoshop')
)
),
array(
'name' => __('Enable weight field','jigoshop'),
'desc' => '',
'tip' => '',
'id' => 'jigoshop_enable_weight',
'css' => 'min-width:100px;',
'std' => 'yes',
'type' => 'select',
'options' => array(
'yes' => __('Yes', 'jigoshop'),
'no' => __('No', 'jigoshop')
)
),
array(
'name' => __('Weight Unit', 'jigoshop'),
'desc' => __("This controls what unit you will define weights in.", 'jigoshop'),
'tip' => '',
'id' => 'jigoshop_weight_unit',
'css' => 'min-width:200px;',
'std' => 'GBP',
'type' => 'select',
'options' => array(
'kg' => __('kg', 'jigoshop'),
'lbs' => __('lbs', 'jigoshop')
)
),
array(
'name' => __('Base Country/Region','jigoshop'),
'desc' => '',
'tip' => __('This is the base country for your business. Tax rates will be based on this country.','jigoshop'),
'id' => 'jigoshop_default_country',
'css' => '',
'std' => 'GB',
'type' => 'single_select_country'
),
array(
'name' => __('Allowed Countries','jigoshop'),
'desc' => '',
'tip' => __('These are countries that you are willing to ship to.','jigoshop'),
'id' => 'jigoshop_allowed_countries',
'css' => 'min-width:100px;',
'std' => 'all',
'type' => 'select',
'options' => array(
'all' => __('All Countries', 'jigoshop'),
'specific' => __('Specific Countries', 'jigoshop')
)
),
array(
'name' => __('Specific Countries','jigoshop'),
'desc' => '',
'tip' => '',
'id' => 'jigoshop_specific_allowed_countries',
'css' => '',
'std' => '',
'type' => 'multi_select_countries'
),
array(
'name' => __('Enable guest checkout?','jigoshop'),
'desc' => '',
'tip' => __('Without guest checkout, all users will require an account in order to checkout.','jigoshop'),
'id' => 'jigoshop_enable_guest_checkout',
'css' => 'min-width:100px;',
'std' => 'yes',
'type' => 'select',
'options' => array(
'yes' => __('Yes', 'jigoshop'),
'no' => __('No', 'jigoshop')
)
),
array(
'name' => __('Force SSL on checkout?','jigoshop'),
'desc' => '',
'tip' => __('Forcing SSL is recommended','jigoshop'),
'id' => 'jigoshop_force_ssl_checkout',
'css' => 'min-width:100px;',
'std' => 'no',
'type' => 'select',
'options' => array(
'yes' => __('Yes', 'jigoshop'),
'no' => __('No', 'jigoshop')
)
),
array(
'name' => __('ShareThis Publisher ID','jigoshop'),
'desc' => __("Enter your <a href='http://sharethis.com/account/'>ShareThis publisher ID</a> to show ShareThis on product pages.",'jigoshop'),
'tip' => __('ShareThis is a small social sharing widget for posting links on popular sites such as Twitter and Facebook.','jigoshop'),
'id' => 'jigoshop_sharethis',
'css' => 'width:300px;',
'type' => 'text',
'std' => ''
),
array(
'name' => __('Disable Jigoshop frontend.css','jigoshop'),
'desc' => '',
'tip' => __('Useful if you want to disable Jigoshop styles and theme it yourself via your theme.','jigoshop'),
'id' => 'jigoshop_disable_css',
'css' => 'min-width:100px;',
'std' => 'no',
'type' => 'select',
'options' => array(
'no' => __('No', 'jigoshop'),
'yes' => __('Yes', 'jigoshop')
)
),
array( 'type' => 'tabend'),
array( 'type' => 'tab', 'tabname' => __('Pages', 'jigoshop') ),
array( 'name' => __('Shop page configuration', 'jigoshop'), 'type' => 'title', 'desc' => '' ),
array(
'name' => __('Cart Page','jigoshop'),
'desc' => __('Your page should contain [jigoshop_cart]','jigoshop'),
'tip' => '',
'id' => 'jigoshop_cart_page_id',
'css' => 'min-width:50px;',
'type' => 'single_select_page',
'std' => ''
),
array(
'name' => __('Checkout Page','jigoshop'),
'desc' => __('Your page should contain [jigoshop_checkout]','jigoshop'),
'tip' => '',
'id' => 'jigoshop_checkout_page_id',
'css' => 'min-width:50px;',
'type' => 'single_select_page',
'std' => ''
),
array(
'name' => __('Pay Page','jigoshop'),
'desc' => __('Your page should contain [jigoshop_pay] and usually have "Checkout" as the parent.','jigoshop'),
'tip' => '',
'id' => 'jigoshop_pay_page_id',
'css' => 'min-width:50px;',
'type' => 'single_select_page',
'std' => ''
),
array(
'name' => __('Thanks Page','jigoshop'),
'desc' => __('Your page should contain [jigoshop_thankyou] and usually have "Checkout" as the parent.','jigoshop'),
'tip' => '',
'id' => 'jigoshop_thanks_page_id',
'css' => 'min-width:50px;',
'type' => 'single_select_page',
'std' => ''
),
array(
'name' => __('My Account Page','jigoshop'),
'desc' => __('Your page should contain [jigoshop_my_account]','jigoshop'),
'tip' => '',
'id' => 'jigoshop_myaccount_page_id',
'css' => 'min-width:50px;',
'type' => 'single_select_page',
'std' => ''
),
array(
'name' => __('Edit Address Page','jigoshop'),
'desc' => __('Your page should contain [jigoshop_edit_address] and usually have "My Account" as the parent.','jigoshop'),
'tip' => '',
'id' => 'jigoshop_edit_address_page_id',
'css' => 'min-width:50px;',
'type' => 'single_select_page',
'std' => ''
),
array(
'name' => __('View Order Page','jigoshop'),
'desc' => __('Your page should contain [jigoshop_view_order] and usually have "My Account" as the parent.','jigoshop'),
'tip' => '',
'id' => 'jigoshop_view_order_page_id',
'css' => 'min-width:50px;',
'type' => 'single_select_page',
'std' => ''
),
array(
'name' => __('Change Password Page','jigoshop'),
'desc' => __('Your page should contain [jigoshop_change_password] and usually have "My Account" as the parent.','jigoshop'),
'tip' => '',
'id' => 'jigoshop_change_password_page_id',
'css' => 'min-width:50px;',
'type' => 'single_select_page',
'std' => ''
),
array( 'type' => 'tabend'),
array( 'type' => 'tab', 'tabname' => __('Catalog', 'jigoshop') ),
array( 'name' => __('Catalog Options', 'jigoshop'), 'type' => 'title','desc' => '', 'id' => '' ),
array(
'name' => __('Products Base Page','jigoshop'),
'desc' => sprintf( __("IMPORTANT: You must <a target='_blank' href='%s'>re-save your permalinks</a> for this change to take effect.",'jigoshop'), 'options-permalink.php' ),
'tip' => __('This sets the base page of your shop. You should not change this value once you have launched your site otherwise you risk breaking urls of other sites pointing to yours, etc.','jigoshop'),
'id' => 'jigoshop_shop_page_id',
'css' => 'min-width:50px;',
'type' => 'single_select_page',
'std' => ''
),
array(
'name' => __('Prepend shop categories/tags with base page?','jigoshop'),
'desc' => sprintf( __("IMPORTANT: You must <a target='_blank' href='%s'>re-save your permalinks</a> for this change to take effect.",'jigoshop'), 'options-permalink.php' ),
'tip' => __('If set to yes, categories will show up as your_base_page/shop_category instead of just shop_category.', 'jigoshop'),
'id' => 'jigoshop_prepend_shop_page_to_urls',
'css' => 'min-width:100px;',
'std' => 'no',
'type' => 'select',
'options' => array(
'no' => __('No', 'jigoshop'),
'yes' => __('Yes', 'jigoshop')
)
),
array(
'name' => __('Terms page ID', 'jigoshop'),
'desc' => __('If you define a "Terms" page the customer will be asked if they accept them when checking out.', 'jigoshop'),
'tip' => '',
'id' => 'jigoshop_terms_page_id',
'css' => 'min-width:50px;',
'std' => '',
'type' => 'single_select_page',
'args' => 'show_option_none=' . __('None', 'jigoshop'),
),
array( 'name' => __('Pricing Options', 'jigoshop'), 'type' => 'title','desc' => '', 'id' => '' ),
array(
'name' => __('Currency', 'jigoshop'),
'desc' => sprintf( __("This controls what currency prices are listed at in the catalog, and which currency PayPal, and other gateways, will take payments in. See the list of supported <a target='_new' href='%s'>PayPal currencies</a>.", 'jigoshop'), 'https://www.paypal.com/cgi-bin/webscr?cmd=p/sell/mc/mc_intro-outside' ),
'tip' => '',
'id' => 'jigoshop_currency',
'css' => 'min-width:200px;',
'std' => 'GBP',
'type' => 'select',
'options' => apply_filters('jigoshop_currencies', array(
'USD' => __('US Dollars (&#36;)', 'jigoshop'),
'EUR' => __('Euros (&euro;)', 'jigoshop'),
'GBP' => __('Pounds Sterling (&pound;)', 'jigoshop'),
'AUD' => __('Australian Dollars (&#36;)', 'jigoshop'),
'BRL' => __('Brazilian Real (&#36;)', 'jigoshop'),
'CAD' => __('Canadian Dollars (&#36;)', 'jigoshop'),
'CZK' => __('Czech Koruna', 'jigoshop'),
'DKK' => __('Danish Krone', 'jigoshop'),
'HKD' => __('Hong Kong Dollar (&#36;)', 'jigoshop'),
'HUF' => __('Hungarian Forint', 'jigoshop'),
'ILS' => __('Israeli Shekel', 'jigoshop'),
'JPY' => __('Japanese Yen (&yen;)', 'jigoshop'),
'MYR' => __('Malaysian Ringgits', 'jigoshop'),
'MXN' => __('Mexican Peso (&#36;)', 'jigoshop'),
'NZD' => __('New Zealand Dollar (&#36;)', 'jigoshop'),
'NOK' => __('Norwegian Krone', 'jigoshop'),
'PHP' => __('Philippine Pesos', 'jigoshop'),
'PLN' => __('Polish Zloty', 'jigoshop'),
'SGD' => __('Singapore Dollar (&#36;)', 'jigoshop'),
'SEK' => __('Swedish Krona', 'jigoshop'),
'CHF' => __('Swiss Franc', 'jigoshop'),
'TWD' => __('Taiwan New Dollars', 'jigoshop'),
'THB' => __('Thai Baht', 'jigoshop')
)
)
),
array(
'name' => __('Currency Position', 'jigoshop'),
'desc' => __("This controls the position of the currency symbol.", 'jigoshop'),
'tip' => '',
'id' => 'jigoshop_currency_pos',
'css' => 'min-width:200px;',
'std' => 'left',
'type' => 'select',
'options' => array(
'left' => __('Left', 'jigoshop'),
'right' => __('Right', 'jigoshop'),
'left_space' => __('Left (with space)', 'jigoshop'),
'right_space' => __('Right (with space)', 'jigoshop')
)
),
array(
'name' => __('Thousand separator', 'jigoshop'),
'desc' => __('This sets the thousand separator of displayed prices.', 'jigoshop'),
'tip' => '',
'id' => 'jigoshop_price_thousand_sep',
'css' => 'width:30px;',
'std' => ',',
'type' => 'text',
),
array(
'name' => __('Decimal separator', 'jigoshop'),
'desc' => __('This sets the decimal separator of displayed prices.', 'jigoshop'),
'tip' => '',
'id' => 'jigoshop_price_decimal_sep',
'css' => 'width:30px;',
'std' => '.',
'type' => 'text',
),
array(
'name' => __('Number of decimals', 'jigoshop'),
'desc' => __('This sets the number of decimal points shown in displayed prices.', 'jigoshop'),
'tip' => '',
'id' => 'jigoshop_price_num_decimals',
'css' => 'width:30px;',
'std' => '2',
'type' => 'text',
),
array( 'type' => 'tabend'),
array( 'type' => 'tab', 'tabname' => __('Coupons', 'jigoshop') ),
array( 'name' => __('Coupon Codes', 'jigoshop'), 'type' => 'title', 'desc' => '' ),
array(
'name' => __('Coupons','jigoshop'),
'desc' => 'All fields are required.',
'tip' => 'Coupons allow you to give customers special offers and discounts. Leave product IDs blank to apply to all products/items in the cart.',
'id' => 'jigoshop_coupons',
'css' => 'min-width:50px;',
'type' => 'coupons',
'std' => ''
),
array( 'type' => 'tabend'),
array( 'type' => 'tab', 'tabname' => __('Inventory', 'jigoshop') ),
array( 'name' => __('Inventory Options', 'jigoshop'), 'type' => 'title','desc' => '', 'id' => '' ),
array(
'name' => __('Manage stock?','jigoshop'),
'desc' => __('If you are not managing stock, turn it off here to disable it in admin and on the front-end.','jigoshop'),
'tip' => __('You can manage stock on a per-item basis if you leave this option on.', 'jigoshop'),
'id' => 'jigoshop_manage_stock',
'css' => 'min-width:100px;',
'std' => 'yes',
'type' => 'select',
'options' => array(
'yes' => __('Yes', 'jigoshop'),
'no' => __('No', 'jigoshop')
)
),
array(
'name' => __('Low stock notification','jigoshop'),
'desc' => '',
'tip' => __('Set the minimum threshold for this below.', 'jigoshop'),
'id' => 'jigoshop_notify_low_stock',
'css' => 'min-width:100px;',
'std' => 'yes',
'type' => 'select',
'options' => array(
'yes' => __('Yes', 'jigoshop'),
'no' => __('No', 'jigoshop')
)
),
array(
'name' => __('Low stock threshold','jigoshop'),
'desc' => '',
'tip' => '',
'id' => 'jigoshop_notify_low_stock_amount',
'css' => 'min-width:50px;',
'type' => 'text',
'std' => '2'
),
array(
'name' => __('Out-of-stock notification','jigoshop'),
'desc' => '',
'tip' => __('Set the minimum threshold for this below.', 'jigoshop'),
'id' => 'jigoshop_notify_no_stock',
'css' => 'min-width:100px;',
'std' => 'yes',
'type' => 'select',
'options' => array(
'yes' => __('Yes', 'jigoshop'),
'no' => __('No', 'jigoshop')
)
),
array(
'name' => __('Out of stock threshold','jigoshop'),
'desc' => '',
'tip' => '',
'id' => 'jigoshop_notify_no_stock_amount',
'css' => 'min-width:50px;',
'type' => 'text',
'std' => '0'
),
array( 'type' => 'tabend'),
array( 'type' => 'tab', 'tabname' => __('Shipping', 'jigoshop') ),
array( 'name' => __('Shipping Options', 'jigoshop'), 'type' => 'title','desc' => '', 'id' => '' ),
array(
'name' => __('Calculate Shipping','jigoshop'),
'desc' => __('Only set this to no if you are not shipping items, or items have shipping costs included.','jigoshop'),
'tip' => __('If you are not calculating shipping then you can ignore all other tax options.', 'jigoshop'),
'id' => 'jigoshop_calc_shipping',
'css' => 'min-width:100px;',
'std' => 'yes',
'type' => 'select',
'options' => array(
'yes' => __('Yes', 'jigoshop'),
'no' => __('No', 'jigoshop')
)
),
array(
'name' => __('Enable shipping calculator on cart','jigoshop'),
'desc' => '',
'tip' => '',
'id' => 'jigoshop_enable_shipping_calc',
'css' => 'min-width:100px;',
'std' => 'yes',
'type' => 'select',
'options' => array(
'yes' => __('Yes', 'jigoshop'),
'no' => __('No', 'jigoshop')
)
),
array(
'name' => __('Only ship to billing address?','jigoshop'),
'desc' => '',
'tip' => '',
'id' => 'jigoshop_ship_to_billing_address_only',
'css' => 'min-width:100px;',
'std' => 'no',
'type' => 'select',
'options' => array(
'yes' => __('Yes', 'jigoshop'),
'no' => __('No', 'jigoshop')
)
),
array( 'type' => 'shipping_options'),
array( 'type' => 'tabend'),
array( 'type' => 'tab', 'tabname' => __('Tax', 'jigoshop') ),
array( 'name' => __('Tax Options', 'jigoshop'), 'type' => 'title','desc' => '', 'id' => '' ),
array(
'name' => __('Calculate Taxes','jigoshop'),
'desc' => __('Only set this to no if you are exclusively selling non-taxable items.','jigoshop'),
'tip' => __('If you are not calculating taxes then you can ignore all other tax options.', 'jigoshop'),
'id' => 'jigoshop_calc_taxes',
'css' => 'min-width:100px;',
'std' => 'yes',
'type' => 'select',
'options' => array(
'yes' => __('Yes', 'jigoshop'),
'no' => __('No', 'jigoshop')
)
),
array(
'name' => __('Catalog Prices include tax?','jigoshop'),
'desc' => '',
'tip' => __('If prices include tax then tax calculations will work backwards.','jigoshop'),
'id' => 'jigoshop_prices_include_tax',
'css' => 'min-width:100px;',
'std' => 'yes',
'type' => 'select',
'options' => array(
'yes' => __('Yes', 'jigoshop'),
'no' => __('No', 'jigoshop')
)
),
array(
'name' => __('Cart totals display...','jigoshop'),
'desc' => '',
'tip' => __('Should the subtotal be shown including or excluding tax on the frontend?','jigoshop'),
'id' => 'jigoshop_display_totals_tax',
'css' => 'min-width:100px;',
'std' => 'excluding',
'type' => 'select',
'options' => array(
'including' => __('price including tax', 'jigoshop'),
'excluding' => __('price excluding tax', 'jigoshop')
)
),
array(
'name' => __('Additional Tax classes','jigoshop'),
'desc' => __('List 1 per line. This is in addition to the default <em>Standard Rate</em>.','jigoshop'),
'tip' => __('List product and shipping tax classes here, e.g. Zero Tax, Reduced Rate.','jigoshop'),
'id' => 'jigoshop_tax_classes',
'css' => 'width:100%; height: 75px;',
'type' => 'textarea',
'std' => "Reduced Rate\nZero Rate"
),
array(
'name' => __('Tax rates','jigoshop'),
'desc' => 'All fields are required.',
'tip' => 'To avoid rounding errors, insert tax rates with 4 decimal places.',
'id' => 'jigoshop_tax_rates',
'css' => 'min-width:50px;',
'type' => 'tax_rates',
'std' => ''
),
array( 'type' => 'tabend'),
array( 'type' => 'tab', 'tabname' => __('Payment Gateways', 'jigoshop') ),
array( 'type' => 'gateway_options'),
array( 'type' => 'tabend')
) );

View File

@ -0,0 +1,516 @@
<?php
/**
* Functions for the settings page in admin.
*
* The settings page contains options for the JigoShop plugin - this file contains functions to display
* and save the list of options.
*
* @author Jigowatt
* @category Admin
* @package JigoShop
*/
/**
* Update options
*
* Updates the options on the jigoshop settings page.
*
* @since 1.0
* @usedby jigoshop_settings()
*
* @param array $options List of options to go through and save
*/
function jigoshop_update_options($options) {
if(isset($_POST['submitted']) && $_POST['submitted'] == 'yes') {
foreach ($options as $value) {
if (isset($value['id']) && $value['id']=='jigoshop_tax_rates') :
$tax_classes = array();
$tax_countries = array();
$tax_rate = array();
$tax_rates = array();
$tax_shipping = array();
if (isset($_POST['tax_class'])) $tax_classes = $_POST['tax_class'];
if (isset($_POST['tax_country'])) $tax_countries = $_POST['tax_country'];
if (isset($_POST['tax_rate'])) $tax_rate = $_POST['tax_rate'];
if (isset($_POST['tax_shipping'])) $tax_shipping = $_POST['tax_shipping'];
for ($i=0; $i<sizeof($tax_classes); $i++) :
if (isset($tax_classes[$i]) && isset($tax_countries[$i]) && isset($tax_rate[$i]) && $tax_rate[$i] && is_numeric($tax_rate[$i])) :
$country = jigowatt_clean($tax_countries[$i]);
$state = '*';
$rate = number_format(jigowatt_clean($tax_rate[$i]), 4);
$class = jigowatt_clean($tax_classes[$i]);
if (isset($tax_shipping[$i]) && $tax_shipping[$i]) $shipping = 'yes'; else $shipping = 'no';
// Get state from country input if defined
if (strstr($country, ':')) :
$cr = explode(':', $country);
$country = current($cr);
$state = end($cr);
endif;
$tax_rates[] = array(
'country' => $country,
'state' => $state,
'rate' => $rate,
'shipping' => $shipping,
'class' => $class
);
endif;
endfor;
update_option($value['id'], $tax_rates);
elseif (isset($value['id']) && $value['id']=='jigoshop_coupons') :
$coupon_code = array();
$coupon_type = array();
$coupon_amount = array();
$product_ids = array();
$coupons = array();
$individual = array();
if (isset($_POST['coupon_code'])) $coupon_code = $_POST['coupon_code'];
if (isset($_POST['coupon_type'])) $coupon_type = $_POST['coupon_type'];
if (isset($_POST['coupon_amount'])) $coupon_amount = $_POST['coupon_amount'];
if (isset($_POST['product_ids'])) $product_ids = $_POST['product_ids'];
if (isset($_POST['individual'])) $individual = $_POST['individual'];
for ($i=0; $i<sizeof($coupon_code); $i++) :
if ( isset($coupon_code[$i]) && isset($coupon_type[$i]) && isset($coupon_amount[$i]) ) :
$code = jigowatt_clean($coupon_code[$i]);
$type = jigowatt_clean($coupon_type[$i]);
$amount = jigowatt_clean($coupon_amount[$i]);
if (isset($product_ids[$i]) && $product_ids[$i]) $products = array_map('trim', explode(',', $product_ids[$i])); else $products = array();
if (isset($individual[$i]) && $individual[$i]) $individual_use = 'yes'; else $individual_use = 'no';
if ($code && $type && $amount) :
$coupons[$code] = array(
'code' => $code,
'amount' => $amount,
'type' => $type,
'products' => $products,
'individual_use' => $individual_use
);
endif;
endif;
endfor;
update_option($value['id'], $coupons);
elseif (isset($value['type']) && $value['type']=='multi_select_countries') :
// Get countries array
if (isset($_POST[$value['id']])) $selected_countries = $_POST[$value['id']]; else $selected_countries = array();
update_option($value['id'], $selected_countries);
/* price separators get a special treatment as they should allow a spaces (don't trim) */
elseif ( isset($value['id']) && ( $value['id'] == 'jigoshop_price_thousand_sep' || $value['id'] == 'jigoshop_price_decimal_sep' ) ):
if( isset( $_POST[ $value['id'] ] ) ) {
update_option($value['id'], $_POST[$value['id']] );
} else {
@delete_option($value['id']);
}
else :
if(isset($value['id']) && isset($_POST[$value['id']])) {
update_option($value['id'], jigowatt_clean($_POST[$value['id']]));
} else {
@delete_option($value['id']);
}
endif;
}
do_action('jigoshop_update_options');
echo '<div id="message" class="updated fade"><p><strong>'.__('Your settings have been saved.','jigoshop').'</strong></p></div>';
}
}
/**
* Admin fields
*
* Loops though the jigoshop options array and outputs each field.
*
* @since 1.0
* @usedby jigoshop_settings()
*
* @param array $options List of options to go through and save
*/
function jigoshop_admin_fields($options) {
?>
<div id="tabs-wrap">
<p class="submit"><input name="save" type="submit" value="<?php _e('Save changes','jigoshop') ?>" /></p>
<?php
$counter = 1;
echo '<ul class="tabs">';
foreach ($options as $value) {
if ( 'tab' == $value['type'] ) :
echo '<li><a href="#'.$value['type'].$counter.'">'.$value['tabname'].'</a></li>'. "\n";
$counter = $counter + 1;
endif;
}
echo '</ul>';
$counter = 1;
foreach ($options as $value) :
switch($value['type']) :
case 'string':
?>
<tr>
<td class="titledesc"><?php echo $value['name']; ?></td>
<td class="forminp"><?php echo $value['desc']; ?></td>
</tr>
<?php
break;
case 'tab':
echo '<div id="'.$value['type'].$counter.'" class="panel">';
echo '<table class="widefat fixed" style="width:850px; margin-bottom:20px;">'. "\n\n";
break;
case 'title':
?><thead><tr><th scope="col" width="200px"><?php echo $value['name'] ?></th><th scope="col" class="desc"><?php if (isset($value['desc'])) echo $value['desc'] ?>&nbsp;</th></tr></thead><?php
break;
case 'text':
?><tr>
<td class="titledesc"><?php if ($value['tip']) { ?><a href="#" tip="<?php echo $value['tip'] ?>" class="tips" tabindex="99"></a><?php } ?><?php echo $value['name'] ?>:</td>
<td class="forminp"><input name="<?php echo $value['id'] ?>" id="<?php echo $value['id'] ?>" type="<?php echo $value['type'] ?>" style="<?php echo $value['css'] ?>" value="<?php if ( get_option( $value['id']) !== false && get_option( $value['id']) !== null ) echo stripslashes(get_option($value['id'])); else echo $value['std'] ?>" /><br /><small><?php echo $value['desc'] ?></small></td>
</tr><?php
break;
case 'select':
?><tr>
<td class="titledesc"><?php if ($value['tip']) { ?><a href="#" tip="<?php echo $value['tip'] ?>" class="tips" tabindex="99"></a><?php } ?><?php echo $value['name'] ?>:</td>
<td class="forminp"><select name="<?php echo $value['id'] ?>" id="<?php echo $value['id'] ?>" style="<?php echo $value['css'] ?>">
<?php
foreach ($value['options'] as $key => $val) {
?>
<option value="<?php echo $key ?>" <?php if (get_option($value['id']) == $key) { ?> selected="selected" <?php } ?>><?php echo ucfirst($val) ?></option>
<?php
}
?>
</select><br /><small><?php echo $value['desc'] ?></small>
</td>
</tr><?php
break;
case 'textarea':
?><tr>
<td class="titledesc"><?php if ($value['tip']) { ?><a href="#" tip="<?php echo $value['tip'] ?>" class="tips" tabindex="99"></a><?php } ?><?php echo $value['name'] ?>:</td>
<td class="forminp">
<textarea <?php if ( isset($value['args']) ) echo $value['args'] . ' '; ?>name="<?php echo $value['id'] ?>" id="<?php echo $value['id'] ?>" style="<?php echo $value['css'] ?>"><?php if (get_option($value['id'])) echo stripslashes(get_option($value['id'])); else echo $value['std']; ?></textarea>
<br /><small><?php echo $value['desc'] ?></small>
</td>
</tr><?php
break;
case 'tabend':
echo '</table></div>';
$counter = $counter + 1;
break;
case 'single_select_page' :
$page_setting = (int) get_option($value['id']);
$args = array( 'name' => $value['id'],
'id' => $value['id']. '" style="width: 200px;',
'sort_column' => 'menu_order',
'sort_order' => 'ASC',
'selected' => $page_setting);
if( isset($value['args']) ) $args = wp_parse_args($value['args'], $args);
?><tr class="single_select_page">
<td class="titledesc"><?php if ($value['tip']) { ?><a href="#" tip="<?php echo $value['tip'] ?>" class="tips" tabindex="99"></a><?php } ?><?php echo $value['name'] ?>:</td>
<td class="forminp">
<?php wp_dropdown_pages($args); ?>
<br /><small><?php echo $value['desc'] ?></small>
</td>
</tr><?php
break;
case 'single_select_country' :
$countries = jigoshop_countries::$countries;
$country_setting = (string) get_option($value['id']);
if (strstr($country_setting, ':')) :
$country = current(explode(':', $country_setting));
$state = end(explode(':', $country_setting));
else :
$country = $country_setting;
$state = '*';
endif;
?><tr class="multi_select_countries">
<td class="titledesc"><?php if ($value['tip']) { ?><a href="#" tip="<?php echo $value['tip'] ?>" class="tips" tabindex="99"></a><?php } ?><?php echo $value['name'] ?>:</td>
<td class="forminp"><select name="<?php echo $value['id'] ?>" title="Country" style="width: 150px;">
<?php echo jigoshop_countries::country_dropdown_options($country, $state); ?>
</select>
</td>
</tr><?php
break;
case 'multi_select_countries' :
$countries = jigoshop_countries::$countries;
asort($countries);
$selections = (array) get_option($value['id']);
?><tr class="multi_select_countries">
<td class="titledesc"><?php if ($value['tip']) { ?><a href="#" tip="<?php echo $value['tip'] ?>" class="tips" tabindex="99"></a><?php } ?><?php echo $value['name'] ?>:</td>
<td class="forminp">
<div class="multi_select_countries"><ul><?php
if ($countries) foreach ($countries as $key=>$val) :
echo '<li><label><input type="checkbox" name="'. $value['id'] .'[]" value="'. $key .'" ';
if (in_array($key, $selections)) echo 'checked="checked"';
echo ' />'. $val .'</label></li>';
endforeach;
?></ul></div>
</td>
</tr><?php
break;
case 'coupons' :
$coupons = new jigoshop_coupons();
$coupon_codes = $coupons->get_coupons();
?><tr>
<td class="titledesc"><?php if ($value['tip']) { ?><a href="#" tip="<?php echo $value['tip'] ?>" class="tips" tabindex="99"></a><?php } ?><?php echo $value['name'] ?>:</td>
<td class="forminp" id="coupon_codes">
<table class="coupon_rows" cellspacing="0">
<thead>
<tr>
<th><?php _e('Coupon Code', 'jigoshop'); ?></th>
<th><?php _e('Coupon Type', 'jigoshop'); ?></th>
<th><?php _e('Coupon Amount', 'jigoshop'); ?></th>
<th><?php _e('Product ids', 'jigoshop'); ?></th>
<th><?php _e('Individual use', 'jigoshop'); ?></th>
<th><?php _e('Delete', 'jigoshop'); ?></th>
</tr>
</thead>
<tbody>
<?php
$i = -1;
if ($coupon_codes && is_array($coupon_codes) && sizeof($coupon_codes)>0) foreach( $coupon_codes as $coupon ) : $i++;
echo '<tr class="coupon_row"><td><input type="text" value="'.$coupon['code'].'" name="coupon_code['.$i.']" title="'.__('Coupon Code', 'jigoshop').'" placeholder="'.__('Coupon Code', 'jigoshop').'" class="text" /></td><td><select name="coupon_type['.$i.']" title="Coupon Type">';
$discount_types = array(
'fixed_cart' => __('Cart Discount', 'jigoshop'),
'percent' => __('Cart % Discount', 'jigoshop'),
'fixed_product' => __('Product Discount', 'jigoshop')
);
foreach ($discount_types as $type => $label) :
$selected = ($coupon['type']==$type) ? 'selected="selected"' : '';
echo '<option value="'.$type.'" '.$selected.'>'.$label.'</option>';
endforeach;
echo '</select></td><td><input type="text" value="'.$coupon['amount'].'" name="coupon_amount['.$i.']" title="'.__('Coupon Amount', 'jigoshop').'" placeholder="'.__('Coupon Amount', 'jigoshop').'" class="text" /></td><td><input type="text" value="'.implode(', ', $coupon['products']).'" name="product_ids['.$i.']" placeholder="'.__('1, 2, 3', 'jigoshop').'" class="text" /></td><td><label><input type="checkbox" name="individual['.$i.']" ';
if (isset($coupon['individual_use']) && $coupon['individual_use']=='yes') echo 'checked="checked"';
echo ' /> '.__('Individual use only', 'jigoshop').'</label></td><td><a href="#" class="remove button">&times;</a></td></tr>';
endforeach;
?>
</tbody>
</table>
<p><a href="#" class="add button"><?php _e('+ Add Coupon', 'jigoshop'); ?></a></p>
</td>
</tr>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(function() {
jQuery('#coupon_codes a.add').live('click', function(){
var size = jQuery('#coupon_codes table.coupon_rows tbody .coupon_row').size();
// Make sure tbody exists
var tbody_size = jQuery('#coupon_codes table.coupon_rows tbody').size();
if (tbody_size==0) jQuery('#coupon_codes table.coupon_rows').append('<tbody></tbody>');
// Add the row
jQuery('<tr class="coupon_row">\
<td><input type="text" value="" name="coupon_code[' + size + ']" title="<?php _e('Coupon Code', 'jigoshop'); ?>" placeholder="<?php _e('Coupon Code', 'jigoshop'); ?>" class="text" /></td>\
<td><select name="coupon_type[' + size + ']" title="Coupon Type">\
<option value="percent"><?php _e('% Discount', 'jigoshop'); ?></option>\
<option value="fixed_product"><?php _e('Product Discount', 'jigoshop');?></option>\
<option value="fixed_cart"><?php _e('Cart Discount', 'jigoshop'); ?></option>\
</select></td>\
<td><input type="text" value="" name="coupon_amount[' + size + ']" title="<?php _e('Coupon Amount', 'jigoshop'); ?>" placeholder="<?php _e('Coupon Amount', 'jigoshop'); ?>" class="text" /></td>\
<td><input type="text" value="" name="product_ids[' + size + ']" placeholder="<?php _e('1, 2, 3', 'jigoshop'); ?>" class="text" /></td>\
<td><label><input type="checkbox" name="individual[' + size + ']" /> <?php _e('Individual use only', 'jigoshop'); ?></label></td>\
<td><a href="#" class="remove button">&times;</a></td></tr>').appendTo('#coupon_codes table.coupon_rows tbody');
return false;
});
jQuery('#coupon_codes a.remove').live('click', function(){
var answer = confirm("<?php _e('Delete this coupon?', 'jigoshop'); ?>")
if (answer) {
jQuery('input', jQuery(this).parent().parent()).val('');
jQuery(this).parent().parent().hide();
}
return false;
});
});
/* ]]> */
</script>
<?php
break;
case 'tax_rates' :
$_tax = new jigoshop_tax();
$tax_classes = $_tax->get_tax_classes();
$tax_rates = get_option('jigoshop_tax_rates');
?><tr>
<td class="titledesc"><?php if ($value['tip']) { ?><a href="#" tip="<?php echo $value['tip'] ?>" class="tips" tabindex="99"></a><?php } ?><?php echo $value['name'] ?>:</td>
<td class="forminp" id="tax_rates">
<div class="taxrows">
<?php
$i = -1;
if ($tax_rates && is_array($tax_rates) && sizeof($tax_rates)>0) foreach( $tax_rates as $rate ) : $i++;
echo '<p class="taxrow"><select name="tax_class['.$i.']" title="Tax Class"><option value="">'.__('Standard Rate', 'jigoshop').'</option>';
if ($tax_classes) foreach ($tax_classes as $class) :
echo '<option value="'.sanitize_title($class).'"';
if ($rate['class']==sanitize_title($class)) echo 'selected="selected"';
echo '>'.$class.'</option>';
endforeach;
echo '</select><select name="tax_country['.$i.']" title="Country">';
jigoshop_countries::country_dropdown_options($rate['country'], $rate['state']);
echo '</select><input type="text" class="text" value="'.$rate['rate'].'" name="tax_rate['.$i.']" title="'.__('Rate', 'jigoshop').'" placeholder="'.__('Rate', 'jigoshop').'" maxlength="8" />% <label><input type="checkbox" name="tax_shipping['.$i.']" ';
if (isset($rate['shipping']) && $rate['shipping']=='yes') echo 'checked="checked"';
echo ' /> '.__('Apply to shipping', 'jigoshop').'</label><a href="#" class="remove button">&times;</a></p>';
endforeach;
?>
</div>
<p><a href="#" class="add button"><?php _e('+ Add Tax Rule', 'jigoshop'); ?></a></p>
</td>
</tr>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(function() {
jQuery('#tax_rates a.add').live('click', function(){
var size = jQuery('.taxrows .taxrow').size();
// Add the row
jQuery('<p class="taxrow"> \
<select name="tax_class[' + size + ']" title="Tax Class"> \
<option value=""><?php _e('Standard Rate', 'jigoshop'); ?></option><?php
$tax_classes = $_tax->get_tax_classes();
if ($tax_classes) foreach ($tax_classes as $class) :
echo '<option value="'.sanitize_title($class).'">'.$class.'</option>';
endforeach;
?></select><select name="tax_country[' + size + ']" title="Country"><?php
jigoshop_countries::country_dropdown_options('','',true);
?></select><input type="text" class="text" name="tax_rate[' + size + ']" title="<?php _e('Rate', 'jigoshop'); ?>" placeholder="<?php _e('Rate', 'jigoshop'); ?>" maxlength="8" />%\
<label><input type="checkbox" name="tax_shipping[' + size + ']" /> <?php _e('Apply to shipping', 'jigoshop'); ?></label>\
<a href="#" class="remove button">&times;</a>\
</p>').appendTo('#tax_rates div.taxrows');
return false;
});
jQuery('#tax_rates a.remove').live('click', function(){
var answer = confirm("<?php _e('Delete this rule?', 'jigoshop'); ?>");
if (answer) {
jQuery('input', jQuery(this).parent()).val('');
jQuery(this).parent().hide();
}
return false;
});
});
/* ]]> */
</script>
<?php
break;
case "shipping_options" :
foreach (jigoshop_shipping::$shipping_methods as $method) :
$method->admin_options();
endforeach;
break;
case "gateway_options" :
foreach (jigoshop_payment_gateways::payment_gateways() as $gateway) :
$gateway->admin_options();
endforeach;
break;
endswitch;
endforeach;
?>
<p class="submit"><input name="save" type="submit" value="<?php _e('Save changes','jigoshop') ?>" /></p>
</div>
<script type="text/javascript">
jQuery(function() {
// Tabs
jQuery('ul.tabs').show();
jQuery('ul.tabs li:first').addClass('active');
jQuery('div.panel:not(div.panel:first)').hide();
jQuery('ul.tabs a').click(function(){
jQuery('ul.tabs li').removeClass('active');
jQuery(this).parent().addClass('active');
jQuery('div.panel').hide();
jQuery( jQuery(this).attr('href') ).show();
jQuery.cookie('jigoshop_settings_tab_index', jQuery(this).parent().index('ul.tabs li'))
return false;
});
<?php if (isset($_COOKIE['jigoshop_settings_tab_index']) && $_COOKIE['jigoshop_settings_tab_index'] > 0) : ?>
jQuery('ul.tabs li:eq(<?php echo $_COOKIE['jigoshop_settings_tab_index']; ?>) a').click();
<?php endif; ?>
// Countries
jQuery('select#jigoshop_allowed_countries').change(function(){
if (jQuery(this).val()=="specific") {
jQuery(this).parent().parent().next('tr.multi_select_countries').show();
} else {
jQuery(this).parent().parent().next('tr.multi_select_countries').hide();
}
}).change();
});
</script>
<?php
}
/**
* Settings page
*
* Handles the display of the settings page in admin.
*
* @since 1.0
* @usedby jigoshop_admin_menu2()
*/
function jigoshop_settings() {
global $options_settings;
jigoshop_update_options($options_settings);
?>
<script type="text/javascript" src="<?php echo jigoshop::plugin_url(); ?>/assets/js/easyTooltip.js"></script>
<div class="wrap jigoshop">
<div class="icon32 icon32-jigoshop-settings" id="icon-jigoshop"><br/></div>
<h2><?php _e('General Settings','jigoshop'); ?></h2>
<form method="post" id="mainform" action="">
<?php jigoshop_admin_fields($options_settings); ?>
<input name="submitted" type="hidden" value="yes" />
</form>
</div>
<?php
}

307
admin/jigoshop-admin.php Normal file
View File

@ -0,0 +1,307 @@
<?php
/**
* JigoShop Admin
*
* Main admin file which loads all settings panels and sets up the menus.
*
* @author Jigowatt
* @category Admin
* @package JigoShop
*/
require_once ( 'jigoshop-install.php' );
require_once ( 'jigoshop-admin-dashboard.php' );
require_once ( 'jigoshop-write-panels.php' );
require_once ( 'jigoshop-admin-settings.php' );
require_once ( 'jigoshop-admin-attributes.php' );
require_once ( 'jigoshop-admin-post-types.php' );
function jigoshop_admin_init () {
require_once ( 'jigoshop-admin-settings-options.php' );
}
add_action('admin_init', 'jigoshop_admin_init');
/**
* Admin Menus
*
* Sets up the admin menus in wordpress.
*
* @since 1.0
*/
function jigoshop_admin_menu() {
global $menu;
$menu[] = array( '', 'read', 'separator-jigoshop', '', 'wp-menu-separator' );
add_menu_page(__('Jigoshop'), __('Jigoshop'), 'manage_options', 'jigoshop' , 'jigoshop_dashboard', jigoshop::plugin_url() . '/assets/images/icons/menu_icons.png', 56);
add_submenu_page('jigoshop', __('Dashboard', 'jigoshop'), __('Dashboard', 'jigoshop'), 'manage_options', 'jigoshop', 'jigoshop_dashboard');
add_submenu_page('jigoshop', __('General Settings', 'jigoshop'), __('Settings', 'jigoshop') , 'manage_options', 'settings', 'jigoshop_settings');
add_submenu_page('jigoshop', __('System Info','jigoshop'), __('System Info','jigoshop'), 'manage_options', 'sysinfo', 'jigoshop_system_info');
add_submenu_page('edit.php?post_type=product', __('Attributes','jigoshop'), __('Attributes','jigoshop'), 'manage_options', 'attributes', 'jigoshop_attributes');
}
function jigoshop_admin_menu_order( $menu_order ) {
// Initialize our custom order array
$jigoshop_menu_order = array();
// Get the index of our custom separator
$jigoshop_separator = array_search( 'separator-jigoshop', $menu_order );
// Loop through menu order and do some rearranging
foreach ( $menu_order as $index => $item ) :
if ( ( ( 'jigoshop' ) == $item ) ) :
$jigoshop_menu_order[] = 'separator-jigoshop';
unset( $menu_order[$jigoshop_separator] );
endif;
if ( !in_array( $item, array( 'separator-jigoshop' ) ) ) :
$jigoshop_menu_order[] = $item;
endif;
endforeach;
// Return order
return $jigoshop_menu_order;
}
function jigoshop_admin_custom_menu_order() {
if ( !current_user_can( 'manage_options' ) ) return false;
return true;
}
add_action('admin_menu', 'jigoshop_admin_menu');
add_action('menu_order', 'jigoshop_admin_menu_order');
add_action('custom_menu_order', 'jigoshop_admin_custom_menu_order');
/**
* Admin Head
*
* Outputs some styles in the admin <head> to show icons on the jigoshop admin pages
*
* @since 1.0
*/
function jigoshop_admin_head() {
?>
<style type="text/css">
<?php if ( isset($_GET['taxonomy']) && $_GET['taxonomy']=='product_cat' ) : ?>
.icon32-posts-product { background-position: -243px -5px !important; }
<?php elseif ( isset($_GET['taxonomy']) && $_GET['taxonomy']=='product_tag' ) : ?>
.icon32-posts-product { background-position: -301px -5px !important; }
<?php endif; ?>
</style>
<?php
}
add_action('admin_head', 'jigoshop_admin_head');
/**
* System info
*
* Shows the system info panel which contains version data and debug info
*
* @since 1.0
* @usedby jigoshop_settings()
*/
function jigoshop_system_info() {
?>
<div class="wrap jigoshop">
<div class="icon32 icon32-jigoshop-debug" id="icon-jigoshop"><br/></div>
<h2><?php _e('System Information','jigoshop') ?></h2>
<div id="tabs-wrap">
<ul class="tabs">
<li><a href="#versions"><?php _e('Environment', 'jigoshop'); ?></a></li>
<li><a href="#debugging"><?php _e('Debugging', 'jigoshop'); ?></a></li>
</ul>
<div id="versions" class="panel">
<table class="widefat fixed" style="width:850px;">
<thead>
<tr>
<th scope="col" width="200px"><?php _e('Versions','jigoshop')?></th>
<th scope="col">&nbsp;</th>
</tr>
</thead>
<tbody>
<tr>
<td class="titledesc"><?php _e('Jigoshop Version','jigoshop')?></td>
<td class="forminp"><?php echo jigoshop::get_var('version'); ?></td>
</tr>
<tr>
<td class="titledesc"><?php _e('WordPress Version','jigoshop')?></td>
<td class="forminp"><?php if (is_multisite()) echo 'WPMU'; else echo 'WP'; ?> <?php echo bloginfo('version'); ?></td>
</tr>
</tbody>
<thead>
<tr>
<th scope="col" width="200px"><?php _e('Server','jigoshop')?></th>
<th scope="col">&nbsp;</th>
</tr>
</thead>
<tbody>
<tr>
<td class="titledesc"><?php _e('PHP Version','jigoshop')?></td>
<td class="forminp"><?php if(function_exists('phpversion')) echo phpversion(); ?></td>
</tr>
<tr>
<td class="titledesc"><?php _e('Server Software','jigoshop')?></td>
<td class="forminp"><?php echo $_SERVER['SERVER_SOFTWARE']; ?></td>
</tr>
</tbody>
</table>
</div>
<div id="debugging" class="panel">
<table class="widefat fixed" style="width:850px;">
<tbody>
<tr>
<th scope="col" width="200px"><?php _e('Debug Information','jigoshop')?></th>
<th scope="col">&nbsp;</th>
</tr>
<tr>
<td class="titledesc"><?php _e('UPLOAD_MAX_FILESIZE','jigoshop')?></td>
<td class="forminp"><?php
if(function_exists('phpversion')) echo (jigoshop_let_to_num(ini_get('upload_max_filesize'))/(1024*1024))."MB";
?></td>
</tr>
<tr>
<td class="titledesc"><?php _e('POST_MAX_SIZE','jigoshop')?></td>
<td class="forminp"><?php
if(function_exists('phpversion')) echo (jigoshop_let_to_num(ini_get('post_max_size'))/(1024*1024))."MB";
?></td>
</tr>
<tr>
<td class="titledesc"><?php _e('WordPress Memory Limit','jigoshop')?></td>
<td class="forminp"><?php
echo (jigoshop_let_to_num(WP_MEMORY_LIMIT)/(1024*1024))."MB";
?></td>
</tr>
<tr>
<td class="titledesc"><?php _e('WP_DEBUG','jigoshop')?></td>
<td class="forminp"><?php if (WP_DEBUG) echo __('On', 'jigoshop'); else __('Off', 'jigoshop'); ?></td>
</tr>
<tr>
<td class="titledesc"><?php _e('DISPLAY_ERRORS','jigoshop')?></td>
<td class="forminp"><?php if(function_exists('phpversion')) echo ini_get('display_errors'); ?></td>
</tr>
<tr>
<td class="titledesc"><?php _e('FSOCKOPEN','jigoshop')?></td>
<td class="forminp"><?php if(function_exists('fsockopen')) echo '<span style="color:green">' . __('Your server supports fsockopen.', 'jigoshop'). '</span>'; else echo '<span style="color:red">' . __('Your server does not support fsockopen.', 'jigoshop'). '</span>'; ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script type="text/javascript">
jQuery(function() {
// Tabs
jQuery('ul.tabs').show();
jQuery('ul.tabs li:first').addClass('active');
jQuery('div.panel:not(div.panel:first)').hide();
jQuery('ul.tabs a').click(function(){
jQuery('ul.tabs li').removeClass('active');
jQuery(this).parent().addClass('active');
jQuery('div.panel').hide();
jQuery( jQuery(this).attr('href') ).show();
return false;
});
});
</script>
<?php
}
function jigoshop_feature_product () {
if( !is_admin() ) die;
if( !current_user_can('edit_posts') ) wp_die( __('You do not have sufficient permissions to access this page.') );
if( !check_admin_referer()) wp_die( __('You have taken too long. Please go back and retry.', 'jigoshop') );
$post_id = isset($_GET['product_id']) && (int)$_GET['product_id'] ? (int)$_GET['product_id'] : '';
if(!$post_id) die;
$post = get_post($post_id);
if(!$post) die;
if($post->post_type !== 'product') die;
$product = new jigoshop_product($post->ID);
if ($product->is_featured()) update_post_meta($post->ID, 'featured', 'no');
else update_post_meta($post->ID, 'featured', 'yes');
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
wp_safe_redirect( $sendback );
}
add_action('wp_ajax_jigoshop-feature-product', 'jigoshop_feature_product');
/**
* Returns proper post_type
*/
function jigoshop_get_current_post_type() {
global $post, $typenow, $current_screen;
if( $current_screen && @$current_screen->post_type ) return $current_screen->post_type;
if( $typenow ) return $typenow;
if( !empty($_REQUEST['post_type']) ) return sanitize_key( $_REQUEST['post_type'] );
if ( !empty($post) && !empty($post->post_type) ) return $post->post_type;
if( ! empty($_REQUEST['post']) && (int)$_REQUEST['post'] ) {
$p = get_post( $_REQUEST['post'] );
return $p ? $p->post_type : '';
}
return '';
}
/**
* Categories ordering
*/
/**
* Load needed scripts to order categories
*/
function jigoshop_categories_scripts () {
if( !isset($_GET['taxonomy']) || $_GET['taxonomy'] !== 'product_cat') return;
wp_register_script('jigoshop-categories-ordering', jigoshop::plugin_url() . '/assets/js/categories-ordering.js', array('jquery-ui-sortable'));
wp_print_scripts('jigoshop-categories-ordering');
}
add_action('admin_footer-edit-tags.php', 'jigoshop_categories_scripts');
/**
* Ajax request handling for categories ordering
*/
function jigoshop_categories_ordering () {
global $wpdb;
$id = (int)$_POST['id'];
$next_id = isset($_POST['nextid']) && (int) $_POST['nextid'] ? (int) $_POST['nextid'] : null;
if( ! $id || ! $term = get_term_by('id', $id, 'product_cat') ) die(0);
jigoshop_order_categories ( $term, $next_id);
$children = get_terms('product_cat', "child_of=$id&menu_order=ASC&hide_empty=0");
if( $term && sizeof($children) ) {
echo 'children';
die;
}
}
add_action('wp_ajax_jigoshop-categories-ordering', 'jigoshop_categories_ordering');

376
admin/jigoshop-install.php Normal file
View File

@ -0,0 +1,376 @@
<?php
/**
* JigoShop Install
*
* Plugin install script which adds default pages, taxonomies, and database tables
*
* @author Jigowatt
* @category Admin
* @package JigoShop
*/
/**
* Install jigoshop
*
* Calls each function to install bits, and clears the cron jobs and rewrite rules
*
* @since 1.0
*/
function install_jigoshop() {
// Get options and define post types before we start
require_once ( 'jigoshop-admin-settings-options.php' );
jigoshop_post_type();
// Do install
jigoshop_default_options();
jigoshop_create_pages();
jigoshop_tables_install();
jigoshop_post_type();
jigoshop_default_taxonomies();
// Clear cron
wp_clear_scheduled_hook('jigoshop_update_sale_prices_schedule_check');
update_option('jigoshop_update_sale_prices', 'no');
// Flush Rules
global $wp_rewrite;
$wp_rewrite->flush_rules();
// Update version
update_option( "jigoshop_db_version", JIGOSHOP_VERSION );
}
/**
* Default options
*
* Sets up the default options used on the settings page
*
* @since 1.0
*/
function jigoshop_default_options() {
global $options_settings;
foreach ($options_settings as $value) {
if (isset($value['std'])) add_option($value['id'], $value['std']);
}
add_option('jigoshop_shop_slug', 'shop');
}
/**
* Create pages
*
* Creates pages that the plugin relies on, storing page id's in variables.
*
* @since 1.0
*/
function jigoshop_create_pages() {
global $wpdb;
$slug = esc_sql( _x('shop', 'page_slug', 'jigoshop') );
$page_found = $wpdb->get_var("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = '$slug' LIMIT 1");
if(!$page_found) {
$page_data = array(
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => 1,
'post_name' => $slug,
'post_title' => __('Shop', 'jigoshop'),
'post_content' => '',
'comment_status' => 'closed'
);
$page_id = wp_insert_post($page_data);
update_option('jigoshop_shop_page_id', $page_id);
} else {
update_option('jigoshop_shop_page_id', $page_found);
}
$slug = esc_sql( _x('cart', 'page_slug', 'jigoshop') );
$page_found = $wpdb->get_var("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = '$slug' LIMIT 1");
if(!$page_found) {
$page_data = array(
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => 1,
'post_name' => $slug,
'post_title' => __('Cart', 'jigoshop'),
'post_content' => '[jigoshop_cart]',
'comment_status' => 'closed'
);
$page_id = wp_insert_post($page_data);
update_option('jigoshop_cart_page_id', $page_id);
} else {
update_option('jigoshop_cart_page_id', $page_found);
}
$slug = esc_sql( _x('checkout', 'page_slug', 'jigoshop') );
$page_found = $wpdb->get_var("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = '$slug' LIMIT 1");
if(!$page_found) {
$page_data = array(
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => 1,
'post_name' => $slug,
'post_title' => __('Checkout', 'jigoshop'),
'post_content' => '[jigoshop_checkout]',
'comment_status' => 'closed'
);
$page_id = wp_insert_post($page_data);
update_option('jigoshop_checkout_page_id', $page_id);
} else {
update_option('jigoshop_checkout_page_id', $page_found);
}
$slug = esc_sql( _x('order-tracking', 'page_slug', 'jigoshop') );
$page_found = $wpdb->get_var("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = '$slug' LIMIT 1");
if(!$page_found) {
$page_data = array(
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => 1,
'post_name' => $slug,
'post_title' => __('Track your order', 'jigoshop'),
'post_content' => '[jigoshop_order_tracking]',
'comment_status' => 'closed'
);
$page_id = wp_insert_post($page_data);
}
$slug = esc_sql( _x('my-account', 'page_slug', 'jigoshop') );
$page_found = $wpdb->get_var("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = '$slug' LIMIT 1");
if(!$page_found) {
$page_data = array(
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => 1,
'post_name' => $slug,
'post_title' => __('My Account', 'jigoshop'),
'post_content' => '[jigoshop_my_account]',
'comment_status' => 'closed'
);
$page_id = wp_insert_post($page_data);
update_option('jigoshop_myaccount_page_id', $page_id);
} else {
update_option('jigoshop_myaccount_page_id', $page_found);
}
$slug = esc_sql( _x('edit-address', 'page_slug', 'jigoshop') );
$page_found = $wpdb->get_var("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = '$slug' LIMIT 1");
if(!$page_found) {
$page_data = array(
'post_status' => 'publish',
'post_type' => 'page',
'post_parent' => get_option('jigoshop_myaccount_page_id'),
'post_author' => 1,
'post_name' => $slug,
'post_title' => __('Edit My Address', 'jigoshop'),
'post_content' => '[jigoshop_edit_address]',
'comment_status' => 'closed'
);
$page_id = wp_insert_post($page_data);
update_option('jigoshop_edit_address_page_id', $page_id);
} else {
update_option('jigoshop_edit_address_page_id', $page_found);
}
$slug = esc_sql( _x('view-order', 'page_slug', 'jigoshop') );
$page_found = $wpdb->get_var("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = '$slug' LIMIT 1");
if(!$page_found) {
$page_data = array(
'post_status' => 'publish',
'post_type' => 'page',
'post_parent' => get_option('jigoshop_myaccount_page_id'),
'post_author' => 1,
'post_name' => $slug,
'post_title' => __('View Order', 'jigoshop'),
'post_content' => '[jigoshop_view_order]',
'comment_status' => 'closed'
);
$page_id = wp_insert_post($page_data);
update_option('jigoshop_view_order_page_id', $page_id);
} else {
update_option('jigoshop_view_order_page_id', $page_found);
}
$slug = esc_sql( _x('change-password', 'page_slug', 'jigoshop') );
$page_found = $wpdb->get_var("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = '$slug' LIMIT 1");
if(!$page_found) {
$page_data = array(
'post_status' => 'publish',
'post_type' => 'page',
'post_parent' => get_option('jigoshop_myaccount_page_id'),
'post_author' => 1,
'post_name' => $slug,
'post_title' => __('Change Password', 'jigoshop'),
'post_content' => '[jigoshop_change_password]',
'comment_status' => 'closed'
);
$page_id = wp_insert_post($page_data);
update_option('jigoshop_change_password_page_id', $page_id);
} else {
update_option('jigoshop_change_password_page_id', $page_found);
}
$slug = esc_sql( _x('pay', 'page_slug', 'jigoshop') );
$page_found = $wpdb->get_var("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = '$slug' LIMIT 1");
if(!$page_found) {
$page_data = array(
'post_status' => 'publish',
'post_type' => 'page',
'post_parent' => get_option('jigoshop_checkout_page_id'),
'post_author' => 1,
'post_name' => $slug,
'post_title' => __('Checkout &rarr; Pay', 'jigoshop'),
'post_content' => '[jigoshop_pay]',
'comment_status' => 'closed'
);
$page_id = wp_insert_post($page_data);
update_option('jigoshop_pay_page_id', $page_id);
} else {
update_option('jigoshop_pay_page_id', $page_found);
}
// Thank you Page
$slug = esc_sql( _x('thanks', 'page_slug', 'jigoshop') );
$page_found = $wpdb->get_var("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = '$slug' LIMIT 1");
if(!$page_found) {
$page_data = array(
'post_status' => 'publish',
'post_type' => 'page',
'post_parent' => get_option('jigoshop_checkout_page_id'),
'post_author' => 1,
'post_name' => $slug,
'post_title' => __('Thank you', 'jigoshop'),
'post_content' => '[jigoshop_thankyou]',
'comment_status' => 'closed'
);
$page_id = wp_insert_post($page_data);
update_option('jigoshop_thanks_page_id', $page_id);
} else {
update_option('jigoshop_thanks_page_id', $page_found);
}
}
/**
* Table Install
*
* Sets up the database tables which the plugin needs to function.
*
* @since 1.0
*/
function jigoshop_tables_install() {
global $wpdb;
//$wpdb->show_errors();
$collate = '';
if($wpdb->supports_collation()) {
if(!empty($wpdb->charset)) $collate = "DEFAULT CHARACTER SET $wpdb->charset";
if(!empty($wpdb->collate)) $collate .= " COLLATE $wpdb->collate";
}
$sql = "CREATE TABLE IF NOT EXISTS ". $wpdb->prefix . "jigoshop_attribute_taxonomies" ." (
`attribute_id` mediumint(9) NOT NULL AUTO_INCREMENT,
`attribute_name` varchar(200) NOT NULL,
`attribute_type` varchar(200) NOT NULL,
PRIMARY KEY id (`attribute_id`)) $collate;";
$wpdb->query($sql);
$sql = "CREATE TABLE IF NOT EXISTS ". $wpdb->prefix . "jigoshop_downloadable_product_permissions" ." (
`product_id` mediumint(9) NOT NULL,
`user_email` varchar(200) NOT NULL,
`user_id` mediumint(9) NULL,
`order_key` varchar(200) NOT NULL,
`downloads_remaining` varchar(9) NULL,
PRIMARY KEY id (`product_id`, `order_key`)) $collate;";
$wpdb->query($sql);
$sql = "CREATE TABLE IF NOT EXISTS ". $wpdb->prefix . "jigoshop_termmeta" ." (
`meta_id` bigint(20) NOT NULL AUTO_INCREMENT,
`jigoshop_term_id` bigint(20) NOT NULL,
`meta_key` varchar(255) NULL,
`meta_value` longtext NULL,
PRIMARY KEY id (`meta_id`)) $collate;";
$wpdb->query($sql);
}
/**
* Default taxonomies
*
* Adds the default terms for taxonomies - product types and order statuses. Modify at your own risk.
*
* @since 1.0
*/
function jigoshop_default_taxonomies() {
$product_types = array(
'simple',
'grouped',
'configurable',
'downloadable',
'virtual'
);
foreach($product_types as $type) {
if (!$type_id = get_term_by( 'slug', sanitize_title($type), 'product_type')) {
wp_insert_term($type, 'product_type');
}
}
$order_status = array(
'pending',
'on-hold',
'processing',
'completed',
'refunded',
'cancelled'
);
foreach($order_status as $status) {
if (!$status_id = get_term_by( 'slug', sanitize_title($status), 'shop_order_status')) {
wp_insert_term($status, 'shop_order_status');
}
}
}

View File

@ -0,0 +1,192 @@
<?php
/**
* JigoShop Write Panels
*
* Sets up the write panels used by products and orders (custom post types)
*
* @author Jigowatt
* @category Admin Write Panels
* @package JigoShop
*/
include('write-panels/product-data.php');
include('write-panels/product-data-save.php');
include('write-panels/product-type.php');
include('write-panels/order-data.php');
include('write-panels/order-data-save.php');
/**
* Init the meta boxes
*
* Inits the write panels for both products and orders. Also removes unused default write panels.
*
* @since 1.0
*/
add_action( 'add_meta_boxes', 'jigoshop_meta_boxes' );
function jigoshop_meta_boxes() {
add_meta_box( 'jigoshop-product-data', __('Product Data', 'jigoshop'), 'jigoshop_product_data_box', 'product', 'normal', 'high' );
add_meta_box( 'jigoshop-product-type-options', __('Product Type Options', 'jigoshop'), 'jigoshop_product_type_options_box', 'product', 'normal', 'high' );
add_meta_box( 'jigoshop-order-data', __('Order Data', 'jigoshop'), 'jigoshop_order_data_meta_box', 'shop_order', 'normal', 'high' );
add_meta_box( 'jigoshop-order-items', __('Order Items <small>&ndash; Note: if you edit quantities or remove items from the order you will need to manually change the item\'s stock levels.</small>', 'jigoshop'), 'jigoshop_order_items_meta_box', 'shop_order', 'normal', 'high');
add_meta_box( 'jigoshop-order-totals', __('Order Totals', 'jigoshop'), 'jigoshop_order_totals_meta_box', 'shop_order', 'side', 'default');
add_meta_box( 'jigoshop-order-actions', __('Order Actions', 'jigoshop'), 'jigoshop_order_actions_meta_box', 'shop_order', 'side', 'default');
remove_meta_box( 'commentstatusdiv', 'shop_order' , 'normal' );
remove_meta_box( 'slugdiv', 'shop_order' , 'normal' );
}
/**
* Save meta boxes
*
* Runs when a post is saved and does an action which the write panel save scripts can hook into.
*
* @since 1.0
*/
add_action( 'save_post', 'jigoshop_meta_boxes_save', 1, 2 );
function jigoshop_meta_boxes_save( $post_id, $post ) {
global $wpdb;
if ( !$_POST ) return $post_id;
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;
if ( !isset($_POST['jigoshop_meta_nonce']) || (isset($_POST['jigoshop_meta_nonce']) && !wp_verify_nonce( $_POST['jigoshop_meta_nonce'], 'jigoshop_save_data' ))) return $post_id;
if ( !current_user_can( 'edit_post', $post_id )) return $post_id;
if ( $post->post_type != 'product' && $post->post_type != 'shop_order' ) return $post_id;
do_action( 'jigoshop_process_'.$post->post_type.'_meta', $post_id, $post );
}
/**
* Product data
*
* Forces certain product data based on the product's type, e.g. grouped products cannot have a parent.
*
* @since 1.0
*/
add_filter('wp_insert_post_data', 'jigoshop_product_data');
function jigoshop_product_data( $data ) {
global $post;
if ($data['post_type']=='product' && isset($_POST['product-type'])) {
$product_type = stripslashes( $_POST['product-type'] );
switch($product_type) :
case "grouped" :
case "variable" :
$data['post_parent'] = 0;
break;
endswitch;
}
return $data;
}
/**
* Order data
*
* Forces the order posts to have a title in a certain format (containing the date)
*
* @since 1.0
*/
add_filter('wp_insert_post_data', 'jigoshop_order_data');
function jigoshop_order_data( $data ) {
global $post;
if ($data['post_type']=='shop_order' && isset($data['post_date'])) {
$order_title = 'Order';
if ($data['post_date']) $order_title.= ' &ndash; '.date('F j, Y @ h:i A', strtotime($data['post_date']));
$data['post_title'] = $order_title;
}
return $data;
}
/**
* Save errors
*
* Stores error messages in a variable so they can be displayed on the edit post screen after saving.
*
* @since 1.0
*/
add_action( 'admin_notices', 'jigoshop_meta_boxes_save_errors' );
function jigoshop_meta_boxes_save_errors() {
$jigoshop_errors = maybe_unserialize(get_option('jigoshop_errors'));
if ($jigoshop_errors && sizeof($jigoshop_errors)>0) :
echo '<div id="jigoshop_errors" class="error fade">';
foreach ($jigoshop_errors as $error) :
echo '<p>'.$error.'</p>';
endforeach;
echo '</div>';
update_option('jigoshop_errors', '');
endif;
}
/**
* Enqueue scripts
*
* Enqueue JavaScript used by the meta panels.
*
* @since 1.0
*/
function jigoshop_write_panel_scripts() {
$post_type = jigoshop_get_current_post_type();
if( $post_type !== 'product' && $post_type !== 'shop_order' ) return;
wp_register_script('jigoshop-date', jigoshop::plugin_url() . '/assets/js/date.js');
wp_register_script('jigoshop-datepicker', jigoshop::plugin_url() . '/assets/js/datepicker.js', array('jquery', 'jigoshop-date'));
wp_enqueue_script('jigoshop-datepicker');
wp_register_script('jigoshop-writepanel', jigoshop::plugin_url() . '/assets/js/write-panels.js', array('jquery'));
wp_enqueue_script('jigoshop-writepanel');
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
wp_enqueue_style('thickbox');
$params = array(
'remove_item_notice' => __("Remove this item? If you have previously reduced this item's stock, or this order was submitted by a customer, will need to manually restore the item's stock.", 'jigoshop'),
'cart_total' => __("Calc totals based on order items, discount amount, and shipping?", 'jigoshop'),
'copy_billing' => __("Copy billing information to shipping information? This will remove any currently entered shipping information.", 'jigoshop'),
'prices_include_tax' => get_option('jigoshop_prices_include_tax'),
'ID' => __('ID', 'jigoshop'),
'item_name' => __('Item Name', 'jigoshop'),
'quantity' => __('Quantity e.g. 2', 'jigoshop'),
'cost_unit' => __('Cost per unit e.g. 2.99', 'jigoshop'),
'tax_rate' => __('Tax Rate e.g. 20.0000', 'jigoshop'),
'meta_name' => __('Meta Name', 'jigoshop'),
'meta_value' => __('Meta Value', 'jigoshop'),
'plugin_url' => jigoshop::plugin_url(),
'ajax_url' => admin_url('admin-ajax.php'),
'add_order_item_nonce' => wp_create_nonce("add-order-item")
);
wp_localize_script( 'jigoshop-writepanel', 'params', $params );
}
add_action('admin_print_scripts-post.php', 'jigoshop_write_panel_scripts');
add_action('admin_print_scripts-post-new.php', 'jigoshop_write_panel_scripts');
/**
* Meta scripts
*
* Outputs JavaScript used by the meta panels.
*
* @since 1.0
*/
function jigoshop_meta_scripts() {
?>
<script type="text/javascript">
jQuery(function(){
<?php do_action('product_write_panel_js'); ?>
});
</script>
<?php
}

View File

@ -0,0 +1,178 @@
<?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

@ -0,0 +1,438 @@
<?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

@ -0,0 +1,211 @@
<?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

@ -0,0 +1,364 @@
<?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

@ -0,0 +1,32 @@
<?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');
}

View File

@ -0,0 +1,79 @@
<?php
/**
* Downloadable Product Type
*
* Functions specific to downloadable products (for the write panels)
*
* @author Jigowatt
* @category Admin Write Panel Product Types
* @package JigoShop
*/
/**
* Product Options
*
* Product Options for the downloadable product type
*
* @since 1.0
*/
function downloadable_product_type_options() {
global $post;
?>
<div id="downloadable_product_options" class="panel jigoshop_options_panel">
<?php
// File URL
$file_path = get_post_meta($post->ID, 'file_path', true);
$field = array( 'id' => 'file_path', 'label' => __('File path', 'jigoshop') );
echo '<p class="form-field">
<label for="'.$field['id'].'">'.$field['label'].':</label>
<span style="float:left">'.ABSPATH.'</span><input type="text" class="short" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$file_path.'" placeholder="'.__('path to file on your server', 'jigoshop').'" /></p>';
// Download Limit
$download_limit = get_post_meta($post->ID, 'download_limit', true);
$field = array( 'id' => 'download_limit', 'label' => __('Download Limit', 'jigoshop') );
echo '<p class="form-field">
<label for="'.$field['id'].'">'.$field['label'].':</label>
<input type="text" class="short" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$download_limit.'" /> <span class="description">' . __('Leave blank for unlimited re-downloads.', 'jigoshop') . '</span></p>';
?>
</div>
<?php
}
add_action('jigoshop_product_type_options_box', 'downloadable_product_type_options');
/**
* Product Type selector
*
* Adds this product type to the product type selector in the product options meta box
*
* @since 1.0
*
* @param string $product_type Passed the current product type so that if it keeps its selected state
*/
function downloadable_product_type_selector( $product_type ) {
echo '<option value="downloadable" '; if ($product_type=='downloadable') echo 'selected="selected"'; echo '>'.__('Downloadable','jigoshop').'</option>';
}
add_action('product_type_selector', 'downloadable_product_type_selector');
/**
* Process meta
*
* Processes this product types options when a post is saved
*
* @since 1.0
*
* @param array $data The $data being saved
* @param int $post_id The post id of the post being saved
*/
function filter_product_meta_downloadable( $data, $post_id ) {
if (isset($_POST['file_path']) && $_POST['file_path']) update_post_meta( $post_id, 'file_path', $_POST['file_path'] );
if (isset($_POST['download_limit'])) update_post_meta( $post_id, 'download_limit', $_POST['download_limit'] );
return $data;
}
add_filter('filter_product_meta_downloadable', 'filter_product_meta_downloadable', 1, 2);

View File

@ -0,0 +1,44 @@
<?php
/**
* Grouped Product Type
*
* Functions specific to grouped products (for the write panels)
*
* @author Jigowatt
* @category Admin Write Panel Product Types
* @package JigoShop
*/
/**
* Product Options
*
* Product Options for the grouped product type
*
* @since 1.0
*/
function grouped_product_type_options() {
?>
<div id="grouped_product_options">
<?php
_e('Grouped products have no specific options &mdash; you can add simple products to this grouped product by editing them and setting their <code>parent product</code> option.', 'jigoshop');
?>
</div>
<?php
}
add_action('jigoshop_product_type_options_box', 'grouped_product_type_options');
/**
* Product Type selector
*
* Adds this product type to the product type selector in the product options meta box
*
* @since 1.0
*
* @param string $product_type Passed the current product type so that if it keeps its selected state
*/
function grouped_product_type_selector( $product_type ) {
echo '<option value="grouped" '; if ($product_type=='grouped') echo 'selected="selected"'; echo '>'.__('Grouped','jigoshop').'</option>';
}
add_action('product_type_selector', 'grouped_product_type_selector');

View File

@ -0,0 +1,411 @@
<?php
/**
* Variable Product Type
*
* Functions specific to variable products (for the write panels)
*
* @author Jigowatt
* @category Admin Write Panel Product Types
* @package JigoShop
*/
/**
* Product Options
*
* Product Options for the variable product type
*
* @since 1.0
*/
function variable_product_type_options() {
global $post;
$attributes = maybe_unserialize( get_post_meta($post->ID, 'product_attributes', true) );
if (!isset($attributes)) $attributes = array();
?>
<div id="variable_product_options" class="panel">
<div class="jigoshop_configurations">
<?php
$args = array(
'post_type' => 'product_variation',
'post_status' => array('private', 'publish'),
'numberposts' => -1,
'orderby' => 'id',
'order' => 'asc',
'post_parent' => $post->ID
);
$variations = get_posts($args);
$loop = 0;
if ($variations) foreach ($variations as $variation) :
$variation_data = get_post_custom( $variation->ID );
$image = '';
if (isset($variation_data['_thumbnail_id'][0])) :
$image = wp_get_attachment_url( $variation_data['_thumbnail_id'][0] );
endif;
if (!$image) $image = jigoshop::plugin_url().'/assets/images/placeholder.png';
?>
<div class="jigoshop_configuration">
<p>
<button type="button" class="remove_variation button" rel="<?php echo $variation->ID; ?>"><?php _e('Remove', 'jigoshop'); ?></button>
<strong>#<?php echo $variation->ID; ?> &mdash; <?php _e('Variation:', 'jigoshop'); ?></strong>
<?php
foreach ($attributes as $attribute) :
if ( $attribute['variation']!=='yes' ) continue;
$options = $attribute['value'];
$value = get_post_meta( $variation->ID, 'tax_' . sanitize_title($attribute['name']), true );
if (!is_array($options)) $options = explode(',', $options);
echo '<select name="tax_' . sanitize_title($attribute['name']).'['.$loop.']"><option value="">'.__('Any ', 'jigoshop').$attribute['name'].'&hellip;</option>';
foreach($options as $option) :
$option = trim($option);
echo '<option ';
selected($value, $option);
echo ' value="'.$option.'">'.ucfirst($option).'</option>';
endforeach;
echo '</select>';
endforeach;
?>
<input type="hidden" name="variable_post_id[<?php echo $loop; ?>]" value="<?php echo $variation->ID; ?>" />
</p>
<table cellpadding="0" cellspacing="0" class="jigoshop_variable_attributes">
<tbody>
<tr>
<td class="upload_image"><img src="<?php echo $image ?>" width="60px" height="60px" /><input type="hidden" name="upload_image_id[<?php echo $loop; ?>]" class="upload_image_id" value="<?php if (isset($variation_data['_thumbnail_id'][0])) echo $variation_data['_thumbnail_id'][0]; ?>" /><input type="button" rel="<?php echo $variation->ID; ?>" class="upload_image_button button" value="<?php _e('Product Image', 'jigoshop'); ?>" /></td>
<td><label><?php _e('SKU:', 'jigoshop'); ?></label><input type="text" size="5" name="variable_sku[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['SKU'][0])) echo $variation_data['SKU'][0]; ?>" /></td>
<td><label><?php _e('Weight', 'jigoshop').' ('.get_option('jigoshop_weight_unit').'):'; ?></label><input type="text" size="5" name="variable_weight[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['weight'][0])) echo $variation_data['weight'][0]; ?>" /></td>
<td><label><?php _e('Stock Qty:', 'jigoshop'); ?></label><input type="text" size="5" name="variable_stock[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['stock'][0])) echo $variation_data['stock'][0]; ?>" /></td>
<td><label><?php _e('Price:', 'jigoshop'); ?></label><input type="text" size="5" name="variable_price[<?php echo $loop; ?>]" placeholder="<?php _e('e.g. 29.99', 'jigoshop'); ?>" value="<?php if (isset($variation_data['price'][0])) echo $variation_data['price'][0]; ?>" /></td>
<td><label><?php _e('Sale Price:', 'jigoshop'); ?></label><input type="text" size="5" name="variable_sale_price[<?php echo $loop; ?>]" placeholder="<?php _e('e.g. 29.99', 'jigoshop'); ?>" value="<?php if (isset($variation_data['sale_price'][0])) echo $variation_data['sale_price'][0]; ?>" /></td>
<td><label><?php _e('Enabled', 'jigoshop'); ?></label><input type="checkbox" class="checkbox" name="variable_enabled[<?php echo $loop; ?>]" <?php checked($variation->post_status, 'publish'); ?> /></td>
</tr>
</tbody>
</table>
</div>
<?php $loop++; endforeach; ?>
</div>
<p class="description"><?php _e('Add (optional) pricing/inventory for product variations. You must save your product attributes in the "Product Data" panel to make them available for selection.', 'jigoshop'); ?></p>
<button type="button" class="button button-primary add_configuration"><?php _e('Add Configuration', 'jigoshop'); ?></button>
<div class="clear"></div>
</div>
<?php
}
add_action('jigoshop_product_type_options_box', 'variable_product_type_options');
/**
* Product Type Javascript
*
* Javascript for the variable product type
*
* @since 1.0
*/
function variable_product_write_panel_js() {
global $post;
$attributes = maybe_unserialize( get_post_meta($post->ID, 'product_attributes', true) );
if (!isset($attributes)) $attributes = array();
?>
jQuery(function(){
jQuery('button.add_configuration').live('click', function(){
jQuery('.jigoshop_configurations').block({ message: null, overlayCSS: { background: '#fff url(<?php echo jigoshop::plugin_url(); ?>/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
var data = {
action: 'jigoshop_add_variation',
post_id: <?php echo $post->ID; ?>,
security: '<?php echo wp_create_nonce("add-variation"); ?>'
};
jQuery.post('<?php echo admin_url('admin-ajax.php'); ?>', data, function(response) {
var variation_id = parseInt(response);
var loop = jQuery('.jigoshop_configuration').size();
jQuery('.jigoshop_configurations').append('<div class="jigoshop_configuration">\
<p>\
<button type="button" class="remove_variation button"><?php _e('Remove', 'jigoshop'); ?></button>\
<strong><?php _e('Variation:', 'jigoshop'); ?></strong>\
<?php
if ($attributes) foreach ($attributes as $attribute) :
if ( $attribute['variation']!=='yes' ) continue;
$options = $attribute['value'];
if (!is_array($options)) $options = explode(',', $options);
echo '<select name="tax_' . sanitize_title($attribute['name']).'[\' + loop + \']"><option value="">'.__('Any ', 'jigoshop').$attribute['name'].'&hellip;</option>';
foreach($options as $option) :
echo '<option value="'.trim($option).'">'.ucfirst(trim($option)).'</option>';
endforeach;
echo '</select>';
endforeach;
?><input type="hidden" name="variable_post_id[' + loop + ']" value="' + variation_id + '" /></p>\
<table cellpadding="0" cellspacing="0" class="jigoshop_variable_attributes">\
<tbody>\
<tr>\
<td class="upload_image"><img src="<?php echo jigoshop::plugin_url().'/assets/images/placeholder.png' ?>" width="60px" height="60px" /><input type="hidden" name="upload_image_id[' + loop + ']" class="upload_image_id" /><input type="button" class="upload_image_button button" rel="" value="<?php _e('Product Image', 'jigoshop'); ?>" /></td>\
<td><label><?php _e('SKU:', 'jigoshop'); ?></label><input type="text" size="5" name="variable_sku[' + loop + ']" /></td>\
<td><label><?php _e('Weight', 'jigoshop').' ('.get_option('jigoshop_weight_unit').'):'; ?></label><input type="text" size="5" name="variable_weight[' + loop + ']" /></td>\
<td><label><?php _e('Stock Qty:', 'jigoshop'); ?></label><input type="text" size="5" name="variable_stock[' + loop + ']" /></td>\
<td><label><?php _e('Price:', 'jigoshop'); ?></label><input type="text" size="5" name="variable_price[' + loop + ']" placeholder="<?php _e('e.g. 29.99', 'jigoshop'); ?>" /></td>\
<td><label><?php _e('Sale Price:', 'jigoshop'); ?></label><input type="text" size="5" name="variable_sale_price[' + loop + ']" placeholder="<?php _e('e.g. 29.99', 'jigoshop'); ?>" /></td>\
<td><label><?php _e('Enabled', 'jigoshop'); ?></label><input type="checkbox" class="checkbox" name="variable_enabled[' + loop + ']" checked="checked" /></td>\
</tr>\
</tbody>\
</table>\
</div>');
jQuery('.jigoshop_configurations').unblock();
});
return false;
});
jQuery('button.remove_variation').live('click', function(){
var answer = confirm('<?php _e('Are you sure you want to remove this variation?', 'jigoshop'); ?>');
if (answer){
var el = jQuery(this).parent().parent();
var variation = jQuery(this).attr('rel');
if (variation>0) {
jQuery(el).block({ message: null, overlayCSS: { background: '#fff url(<?php echo jigoshop::plugin_url(); ?>/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
var data = {
action: 'jigoshop_remove_variation',
variation_id: variation,
security: '<?php echo wp_create_nonce("delete-variation"); ?>'
};
jQuery.post('<?php echo admin_url('admin-ajax.php'); ?>', data, function(response) {
// Success
jQuery(el).fadeOut('300', function(){
jQuery(el).remove();
});
});
} else {
jQuery(el).fadeOut('300', function(){
jQuery(el).remove();
});
}
}
return false;
});
var current_field_wrapper;
window.send_to_editor_default = window.send_to_editor;
jQuery('.upload_image_button').live('click', function(){
var post_id = jQuery(this).attr('rel');
var parent = jQuery(this).parent();
current_field_wrapper = parent;
window.send_to_editor = window.send_to_cproduct;
formfield = jQuery('.upload_image_id', parent).attr('name');
tb_show('', 'media-upload.php?post_id=' + post_id + '&amp;type=image&amp;TB_iframe=true');
return false;
});
window.send_to_cproduct = function(html) {
imgurl = jQuery('img', html).attr('src');
imgclass = jQuery('img', html).attr('class');
imgid = parseInt(imgclass.replace(/\D/g, ''), 10);
jQuery('.upload_image_id', current_field_wrapper).val(imgid);
jQuery('img', current_field_wrapper).attr('src', imgurl);
tb_remove();
window.send_to_editor = window.send_to_editor_default;
}
});
<?php
}
add_action('product_write_panel_js', 'variable_product_write_panel_js');
/**
* Delete variation via ajax function
*
* @since 1.0
*/
add_action('wp_ajax_jigoshop_remove_variation', 'jigoshop_remove_variation');
function jigoshop_remove_variation() {
check_ajax_referer( 'delete-variation', 'security' );
$variation_id = intval( $_POST['variation_id'] );
wp_delete_post( $variation_id );
die();
}
/**
* Add variation via ajax function
*
* @since 1.0
*/
add_action('wp_ajax_jigoshop_add_variation', 'jigoshop_add_variation');
function jigoshop_add_variation() {
check_ajax_referer( 'add-variation', 'security' );
$post_id = intval( $_POST['post_id'] );
$variation = array(
'post_title' => 'Product #' . $post_id . ' Variation',
'post_content' => '',
'post_status' => 'publish',
'post_author' => get_current_user_id(),
'post_parent' => $post_id,
'post_type' => 'product_variation'
);
$variation_id = wp_insert_post( $variation );
echo $variation_id;
die();
}
/**
* Product Type selector
*
* Adds this product type to the product type selector in the product options meta box
*
* @since 1.0
*
* @param string $product_type Passed the current product type so that if it keeps its selected state
*/
function variable_product_type_selector( $product_type ) {
echo '<option value="variable" '; if ($product_type=='variable') echo 'selected="selected"'; echo '>'.__('Variable','jigoshop').'</option>';
}
add_action('product_type_selector', 'variable_product_type_selector');
/**
* Process meta
*
* Processes this product types options when a post is saved
*
* @since 1.0
*
* @param array $data The $data being saved
* @param int $post_id The post id of the post being saved
*/
function process_product_meta_variable( $data, $post_id ) {
if (isset($_POST['variable_sku'])) :
$variable_post_id = $_POST['variable_post_id'];
$variable_sku = $_POST['variable_sku'];
$variable_weight = $_POST['variable_weight'];
$variable_stock = $_POST['variable_stock'];
$variable_price = $_POST['variable_price'];
$variable_sale_price= $_POST['variable_sale_price'];
$upload_image_id = $_POST['upload_image_id'];
if (isset($_POST['variable_enabled'])) $variable_enabled = $_POST['variable_enabled'];
$attributes = maybe_unserialize( get_post_meta($post_id, 'product_attributes', true) );
if (!isset($attributes)) $attributes = array();
for ($i=0; $i<sizeof($variable_sku); $i++) :
$variation_id = (int) $variable_post_id[$i];
// Enabled or disabled
if (isset($variable_enabled[$i])) $post_status = 'publish'; else $post_status = 'private';
// Generate a useful post title
$title = array();
foreach ($attributes as $attribute) :
if ( $attribute['variation']=='yes' ) :
$value = trim($_POST[ 'tax_' . sanitize_title($attribute['name']) ][$i]);
if ($value) $title[] = ucfirst($attribute['name']).': '.$value;
endif;
endforeach;
$sku_string = '#'.$variation_id;
if ($variable_sku[$i]) $sku_string .= ' SKU: ' . $variable_sku[$i];
// Update or Add post
if (!$variation_id) :
$variation = array(
'post_title' => '#' . $post_id . ' Variation ('.$sku_string.') - ' . implode(', ', $title),
'post_content' => '',
'post_status' => $post_status,
'post_author' => get_current_user_id(),
'post_parent' => $post_id,
'post_type' => 'product_variation'
);
$variation_id = wp_insert_post( $variation );
else :
global $wpdb;
$wpdb->update( $wpdb->posts, array( 'post_status' => $post_status, 'post_title' => '#' . $post_id . ' Variation ('.$sku_string.') - ' . implode(', ', $title) ), array( 'ID' => $variation_id ) );
endif;
// Update post meta
update_post_meta( $variation_id, 'SKU', $variable_sku[$i] );
update_post_meta( $variation_id, 'price', $variable_price[$i] );
update_post_meta( $variation_id, 'sale_price', $variable_sale_price[$i] );
update_post_meta( $variation_id, 'weight', $variable_weight[$i] );
update_post_meta( $variation_id, 'stock', $variable_stock[$i] );
update_post_meta( $variation_id, '_thumbnail_id', $upload_image_id[$i] );
// Update taxonomies
foreach ($attributes as $attribute) :
if ( $attribute['variation']=='yes' ) :
$value = trim($_POST[ 'tax_' . sanitize_title($attribute['name']) ][$i]);
update_post_meta( $variation_id, 'tax_' . sanitize_title($attribute['name']), $value );
endif;
endforeach;
endfor;
endif;
}
add_action('process_product_meta_variable', 'process_product_meta_variable', 1, 2);

View File

@ -0,0 +1,44 @@
<?php
/**
* Virtual Product Type
*
* Functions specific to virtual products (for the write panels)
*
* @author Jigowatt
* @category Admin Write Panel Product Types
* @package JigoShop
*/
/**
* Product Options
*
* Product Options for the virtual product type
*
* @since 1.0
*/
function virtual_product_type_options() {
?>
<div id="virtual_product_options">
<?php
_e('Virtual products have no specific options.', 'jigoshop');
?>
</div>
<?php
}
add_action('jigoshop_product_type_options_box', 'virtual_product_type_options');
/**
* Product Type selector
*
* Adds this product type to the product type selector in the product options meta box
*
* @since 1.0
*
* @param string $product_type Passed the current product type so that if it keeps its selected state
*/
function virtual_product_type_selector( $product_type ) {
echo '<option value="virtual" '; if ($product_type=='virtual') echo 'selected="selected"'; echo '>'.__('Virtual','jigoshop').'</option>';
}
add_action('product_type_selector', 'virtual_product_type_selector');

903
assets/css/admin.css Normal file
View File

@ -0,0 +1,903 @@
#toplevel_page_jigoshop .wp-menu-image {
background: url(../images/icons/menu_icons.png) no-repeat 0px -32px !important;
}
#toplevel_page_jigoshop:hover .wp-menu-image, #toplevel_page_jigoshop.wp-has-current-submenu .wp-menu-image {
background: url(../images/icons/menu_icons.png) no-repeat 0px 0px !important;
}
#toplevel_page_jigoshop .wp-menu-image img {
display: none;
}
#menu-posts-product .wp-menu-image {
background: url(../images/icons/menu_icons.png) no-repeat -35px -32px !important;
}
#menu-posts-product:hover .wp-menu-image, #menu-posts-product.wp-has-current-submenu .wp-menu-image {
background: url(../images/icons/menu_icons.png) no-repeat -35px 0px !important;
}
#menu-posts-shoporder .wp-menu-image {
background: url(../images/icons/menu_icons.png) no-repeat -70px -32px !important;
}
#menu-posts-shoporder:hover .wp-menu-image, #menu-posts-shoporder.wp-has-current-submenu .wp-menu-image {
background: url(../images/icons/menu_icons.png) no-repeat -70px 0px !important;
}
#icon-jigoshop,
.jigoshop_icon,
.icon32-posts-product,
.icon32-posts-shoporder {
background-image: url(../images/icons/jigoshop-icons.png) !important;
background-position: -11px -5px;
}
.icon32-posts-product {
background-position: -185px -5px !important;
}
.icon32-posts-product {
background-position: -69px -5px !important;
}
.icon32-posts-shoporder {
background-position: -127px -5px !important;
}
.icon32-attributes {
background-position: -185px -5px !important;
}
.icon32-jigoshop-settings {
background-position: -359px -5px !important;
}
.icon32-jigoshop-debug {
background-position: -417px -5px !important;
}
/* Orders */
.order_actions {
color: #999;
font-size: 11px;
}
.order_actions li {
border-top: 1px solid #fff;
border-bottom: 1px solid #ddd;
padding: 6px;
margin: 0;
line-height: 1.6em;
}
#jigoshop-order-items .inside {
margin: 0;
padding: 0;
background: #fefefe;
}
#jigoshop-order-items .buttons {
float: left;
padding-left: 6px;
vertical-align: top;
}
#jigoshop-order-items .buttons .item_id {
width: 300px;
vertical-align: top;
}
#jigoshop-order-items .buttons button {
margin: 2px 0 0 0;
}
#jigoshop-order-items .buttons-alt {
float: right;
padding-right: 6px;
}
#jigoshop-order-items h3 small {
color: #999;
}
dl.totals {
margin: 6px 6px 0;
float: left;
}
dl.totals dt {
float: left;
width: 100%;
font-size: 1.2em;
font-weight: bold;
line-height: 2em;
}
dl.totals dd {
line-height: 2em;
font-size: 1.2em;
float: left;
width: 100%;
}
dl.totals dd input {
width: 100%;
vertical-align: middle;
float: left;
font-size: 1em;
margin: 0 !important;
}
dl.totals dd input.first {
width: 49%;
float: left;
}
dl.totals dd input.last {
width: 49%;
float: right;
}
.jigoshop_order_items_wrapper {
margin: 0;
}
.jigoshop_order_items_wrapper table.jigoshop_order_items {
width: 100%;
background: #fff;
}
.jigoshop_order_items_wrapper table.jigoshop_order_items thead th {
background: #ECECEC;
padding: 8px 10px;
font-size: 11px;
text-align: left;
}
.jigoshop_order_items_wrapper table.jigoshop_order_items td {
padding: 8px 10px;
text-align: left;
vertical-align: middle;
border-bottom: 1px dotted #ececec;
}
.jigoshop_order_items_wrapper table.jigoshop_order_items td input, .jigoshop_order_items_wrapper table.jigoshop_order_items td textarea {
width: 100%;
}
.jigoshop_order_items_wrapper table.jigoshop_order_items td select {
width: 50%;
}
.jigoshop_order_items_wrapper table.jigoshop_order_items td input, .jigoshop_order_items_wrapper table.jigoshop_order_items td textarea {
font-size: 14px;
padding: 4px;
color: #555;
}
.jigoshop_order_items_wrapper table.jigoshop_order_items .name {
min-width: 100px;
}
.jigoshop_order_items_wrapper table.jigoshop_order_items .center,
.jigoshop_order_items_wrapper table.jigoshop_order_items .variation-id,
.jigoshop_order_items_wrapper table.jigoshop_order_items .product-id,
.jigoshop_order_items_wrapper table.jigoshop_order_items .product-sku {
text-align: center;
}
.jigoshop_order_items_wrapper table.jigoshop_order_items table.meta tr td {
padding: 1px 4px 1px 0;
border: 0;
}
.jigoshop-order-panel {
overflow: hidden;
zoom: 1;
}
.jigoshop-order-panel .panel {
padding: 0 9px;
}
.jigoshop-order-panel .column {
width: 47%;
}
.jigoshop-order-panel .first {
float: left;
}
.jigoshop-order-panel .last {
float: right;
}
.jigoshop-order-panel .panel p {
overflow: hidden;
zoom: 1;
margin: 0 !important;
font-size: 12px;
padding: 7px 0;
line-height: 24px;
}
.jigoshop-order-panel label {
float: left;
width: 30%;
padding: 0;
}
.jigoshop-order-panel label .req {
font-weight: bold;
font-style: normal;
color: red;
}
.jigoshop-order-panel .description {
padding: 0;
margin: 0 0 0 7px;
}
.jigoshop-order-panel .description-block {
margin-left: 0;
display: block;
}
.jigoshop-order-panel textarea, .jigoshop-order-panel input, .jigoshop-order-panel select {
margin: 0;
}
.jigoshop-order-panel textarea {
width: 65% !important;
float: left;
}
.jigoshop-order-panel input {
width: 65%;
float: left;
}
.column-total_cost table.cost {
border: 1px solid #ddd !important;
width: 100%;
margin: 5px 0 !important;
}
.column-total_cost table.cost td, .column-total_cost table.cost th {
padding: 4px 9px 4px;
background: #eee;
line-height: 1;
}
.widefat th.column-id {
width: 60px !important;
}
.widefat .column-total_cost {
width: 150px !important;
}
.widefat .column-order_title {
width: 120px;
}
.widefat .column-order_title a {
display: block;
}
.widefat .column-order_title time {
color: #999;
}
.widefat .column-customer {
width: 140px;
}
.widefat .column-order_status {
width: 80px;
text-align: center;
}
.widefat .column-order_status mark {
display: block;
text-align: left;
text-indent: -9999px;
background: #fff;
height: 16px;
width: 16px;
background: #fff;
-webkit-box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.1);
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
-o-border-radius: 20px;
border-radius: 20px;
margin: 1px auto;
font-size: 9px;
text-transform: uppercase;
color: #fff;
font-weight: bold;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
-webkit-transition: all ease-in-out 0.1s;
}
.widefat .column-order_status mark.pending {
background: #E66F00;
}
.widefat .column-order_status mark.completed {
background: green;
}
.widefat .column-order_status mark.onhold {
background: red;
}
.widefat .column-order_status mark.cancelled {
background: #dfdfdf;
}
.widefat .column-order_status mark.processing {
background: #2184c2;
}
.widefat .column-order_status mark.on-hold {
background: red;
}
.widefat .column-order_status mark.refunded {
background: #ccc;
}
.widefat .column-order_status mark:hover {
text-indent: 0;
width: auto;
text-align: center;
}
ul.subsubsub li.pending a {
color: #E66F00;
}
ul.subsubsub li.completed a {
color: green;
}
ul.subsubsub li.onhold a {
color: red;
}
ul.subsubsub li.cancelled a {
color: #dfdfdf;
}
ul.subsubsub li.refunded a {
color: #ccc;
}
/* Product list */
table.wp-list-table .column-thumb {
width: 66px;
text-align: center;
white-space: nowrap;
}
table.wp-list-table .column-sku {
width: 100px;
}
table.wp-list-table img {
margin: 2px 0;
}
table.wp-list-table .column-thumb img {
padding: 2px;
border: 1px solid #dfdfdf;
vertical-align: middle;
}
table.wp-list-table span.na {
color: #999;
}
table.wp-list-table .column-featured, table.wp-list-table .column-sellable, table.wp-list-table .column-is_in_stock {
text-align: center !important;
}
/* Dashboard */
#jigoshop_dashboard {
padding: 0 5px;
}
#jigoshop_dashboard div.postbox div.inside {
margin: 10px;
position: relative;
}
#jigoshop_dashboard div.postbox h3 {
cursor: default !important;
}
#jigoshop_dashboard div.postbox a {
text-decoration: none;
}
.stats h3 a {
float: right;
margin-left: 8px;
}
ul.recent-orders li {
overflow: hidden;
zoom: 1;
border-bottom: #ECECEC 1px solid;
padding: 0 0 8px;
margin: 0 0 8px;
}
ul.recent-orders li .order-status {
float: right;
}
ul.recent-orders li small {
color: #999;
}
ul.recent-orders li .order-cost {
margin-left: 8px;
}
ul.recent-orders li .completed {
color: green;
}
ul.recent-orders li .on-hold {
color: red;
}
ul.recent-orders li .processing {
color: #21759B;
}
ul.recent-orders li .pending {
color: #E66F00;
}
ul.recent-orders li .refunded, ul.recent-orders li .cancelled {
color: #999;
}
.jigoshop_right_now p.sub, .jigoshop_right_now .table, .jigoshop_right_now .versions {
margin: -12px;
}
.jigoshop_right_now .inside {
font-size: 12px;
padding-top: 20px;
}
.jigoshop_right_now p.sub {
font-style: italic;
font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
padding: 5px 10px 15px;
color: #777;
font-size: 13px;
position: absolute;
top: -17px;
left: 15px;
}
.jigoshop_right_now .table {
margin: 0 -9px;
padding: 0 10px;
position: relative;
}
.jigoshop_right_now .table_content {
float: left;
border-top: #ececec 1px solid;
width: 45%;
}
.jigoshop_right_now .table_discussion {
float: right;
border-top: #ececec 1px solid;
width: 45%;
}
.jigoshop_right_now table td {
padding: 3px 0;
white-space: nowrap;
}
.jigoshop_right_now table tr.first td {
border-top: none;
}
.jigoshop_right_now td.b {
padding-right: 6px;
text-align: right;
font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
font-size: 14px;
width: 1%;
}
.jigoshop_right_now td.b a {
font-size: 18px;
}
.jigoshop_right_now td.b a:hover {
color: #d54e21;
}
.jigoshop_right_now .t {
font-size: 12px;
padding-right: 12px;
padding-top: 6px;
color: #777;
}
.jigoshop_right_now .t a {
white-space: nowrap;
}
.jigoshop_right_now .onhold {
color: red;
}
.jigoshop_right_now .pending {
color: #e66f00;
}
.jigoshop_right_now .complete {
color: green;
}
.jigoshop_right_now .versions {
padding: 4px 15px 12px;
clear: both;
}
.jigoshop-rss-widget ul li, .jigoshop-links-widget ul li {
line-height: 1.5em;
margin-bottom: 12px;
}
.jigoshop-links-widget ul.links {
float: left;
width: 49%;
}
.jigoshop-links-widget .social {
float: right;
width: 49%;
}
.jigoshop-links-widget .social h4 {
color: #999;
}
.jigoshop-links-widget .social h4.first {
margin-top: 0;
}
.jigoshop-links-widget .social img {
width: 49%;
}
.jigoshop-links-widget .social p {
color: #ccc;
line-height: 1.5em;
font-style: italic;
}
.jigoshop-reviews-widget li {
line-height: 1.5em;
margin-bottom: 12px;
}
.jigoshop-reviews-widget h4.meta {
line-height: 1.4;
margin: -0.2em 0 0 0;
font-weight: normal;
color: #999;
}
.jigoshop-reviews-widget blockquote {
padding: 0;
margin: 0;
}
.jigoshop-reviews-widget .avatar {
float: left;
margin: 0 10px 5px 0;
}
.jigoshop-reviews-widget .star-rating {
float: right;
width: 80px;
height: 16px;
background: url(../images/star.png) repeat-x left 0;
}
.jigoshop-reviews-widget .star-rating span {
background: url(../images/star.png) repeat-x left -32px;
height: 0;
padding-top: 16px;
overflow: hidden;
float: left;
}
/* Settings */
.jigoshop table.widefat {
width: 850px;
margin-top: 0.5em !important;
}
.jigoshop table.widefat .button {
float: left;
margin: 0 3px 3px 0 !important;
}
.jigoshop table.widefat .button-right {
float: right;
margin: 0 0 3px 3px !important;
}
.jigoshop table.widefat td, .jigoshop table.widefat th {
padding: 9px 9px;
}
.jigoshop table.widefat .forminp .input-text, .jigoshop table.widefat .forminp .select {
width: 45%;
}
.jigoshop table.widefat .forminp .wide-input {
width: 99%;
}
.jigoshop table.widefat th.desc {
font-weight: normal;
color: #2958aa;
}
.jigoshop table.widefat td small {
color: #999;
}
.jigoshop #tabs-wrap {
background: #ececec;
width: 850px;
padding: 7px 9px;
overflow: hidden;
margin-top: 0.5em !important;
margin-bottom: 2em !important;
zoom: 1;
}
.jigoshop #tabs-wrap ul.tabs {
padding: 0;
}
.jigoshop #tabs-wrap table {
margin: 0 0 5px !important;
border: 1px solid #e1e1e1;
border-top: 0;
}
.jigoshop #tabs-wrap table thead tr th {
border-top: 4px solid #e1e1e1;
}
.jigoshop #tabs-wrap table thead:first-child tr th {
border-top: 0;
}
.jigoshop #tabs-wrap table thead th {
background: #fff;
}
.jigoshop #tabs-wrap table select {
white-space: nowrap;
}
.jigoshop #tabs-wrap .submit {
float: right;
margin: 0 !important;
padding: 0 !important;
}
.jigoshop #tabs-wrap table.shippingrows {
border: 0;
width: 100%;
}
.jigoshop #tabs-wrap table.shippingrows td, .jigoshop #tabs-wrap table.shippingrows th {
padding: 4px 4px 4px 0 !important;
border: 0 !important;
vertical-align: middle;
}
.jigoshop #tabs-wrap table.shippingrows td a.remove {
margin: 0 !important;
}
p.taxrow select {
width: 125px;
}
p.taxrow input.text {
width: 60px;
}
p.taxrow label {
line-height: 1.5em;
margin: 0 8px;
}
p.taxrow label input {
margin: 0 4px 0 0;
}
.jigoshop table.widefat table.coupon_rows {
border: 0 !important;
width: 100%;
}
.jigoshop table.widefat table.coupon_rows thead th {
padding: 1px;
border: 0;
font-weight: normal;
font-size: 11px;
color: #999;
}
.jigoshop table.widefat table.coupon_rows tbody td {
padding: 3px 3px 0 0;
border: 0;
vertical-align: middle;
}
.jigoshop table.widefat table.coupon_rows tbody td input.text {
width: 95px;
}
a.tips {
height: 16px;
width: 16px;
margin: 4px -8px 0 0;
float: right;
background: url(../images/tip.png) no-repeat top left;
}
#easyTooltip {
padding: 8px;
border: 3px solid #b9e3f0;
background: #E3F4F9;
font-size: 12px;
width: 400px;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
-o-border-radius: 8px;
-khtml-border-radius: 8px;
border-radius: 8px;
}
.jigoshop #tabs-wrap table a.remove {
margin-left: 4px;
}
.jigoshop #tabs-wrap table p {
margin: 0 0 4px !important;
overflow: hidden;
zoom: 1;
}
.jigoshop #tabs-wrap table p a.add {
float: left;
}
/* Write Panels */
#jigoshop-product-data ul.product_data_tabs, .jigoshop ul.tabs {
background: #ececec;
padding: 7px 9px 0;
overflow: hidden;
zoom: 1;
line-height: 1em;
}
#jigoshop-product-data ul.product_data_tabs li, .jigoshop ul.tabs li {
float: left;
padding: 0;
margin: 0 5px 0 0;
}
#jigoshop-product-data ul.product_data_tabs li a, .jigoshop ul.tabs li a {
padding: 0;
margin: 0;
border: 0;
border: 1px solid #d5d5d5;
border-bottom: 0;
float: left;
padding: 7px 9px;
background: #e1e1e1;
text-decoration: none;
color: #555;
-moz-border-radius-topleft: 3px;
-moz-border-radius-topright: 3px;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
#jigoshop-product-data ul.product_data_tabs li.active a, .jigoshop ul.tabs li.active a {
background: #fff;
border-color: #e1e1e1;
color: #333;
}
#jigoshop-product-data .inside, #jigoshop-product-type-options .inside, #jigoshop-order-data .inside {
padding: 0;
margin: 0;
}
.jigoshop_options_panel, .panel {
padding: 9px 9px 9px 9px;
color: #555;
}
.jigoshop_page_settings .jigoshop_options_panel, .panel {
padding: 0;
}
#jigoshop-product-type-options .panel, #jigoshop-product-specs .inside {
padding: 9px;
margin: 0;
}
.jigoshop_options_panel p, #jigoshop-product-type-options .panel p {
overflow: hidden;
zoom: 1;
margin: 0 0 9px;
font-size: 12px;
padding: 7px 9px;
line-height: 24px;
}
.jigoshop_options_panel label {
float: left;
width: 150px;
padding: 0;
}
.jigoshop_options_panel label .req {
font-weight: bold;
font-style: normal;
color: red;
}
.jigoshop_options_panel .description {
padding: 0;
margin: 0 0 0 7px;
}
.jigoshop_options_panel .description-block {
margin-left: 0;
display: block;
}
.jigoshop_options_panel textarea, .jigoshop_options_panel input, .jigoshop_options_panel select {
margin: 0;
}
.jigoshop_options_panel textarea {
width: 50% !important;
float: left;
}
.jigoshop_options_panel input {
width: 50%;
float: left;
}
.jigoshop_options_panel .checkbox, table.jigoshop_variable_attributes .checkbox {
vertical-align: middle;
margin: 7px 0;
}
.jigoshop_options_panel select {
float: left;
}
.jigoshop_options_panel .short {
width: 20%;
}
#jigoshop_attributes {
padding: 12px;
}
.jigoshop_attributes_wrapper, .jigoshop_variable_attributes_wrapper {
margin-bottom: 7px;
border: 1px solid #ececec;
}
table.jigoshop_attributes, table.jigoshop_variable_attributes {
width: 100%;
}
table.jigoshop_attributes thead th, table.jigoshop_variable_attributes thead th {
background: #ececec;
padding: 7px 9px;
font-size: 11px;
text-align: left;
}
table.jigoshop_attributes td, table.jigoshop_variable_attributes td {
padding: 2px 9px;
text-align: left;
vertical-align: middle;
border-bottom: 1px dotted #ececec;
}
table.jigoshop_attributes td input, table.jigoshop_variable_attributes td input, table.jigoshop_variable_attributes td textarea {
width: 100%;
}
table.jigoshop_attributes td select {
width: 100%;
}
table.jigoshop_attributes td select.multiselect {
height: 8em !important;
}
table.jigoshop_attributes td input, table.jigoshop_variable_attributes td input, table.jigoshop_variable_attributes td textarea {
font-size: 14px;
padding: 4px;
color: #555;
}
table.jigoshop_attributes .taxonomy td.name {
padding: 10px 15px;
font-size: 14px;
color: #555;
}
table.jigoshop_attributes .center {
text-align: center;
}
#jigoshop_attributes select.attribute_taxonomy,
button.add_attribute,
button.add_variable_attribute,
button.add_configuration {
float: right;
}
div.multi_select_products_wrapper {
float: left;
padding: 0 9px 9px;
}
.multi_select_products, div.multi_select_countries {
border: 1px solid #ececec;
height: 200px;
overflow: auto;
width: 250px;
float: left;
}
.multi_select_products li {
padding: 7px 9px;
line-height: 2em;
border-bottom: 1px dotted #ececec;
}
.multi_select_countries li {
padding: 3px 9px;
margin: 0;
line-height: 2em;
border-bottom: 1px dotted #ececec;
}
.multi_select_countries li label {
display: block;
}
.multi_select_countries li label input {
margin: 0 4px 0 0;
}
.multi_select_products button {
float: right;
vertical-align: middle;
}
#jigoshop-product-data a.dp-choose-date {
float: left;
width: 16px;
height: 16px;
padding: 0;
margin: 4px 9px 0 3px;
display: block;
text-indent: -2000px;
overflow: hidden;
background: url(../images/calendar.png) no-repeat;
}
#jigoshop-product-data a.dp-choose-date.dp-disabled {
background-position: 0 -20px;
cursor: default;
}
#jigoshop-product-data input.dp-applied {
width: 140px;
float: left;
}
#grouped_product_options, #virtual_product_options, #simple_product_options {
padding: 12px;
font-style: italic;
color: #666;
}
/* Configuration */
#variable_product_options p.description {
float: left;
padding: 0;
margin: 0;
}
.jigoshop_configuration {
background: #ececec;
border: 1px solid #ececec;
margin: 0 0 8px;
}
.jigoshop_configuration p {
margin: 0 !important;
}
.jigoshop_configuration p button {
float: right;
}
.jigoshop_configuration table td {
background: #fff;
padding: 6px 6px;
vertical-align: middle;
}
.jigoshop_configuration table td label {
color: #999;
font-size: 10px;
text-transform: uppercase;
text-align: left;
display: block;
line-height: 16px;
}
.jigoshop_configuration table td input {
float: left;
width: 100%;
}
.jigoshop_configuration table td.upload_image {
width: 1%;
white-space: nowrap;
}
.jigoshop_configuration table td.upload_image img {
float: none;
margin-right: 6px;
vertical-align: middle;
}
.jigoshop_configuration table td.upload_image .button {
margin: 0;
padding: 4px 10px;
width: auto;
float: none;
vertical-align: middle;
}
.widefat .product-cat-placeholder {
outline: 1px dotted #A0C443;
height: 60px;
background: #000;
}

975
assets/css/admin.less Normal file
View File

@ -0,0 +1,975 @@
#toplevel_page_jigoshop .wp-menu-image {
background: url(../images/icons/menu_icons.png) no-repeat 0px -32px !important;
}
#toplevel_page_jigoshop:hover .wp-menu-image,
#toplevel_page_jigoshop.wp-has-current-submenu .wp-menu-image {
background: url(../images/icons/menu_icons.png) no-repeat 0px 0px !important;
}
#toplevel_page_jigoshop .wp-menu-image img {
display: none;
}
#menu-posts-product .wp-menu-image {
background: url(../images/icons/menu_icons.png) no-repeat -35px -32px !important;
}
#menu-posts-product:hover .wp-menu-image,
#menu-posts-product.wp-has-current-submenu .wp-menu-image {
background: url(../images/icons/menu_icons.png) no-repeat -35px 0px !important;
}
#menu-posts-shoporder .wp-menu-image {
background: url(../images/icons/menu_icons.png) no-repeat -70px -32px !important;
}
#menu-posts-shoporder:hover .wp-menu-image,
#menu-posts-shoporder.wp-has-current-submenu .wp-menu-image {
background: url(../images/icons/menu_icons.png) no-repeat -70px 0px !important;
}
#icon-jigoshop, .jigoshop_icon, .icon32-posts-product, .icon32-posts-shoporder {
background-image: url(../images/icons/jigoshop-icons.png) !important;
background-position: -11px -5px;
}
.icon32-posts-product {
background-position: -185px -5px !important;
}
.icon32-posts-product {
background-position: -69px -5px !important;
}
.icon32-posts-shoporder {
background-position: -127px -5px !important;
}
.icon32-attributes {
background-position: -185px -5px !important;
}
.icon32-jigoshop-settings {
background-position: -359px -5px !important;
}
.icon32-jigoshop-debug {
background-position: -417px -5px !important;
}
/* Orders */
.order_actions {
color: #999;
font-size: 11px;
li {
border-top: 1px solid #fff;
border-bottom: 1px solid #ddd;
padding: 6px;
margin: 0;
line-height: 1.6em;
}
}
#jigoshop-order-items {
.inside {
margin: 0;
padding: 0;
background: #fefefe;
}
.buttons {
float: left;
padding-left: 6px;
vertical-align: top;
.item_id {
width: 300px;
vertical-align: top;
}
button {
margin: 2px 0 0 0;
}
}
.buttons-alt {
float: right;
padding-right: 6px;
}
h3 small {
color: #999;
}
}
dl.totals {
margin: 6px 6px 0;
float: left;
dt {
float: left;
width: 100%;
font-size: 1.2em;
font-weight: bold;
line-height: 2em;
}
dd {
line-height: 2em;
font-size: 1.2em;
float: left;
width: 100%;
input {
width: 100%;
vertical-align: middle;
float: left;
font-size: 1em;
margin: 0 !important;
}
input.first {
width: 49%;
float: left;
}
input.last {
width: 49%;
float: right;
}
}
}
.jigoshop_order_items_wrapper {
margin: 0;
table.jigoshop_order_items {
width: 100%;
background: #fff;
thead th {
background: #ECECEC;
padding: 8px 10px;
font-size: 11px;
text-align: left;
}
td {
padding: 8px 10px;
text-align: left;
vertical-align: middle;
border-bottom: 1px dotted #ececec;
input, textarea {
width: 100%;
}
select {
width: 50%;
}
input, textarea {
font-size: 14px;
padding: 4px;
color: #555;
}
}
.name {
min-width: 100px;
}
.center, .variation-id, .product-id, .product-sku {
text-align: center;
}
table.meta {
tr {
td {
padding: 1px 4px 1px 0;
border: 0;
}
}
}
}
}
.jigoshop-order-panel {
overflow: hidden;
zoom: 1;
.panel {
padding: 0 9px;
}
.column {
width: 47%;
}
.first {
float: left;
}
.last {
float: right;
}
.panel p {
overflow: hidden;
zoom: 1;
margin: 0 !important;
font-size: 12px;
padding: 7px 0;
line-height: 24px;
}
label {
float: left;
width: 30%;
padding: 0;
.req {
font-weight: bold;
font-style: normal;
color: red;
}
}
.description {
padding: 0;
margin: 0 0 0 7px;
}
.description-block {
margin-left: 0;
display: block;
}
textarea, input, select {
margin: 0;
}
textarea {
width: 65% !important;
float: left;
}
input {
width: 65%;
float: left;
}
}
.column-total_cost {
table.cost {
border: 1px solid #ddd !important;
width: 100%;
margin: 5px 0 !important;
td, th {
padding: 4px 9px 4px;
background: #eee;
line-height: 1;
}
}
}
.widefat {
th.column-id {
width:60px !important;
}
.column-total_cost {
width:150px !important;
}
.column-order_title {
width:120px;
a {
display: block;
}
time {
color:#999;
}
}
.column-customer {
width:140px;
}
.column-order_status {
width:80px;
text-align: center;
mark {
display: block;
text-align: left;
text-indent: -9999px;
background: #fff;
height:16px;
width:16px;
background: #fff;
-webkit-box-shadow:inset 0 0 0 3px rgba(0,0,0,0.1);
-webkit-border-radius:20px;
-moz-border-radius:20px;
-o-border-radius:20px;
border-radius:20px;
margin:1px auto;
font-size:9px;
text-transform: uppercase;
color:#fff;
font-weight: bold;
text-shadow:0 1px 0 rgba(0,0,0,0.1);
-webkit-transition: all ease-in-out .1s;
}
mark.pending {
background: #E66F00;
}
mark.completed {
background: green;
}
mark.onhold {
background: red;
}
mark.cancelled {
background: #dfdfdf;
}
mark.processing {
background: #2184c2;
}
mark.on-hold {
background: red;
}
mark.refunded {
background: #ccc;
}
mark:hover {
text-indent: 0;
width:auto;
text-align: center;
}
}
}
ul.subsubsub {
li.pending {
a {
color:#E66F00;
}
}
li.completed {
a {
color:green;
}
}
li.onhold {
a {
color:red;
}
}
li.cancelled {
a {
color:#dfdfdf;
}
}
li.refunded {
a {
color:#ccc;
}
}
}
/* Product list */
table.wp-list-table .column-thumb {
width: 66px;
text-align: center;
white-space: nowrap
}
table.wp-list-table .column-sku {
width: 100px;
}
table.wp-list-table img {
margin: 2px 0;
}
table.wp-list-table .column-thumb img {
padding: 2px;
border: 1px solid #dfdfdf;
vertical-align: middle;
}
table.wp-list-table span.na {
color: #999;
}
table.wp-list-table .column-featured, table.wp-list-table .column-sellable, table.wp-list-table .column-is_in_stock {
text-align: center !important;
}
/* Dashboard */
#jigoshop_dashboard {
padding: 0 5px;
}
#jigoshop_dashboard div.postbox div.inside {
margin: 10px;
position: relative;
}
#jigoshop_dashboard div.postbox h3 {
cursor: default !important;
}
#jigoshop_dashboard div.postbox a {
text-decoration: none;
}
.stats {
h3 a {
float: right;
margin-left: 8px;
}
}
ul.recent-orders {
li {
overflow: hidden;
zoom: 1;
border-bottom: #ECECEC 1px solid;
padding: 0 0 8px;
margin: 0 0 8px;
.order-status {
float: right;
}
small {
color: #999;
}
.order-cost {
margin-left: 8px;
}
.completed {
color: green;
}
.on-hold {
color: red;
}
.processing {
color: #21759B;
}
.pending {
color: #E66F00;
}
.refunded, .cancelled {
color: #999;
}
}
}
.jigoshop_right_now p.sub,
.jigoshop_right_now .table, .jigoshop_right_now .versions {
margin: -12px;
}
.jigoshop_right_now .inside {
font-size: 12px;
padding-top: 20px;
}
.jigoshop_right_now p.sub {
font-style: italic;
font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
padding: 5px 10px 15px;
color: #777;
font-size: 13px;
position: absolute;
top: -17px;
left: 15px;
}
.jigoshop_right_now .table {
margin: 0 -9px;
padding: 0 10px;
position: relative;
}
.jigoshop_right_now .table_content {
float: left;
border-top: #ececec 1px solid;
width: 45%;
}
.jigoshop_right_now .table_discussion {
float: right;
border-top: #ececec 1px solid;
width: 45%;
}
.jigoshop_right_now table td {
padding: 3px 0;
white-space: nowrap;
}
.jigoshop_right_now table tr.first td {
border-top: none;
}
.jigoshop_right_now td.b {
padding-right: 6px;
text-align: right;
font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
font-size: 14px;
width: 1%;
}
.jigoshop_right_now td.b a {
font-size: 18px;
}
.jigoshop_right_now td.b a:hover {
color: #d54e21;
}
.jigoshop_right_now .t {
font-size: 12px;
padding-right: 12px;
padding-top: 6px;
color: #777;
}
.jigoshop_right_now .t a {
white-space: nowrap;
}
.jigoshop_right_now .onhold {
color: red;
}
.jigoshop_right_now .pending {
color: #e66f00;
}
.jigoshop_right_now .complete {
color: green;
}
.jigoshop_right_now .versions {
padding: 4px 15px 12px;
clear: both;
}
.jigoshop-rss-widget ul li, .jigoshop-links-widget ul li {
line-height: 1.5em;
margin-bottom: 12px;
}
.jigoshop-links-widget {
ul.links {
float: left;
width: 49%;
}
.social {
float: right;
width: 49%;
h4 {
color: #999;
&.first {
margin-top: 0;
}
}
img {
width: 49%;
}
p {
color: #ccc;
line-height: 1.5em;
font-style: italic;
}
}
}
.jigoshop-reviews-widget {
li {
line-height: 1.5em;
margin-bottom: 12px;
}
h4.meta {
line-height: 1.4;
margin: -.2em 0 0 0;
font-weight: normal;
color: #999;
}
blockquote {
padding: 0;
margin: 0;
}
.avatar {
float: left;
margin: 0 10px 5px 0;
}
.star-rating {
float: right;
width: 80px;
height: 16px;
background: url(../images/star.png) repeat-x left 0;
span {
background: url(../images/star.png) repeat-x left -32px;
height: 0;
padding-top: 16px;
overflow: hidden;
float: left;
}
}
}
/* Settings */
.jigoshop table.widefat {
width: 850px;
margin-top: 0.5em !important;
.button {
float: left;
margin: 0 3px 3px 0 !important;
}
.button-right {
float: right;
margin: 0 0 3px 3px !important;
}
td, th {
padding: 9px 9px;
}
.forminp {
.input-text, .select {
width: 45%;
}
.wide-input {
width: 99%;
}
}
}
.jigoshop table.widefat th.desc {
font-weight: normal;
color: #2958aa;
}
.jigoshop table.widefat td small {
color: #999;
}
.jigoshop #tabs-wrap {
background: #ececec;
width: 850px;
padding: 7px 9px;
overflow: hidden;
margin-top: 0.5em !important;
margin-bottom: 2em !important;
zoom: 1;
}
.jigoshop #tabs-wrap ul.tabs {
padding: 0;
}
.jigoshop #tabs-wrap table {
margin: 0 0 5px !important;
border: 1px solid #e1e1e1;
border-top: 0;
}
.jigoshop #tabs-wrap table thead tr th {
border-top: 4px solid #e1e1e1;
}
.jigoshop #tabs-wrap table thead:first-child tr th {
border-top: 0;
}
.jigoshop #tabs-wrap table thead th {
background: #fff;
}
.jigoshop #tabs-wrap table select {
white-space: nowrap;
}
.jigoshop #tabs-wrap .submit {
float: right;
margin: 0 !important;
padding: 0 !important;
}
.jigoshop #tabs-wrap table.shippingrows {
border: 0;
width: 100%;
}
.jigoshop #tabs-wrap table.shippingrows td,.jigoshop #tabs-wrap table.shippingrows th {
padding: 4px 4px 4px 0 !important;
border: 0 !important;
vertical-align: middle;
}
.jigoshop #tabs-wrap table.shippingrows td a.remove {
margin: 0 !important;
}
p.taxrow select {
width: 125px;
}
p.taxrow input.text {
width: 60px;
}
p.taxrow label {
line-height: 1.5em;
margin: 0 8px;
input {
margin: 0 4px 0 0;
}
}
.jigoshop table.widefat {
table.coupon_rows {
border: 0 !important;
width: 100%;
thead {
th {
padding: 1px;
border: 0;
font-weight: normal;
font-size: 11px;
color: #999;
}
}
tbody {
td {
padding: 3px 3px 0 0;
border: 0;
vertical-align: middle;
input.text {
width: 95px;
}
}
}
}
}
a.tips {
height: 16px;
width: 16px;
margin: 4px -8px 0 0;
float: right;
background: url(../images/tip.png) no-repeat top left;
}
#easyTooltip {
padding:8px;
border:3px solid #b9e3f0;
background:#E3F4F9;
font-size: 12px;
width:400px;
-moz-border-radius:8px;
-webkit-border-radius:8px;
-o-border-radius:8px;
-khtml-border-radius:8px;
border-radius:8px;
}
.jigoshop #tabs-wrap table a.remove {
margin-left: 4px;
}
.jigoshop #tabs-wrap table p {
margin: 0 0 4px !important;
overflow: hidden;
zoom: 1;
}
.jigoshop #tabs-wrap table p a.add {
float: left;
}
/* Write Panels */
#jigoshop-product-data ul.product_data_tabs, .jigoshop ul.tabs {
background: #ececec;
padding: 7px 9px 0;
overflow: hidden;
zoom: 1;
line-height: 1em;
}
#jigoshop-product-data ul.product_data_tabs li, .jigoshop ul.tabs li {
float: left;
padding: 0;
margin: 0 5px 0 0;
}
#jigoshop-product-data ul.product_data_tabs li a, .jigoshop ul.tabs li a {
padding: 0;
margin: 0;
border: 0;
border: 1px solid #d5d5d5;
border-bottom: 0;
float: left;
padding: 7px 9px;
background: #e1e1e1;
text-decoration: none;
color: #555;
-moz-border-radius-topleft: 3px;
-moz-border-radius-topright: 3px;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
#jigoshop-product-data ul.product_data_tabs li.active a, .jigoshop ul.tabs li.active a {
background: #fff;
border-color: #e1e1e1;
color: #333;
}
#jigoshop-product-data .inside, #jigoshop-product-type-options .inside, #jigoshop-order-data .inside {
padding: 0;
margin: 0;
}
.jigoshop_options_panel, .panel {
padding: 9px 9px 9px 9px;
color: #555;
}
.jigoshop_page_settings .jigoshop_options_panel, .panel {
padding: 0;
}
#jigoshop-product-type-options .panel, #jigoshop-product-specs .inside {
padding: 9px;
margin: 0;
}
.jigoshop_options_panel p, #jigoshop-product-type-options .panel p {
overflow: hidden;
zoom: 1;
margin: 0 0 9px;
font-size: 12px;
padding: 7px 9px;
line-height: 24px;
}
.jigoshop_options_panel label {
float: left;
width: 150px;
padding: 0;
}
.jigoshop_options_panel label .req {
font-weight: bold;
font-style: normal;
color: red;
}
.jigoshop_options_panel .description {
padding: 0;
margin: 0 0 0 7px;
}
.jigoshop_options_panel .description-block {
margin-left: 0;
display: block;
}
.jigoshop_options_panel textarea, .jigoshop_options_panel input, .jigoshop_options_panel select {
margin: 0;
}
.jigoshop_options_panel textarea {
width: 50% !important;
float: left;
}
.jigoshop_options_panel input {
width: 50%;
float: left;
}
.jigoshop_options_panel .checkbox, table.jigoshop_variable_attributes .checkbox {
vertical-align: middle;
margin: 7px 0;
}
.jigoshop_options_panel select {
float: left;
}
.jigoshop_options_panel .short {
width: 20%;
}
#jigoshop_attributes {
padding: 12px;
}
.jigoshop_attributes_wrapper, .jigoshop_variable_attributes_wrapper {
margin-bottom: 7px;
border: 1px solid #ececec;
}
table.jigoshop_attributes, table.jigoshop_variable_attributes {
width: 100%;
}
table.jigoshop_attributes thead th, table.jigoshop_variable_attributes thead th {
background: #ececec;
padding: 7px 9px;
font-size: 11px;
text-align: left;
}
table.jigoshop_attributes td, table.jigoshop_variable_attributes td {
padding: 2px 9px;
text-align: left;
vertical-align: middle;
border-bottom: 1px dotted #ececec;
}
table.jigoshop_attributes td input, table.jigoshop_variable_attributes td input, table.jigoshop_variable_attributes td textarea {
width: 100%;
}
table.jigoshop_attributes td select {
width: 100%;
}
table.jigoshop_attributes td select.multiselect {
height: 8em !important;
}
table.jigoshop_attributes td input, table.jigoshop_variable_attributes td input, table.jigoshop_variable_attributes td textarea {
font-size: 14px;
padding: 4px;
color: #555;
}
table.jigoshop_attributes .taxonomy td.name {
padding: 10px 15px;
font-size: 14px;
color: #555;
}
table.jigoshop_attributes .center {
text-align: center;
}
#jigoshop_attributes select.attribute_taxonomy, button.add_attribute, button.add_variable_attribute, button.add_configuration {
float: right;
}
div.multi_select_products_wrapper {
float: left;
padding: 0 9px 9px;
}
.multi_select_products, div.multi_select_countries {
border: 1px solid #ececec;
height: 200px;
overflow: auto;
width: 250px;
float: left;
}
.multi_select_products li {
padding: 7px 9px;
line-height: 2em;
border-bottom: 1px dotted #ececec;
}
.multi_select_countries li {
padding: 3px 9px;
margin: 0;
line-height: 2em;
border-bottom: 1px dotted #ececec;
}
.multi_select_countries li label {
display: block;
}
.multi_select_countries li label input {
margin: 0 4px 0 0;
}
.multi_select_products button {
float: right;
vertical-align: middle;
}
#jigoshop-product-data a.dp-choose-date {
float: left;
width: 16px;
height: 16px;
padding: 0;
margin: 4px 9px 0 3px;
display: block;
text-indent: -2000px;
overflow: hidden;
background: url(../images/calendar.png) no-repeat;
}
#jigoshop-product-data a.dp-choose-date.dp-disabled {
background-position: 0 -20px;
cursor: default;
}
#jigoshop-product-data input.dp-applied {
width: 140px;
float: left;
}
#grouped_product_options, #virtual_product_options, #simple_product_options {
padding: 12px;
font-style: italic;
color: #666;
}
/* Configuration */
#variable_product_options {
p.description {
float: left;
padding: 0;
margin: 0;
}
}
.jigoshop_configuration {
background: #ececec;
border: 1px solid #ececec;
margin: 0 0 8px;
p {
margin: 0 !important;
button {
float: right;
}
}
table td {
background: #fff;
padding: 6px 6px;
vertical-align: middle;
label {
color: #999;
font-size: 10px;
text-transform: uppercase;
text-align: left;
display: block;
line-height: 16px;
}
input {
float: left;
width: 100%;
}
&.upload_image {
width: 1%;
white-space: nowrap;
img {
float: none;
margin-right: 6px;
vertical-align: middle;
}
.button {
margin: 0;
padding: 4px 10px;
width: auto;
float: none;
vertical-align: middle;
}
}
}
}
.widefat .product-cat-placeholder {
outline: 1px dotted #A0C443;
height: 60px;
background: #000;
}

129
assets/css/datepicker.css Normal file
View File

@ -0,0 +1,129 @@
table.jCalendar {
border: 1px solid #000;
background: #aaa;
border-collapse: separate;
border-spacing: 2px;
width: 190px;
}
table.jCalendar th {
background: #333;
color: #fff;
font-weight: bold;
padding: 3px 5px;
}
table.jCalendar td {
background: #ccc;
color: #000;
padding: 3px 5px;
text-align: center;
font-size: 10px !important;
}
table.jCalendar td.other-month {
background: #ddd;
color: #aaa;
}
table.jCalendar td.today {
background: #666;
color: #fff;
}
table.jCalendar td.selected {
background: #f66;
color: #fff;
}
table.jCalendar td.selected.dp-hover {
background: #f33;
color: #fff;
}
table.jCalendar td.dp-hover,
table.jCalendar tr.activeWeekHover td {
background: #fff;
color: #000;
}
table.jCalendar tr.selectedWeek td {
background: #f66;
color: #fff;
}
table.jCalendar td.disabled, table.jCalendar td.disabled.dp-hover {
background: #bbb;
color: #888;
}
table.jCalendar td.unselectable,
table.jCalendar td.unselectable:hover,
table.jCalendar td.unselectable.dp-hover {
background: #bbb;
color: #888;
}
/* For the popup */
/* NOTE - you will probably want to style a.dp-choose-date - see how I did it in demo.css */
div.dp-popup {
position: relative;
background: #ccc;
font-size: 10px !important;
font-family: arial, sans-serif;
padding: 2px;
width: 190px;
line-height: 1.2em;
}
div#dp-popup {
position: absolute;
z-index: 199;
}
div.dp-popup h2 {
font-size: 12px !important;
text-align: center;
margin: 2px 0;
padding: 0;
}
a#dp-close {
font-size: 11px !important;
padding: 4px 0;
text-align: center;
display: block;
}
a#dp-close:hover {
text-decoration: underline;
}
div.dp-popup a {
color: #000;
text-decoration: none;
padding: 3px 2px 0;
}
div.dp-popup div.dp-nav-prev {
position: absolute;
top: 2px;
left: 4px;
width: 100px;
}
div.dp-popup div.dp-nav-prev a {
float: left;
}
/* Opera needs the rules to be this specific otherwise it doesn't change the cursor back to pointer after you have disabled and re-enabled a link */
div.dp-popup div.dp-nav-prev a, div.dp-popup div.dp-nav-next a {
cursor: pointer;
}
div.dp-popup div.dp-nav-prev a.disabled, div.dp-popup div.dp-nav-next a.disabled {
cursor: default;
}
div.dp-popup div.dp-nav-next {
position: absolute;
top: 2px;
right: 4px;
width: 100px;
}
div.dp-popup div.dp-nav-next a {
float: right;
}
div.dp-popup a.disabled {
cursor: default;
color: #aaa;
}
div.dp-popup td {
cursor: pointer;
}
div.dp-popup td.disabled {
cursor: default;
}

323
assets/css/fancybox.css Executable file
View File

@ -0,0 +1,323 @@
/*
* FancyBox - jQuery Plugin
* Simple and fancy lightbox alternative
*
* Examples and documentation at: http://fancybox.net
*
* Copyright (c) 2008 - 2010 Janis Skarnelis
* That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
*
* Version: 1.3.4 (11/11/2010)
* Requires: jQuery v1.3+
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
#fancybox-loading {
position: fixed;
top: 50%;
left: 50%;
width: 40px;
height: 40px;
margin-top: -20px;
margin-left: -20px;
cursor: pointer;
overflow: hidden;
z-index: 1104;
display: none;
}
#fancybox-loading div {
position: absolute;
top: 0;
left: 0;
width: 40px;
height: 480px;
background-image: url('../images/fancybox/fancybox.png');
}
#fancybox-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 1100;
display: none;
}
#fancybox-tmp {
padding: 0;
margin: 0;
border: 0;
overflow: auto;
display: none;
}
#fancybox-wrap {
position: absolute;
top: 0;
left: 0;
padding: 20px;
z-index: 1101;
outline: none;
display: none;
}
#fancybox-outer {
position: relative;
width: 100%;
height: 100%;
background: #fff;
}
#fancybox-content {
width: 0;
height: 0;
padding: 0;
outline: none;
position: relative;
overflow: hidden;
z-index: 1102;
border: 0px solid #fff;
}
#fancybox-hide-sel-frame {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: transparent;
z-index: 1101;
}
#fancybox-close {
position: absolute;
top: -15px;
right: -15px;
width: 30px;
height: 30px;
background: transparent url('../images/fancybox/fancybox.png') -40px 0px;
cursor: pointer;
z-index: 1103;
display: none;
}
#fancybox-error {
color: #444;
font: normal 12px/20px Arial;
padding: 14px;
margin: 0;
}
#fancybox-img {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
border: none;
outline: none;
line-height: 0;
vertical-align: top;
}
#fancybox-frame {
width: 100%;
height: 100%;
border: none;
display: block;
}
#fancybox-left, #fancybox-right {
position: absolute;
bottom: 0px;
height: 100%;
width: 35%;
cursor: pointer;
outline: none;
background: transparent url('../images/fancybox/blank.gif');
z-index: 1102;
display: none;
}
#fancybox-left {
left: 0px;
}
#fancybox-right {
right: 0px;
}
#fancybox-left-ico, #fancybox-right-ico {
position: absolute;
top: 50%;
left: -9999px;
width: 30px;
height: 30px;
margin-top: -15px;
cursor: pointer;
z-index: 1102;
display: block;
}
#fancybox-left-ico {
background-image: url('../images/fancybox/fancybox.png');
background-position: -40px -30px;
}
#fancybox-right-ico {
background-image: url('../images/fancybox/fancybox.png');
background-position: -40px -60px;
}
#fancybox-left:hover, #fancybox-right:hover {
visibility: visible; /* IE6 */
}
#fancybox-left:hover span {
left: 20px;
}
#fancybox-right:hover span {
left: auto;
right: 20px;
}
.fancybox-bg {
position: absolute;
padding: 0;
margin: 0;
border: 0;
width: 20px;
height: 20px;
z-index: 1001;
}
#fancybox-bg-n {
top: -20px;
left: 0;
width: 100%;
background-image: url('../images/fancybox/fancybox-x.png');
}
#fancybox-bg-ne {
top: -20px;
right: -20px;
background-image: url('../images/fancybox/fancybox.png');
background-position: -40px -162px;
}
#fancybox-bg-e {
top: 0;
right: -20px;
height: 100%;
background-image: url('../images/fancybox/fancybox-y.png');
background-position: -20px 0px;
}
#fancybox-bg-se {
bottom: -20px;
right: -20px;
background-image: url('../images/fancybox/fancybox.png');
background-position: -40px -182px;
}
#fancybox-bg-s {
bottom: -20px;
left: 0;
width: 100%;
background-image: url('../images/fancybox/fancybox-x.png');
background-position: 0px -20px;
}
#fancybox-bg-sw {
bottom: -20px;
left: -20px;
background-image: url('../images/fancybox/fancybox.png');
background-position: -40px -142px;
}
#fancybox-bg-w {
top: 0;
left: -20px;
height: 100%;
background-image: url('../images/fancybox/fancybox-y.png');
}
#fancybox-bg-nw {
top: -20px;
left: -20px;
background-image: url('../images/fancybox/fancybox.png');
background-position: -40px -122px;
}
#fancybox-title {
font-family: Helvetica;
font-size: 12px;
z-index: 1102;
}
.fancybox-title-inside {
padding-bottom: 10px;
text-align: center;
color: #333;
background: #fff;
position: relative;
}
.fancybox-title-outside {
padding-top: 10px;
color: #fff;
}
.fancybox-title-over {
position: absolute;
bottom: 0;
left: 0;
color: #FFF;
text-align: left;
}
#fancybox-title-over {
padding: 10px;
background-image: url('../images/fancybox/fancy_title_over.png');
display: block;
}
.fancybox-title-float {
position: absolute;
left: 0;
bottom: -20px;
height: 32px;
}
#fancybox-title-float-wrap {
border: none;
border-collapse: collapse;
width: auto;
}
#fancybox-title-float-wrap td {
border: none;
white-space: nowrap;
}
#fancybox-title-float-left {
padding: 0 0 0 15px;
background: url('../images/fancybox/fancybox.png') -40px -90px no-repeat;
}
#fancybox-title-float-main {
color: #FFF;
line-height: 29px;
font-weight: bold;
padding: 0 0 3px 0;
background: url('../images/fancybox/fancybox-x.png') 0px -40px;
}
#fancybox-title-float-right {
padding: 0 0 0 15px;
background: url('../images/fancybox/fancybox.png') -55px -90px no-repeat;
}

1109
assets/css/frontend.css Normal file

File diff suppressed because it is too large Load Diff

1180
assets/css/frontend.less Normal file

File diff suppressed because it is too large Load Diff

38
assets/css/ui.css Normal file
View File

@ -0,0 +1,38 @@
/* Interaction states
----------------------------------*/
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3; background: #e6e6e6 url(../images/ui/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #555555; }
.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #555555; text-decoration: none; }
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #999999; background: #dadada url(../images/ui/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
.ui-state-hover a, .ui-state-hover a:hover { color: #212121; text-decoration: none; }
.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa; background: #ffffff url(../images/ui/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #212121; text-decoration: none; }
.ui-widget :active { outline: none; }
/* Interaction Cues
----------------------------------*/
.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fcefa1; background: #fbf9ee url(../images/ui/ui-bg_glass_55_fbf9ee_1x400.png) 50% 50% repeat-x; color: #363636; }
.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; }
.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(../images/ui/ui-bg_inset-soft_95_fef1ec_1x100.png) 50% bottom repeat-x; color: #cd0a0a; }
.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cd0a0a; }
.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cd0a0a; }
.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; }
.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
/* Slider
----------------------------------*/
.ui-corner-all { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; }
.ui-slider { position: relative; text-align: left; }
.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }
.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
.price_slider_wrapper .ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(../images/ui/ui-bg_glass_75_ffffff_1x400.png) 50% 50% repeat-x; color: #222222; }
.price_slider_wrapper .ui-widget-header { border: 1px solid #aaaaaa; background: #cccccc url(../images/ui/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x; color: #222222; font-weight: bold; }
.ui-slider-horizontal { height: .8em; }
.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; }
.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
.ui-slider-horizontal .ui-slider-range-min { left: 0; }
.ui-slider-horizontal .ui-slider-range-max { right: 0; }

BIN
assets/images/add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

BIN
assets/images/calendar.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/images/cross.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

BIN
assets/images/edit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

BIN
assets/images/error.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

BIN
assets/images/fancybox/blank.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 911 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
assets/images/jigoshop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
assets/images/jigowatt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
assets/images/minus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

BIN
assets/images/placeholder.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
assets/images/remove.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

BIN
assets/images/star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

BIN
assets/images/success.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 B

BIN
assets/images/tip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,153 @@
/*!
jQuery blockUI plugin
Version 2.37 (29-JAN-2011)
@requires jQuery v1.2.3 or later
Examples at: http://malsup.com/jquery/block/
Copyright (c) 2007-2010 M. Alsup
Dual licensed under the MIT and GPL licenses:
http://www.opensource.org/licenses/mit-license.php
http://www.gnu.org/licenses/gpl.html
Thanks to Amir-Hossein Sobhi for some excellent contributions!
*/
;(function($){if(/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery)||/^1.1/.test($.fn.jquery)){alert('blockUI requires jQuery v1.2.3 or later! You are using v'+$.fn.jquery);return;}
$.fn._fadeIn=$.fn.fadeIn;var noOp=function(){};var mode=document.documentMode||0;var setExpr=$.browser.msie&&(($.browser.version<8&&!mode)||mode<8);var ie6=$.browser.msie&&/MSIE 6.0/.test(navigator.userAgent)&&!mode;$.blockUI=function(opts){install(window,opts);};$.unblockUI=function(opts){remove(window,opts);};$.growlUI=function(title,message,timeout,onClose){var $m=$('<div class="growlUI"></div>');if(title)$m.append('<h1>'+title+'</h1>');if(message)$m.append('<h2>'+message+'</h2>');if(timeout==undefined)timeout=3000;$.blockUI({message:$m,fadeIn:700,fadeOut:1000,centerY:false,timeout:timeout,showOverlay:false,onUnblock:onClose,css:$.blockUI.defaults.growlCSS});};$.fn.block=function(opts){return this.unblock({fadeOut:0}).each(function(){if($.css(this,'position')=='static')
this.style.position='relative';if($.browser.msie)
this.style.zoom=1;install(this,opts);});};$.fn.unblock=function(opts){return this.each(function(){remove(this,opts);});};$.blockUI.version=2.37;$.blockUI.defaults={message:'<h1>Please wait...</h1>',title:null,draggable:true,theme:false,css:{padding:0,margin:0,width:'30%',top:'40%',left:'35%',textAlign:'center',color:'#000',border:'3px solid #aaa',backgroundColor:'#fff',cursor:'wait'},themedCSS:{width:'30%',top:'40%',left:'35%'},overlayCSS:{backgroundColor:'#000',opacity:0.6,cursor:'wait'},growlCSS:{width:'350px',top:'10px',left:'',right:'10px',border:'none',padding:'5px',opacity:0.6,cursor:'default',color:'#fff',backgroundColor:'#000','-webkit-border-radius':'10px','-moz-border-radius':'10px','border-radius':'10px'},iframeSrc:/^https/i.test(window.location.href||'')?'javascript:false':'about:blank',forceIframe:false,baseZ:1000,centerX:true,centerY:true,allowBodyStretch:true,bindEvents:true,constrainTabKey:true,fadeIn:200,fadeOut:400,timeout:0,showOverlay:true,focusInput:true,applyPlatformOpacityRules:true,onBlock:null,onUnblock:null,quirksmodeOffsetHack:4,blockMsgClass:'blockMsg'};var pageBlock=null;var pageBlockEls=[];function install(el,opts){var full=(el==window);var msg=opts&&opts.message!==undefined?opts.message:undefined;opts=$.extend({},$.blockUI.defaults,opts||{});opts.overlayCSS=$.extend({},$.blockUI.defaults.overlayCSS,opts.overlayCSS||{});var css=$.extend({},$.blockUI.defaults.css,opts.css||{});var themedCSS=$.extend({},$.blockUI.defaults.themedCSS,opts.themedCSS||{});msg=msg===undefined?opts.message:msg;if(full&&pageBlock)
remove(window,{fadeOut:0});if(msg&&typeof msg!='string'&&(msg.parentNode||msg.jquery)){var node=msg.jquery?msg[0]:msg;var data={};$(el).data('blockUI.history',data);data.el=node;data.parent=node.parentNode;data.display=node.style.display;data.position=node.style.position;if(data.parent)
data.parent.removeChild(node);}
var z=opts.baseZ;var lyr1=($.browser.msie||opts.forceIframe)?$('<iframe class="blockUI" style="z-index:'+(z++)+';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>'):$('<div class="blockUI" style="display:none"></div>');var lyr2=$('<div class="blockUI blockOverlay" style="z-index:'+(z++)+';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');var lyr3,s;if(opts.theme&&full){s='<div class="blockUI '+opts.blockMsgClass+' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+z+';display:none;position:fixed">'+'<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title||'&nbsp;')+'</div>'+'<div class="ui-widget-content ui-dialog-content"></div>'+'</div>';}
else if(opts.theme){s='<div class="blockUI '+opts.blockMsgClass+' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+z+';display:none;position:absolute">'+'<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title||'&nbsp;')+'</div>'+'<div class="ui-widget-content ui-dialog-content"></div>'+'</div>';}
else if(full){s='<div class="blockUI '+opts.blockMsgClass+' blockPage" style="z-index:'+z+';display:none;position:fixed"></div>';}
else{s='<div class="blockUI '+opts.blockMsgClass+' blockElement" style="z-index:'+z+';display:none;position:absolute"></div>';}
lyr3=$(s);if(msg){if(opts.theme){lyr3.css(themedCSS);lyr3.addClass('ui-widget-content');}
else
lyr3.css(css);}
if(!opts.applyPlatformOpacityRules||!($.browser.mozilla&&/Linux/.test(navigator.platform)))
lyr2.css(opts.overlayCSS);lyr2.css('position',full?'fixed':'absolute');if($.browser.msie||opts.forceIframe)
lyr1.css('opacity',0.0);var layers=[lyr1,lyr2,lyr3],$par=full?$('body'):$(el);$.each(layers,function(){this.appendTo($par);});if(opts.theme&&opts.draggable&&$.fn.draggable){lyr3.draggable({handle:'.ui-dialog-titlebar',cancel:'li'});}
var expr=setExpr&&(!$.boxModel||$('object,embed',full?null:el).length>0);if(ie6||expr){if(full&&opts.allowBodyStretch&&$.boxModel)
$('html,body').css('height','100%');if((ie6||!$.boxModel)&&!full){var t=sz(el,'borderTopWidth'),l=sz(el,'borderLeftWidth');var fixT=t?'(0 - '+t+')':0;var fixL=l?'(0 - '+l+')':0;}
$.each([lyr1,lyr2,lyr3],function(i,o){var s=o[0].style;s.position='absolute';if(i<2){full?s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"'):s.setExpression('height','this.parentNode.offsetHeight + "px"');full?s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'):s.setExpression('width','this.parentNode.offsetWidth + "px"');if(fixL)s.setExpression('left',fixL);if(fixT)s.setExpression('top',fixT);}
else if(opts.centerY){if(full)s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');s.marginTop=0;}
else if(!opts.centerY&&full){var top=(opts.css&&opts.css.top)?parseInt(opts.css.top):0;var expression='((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';s.setExpression('top',expression);}});}
if(msg){if(opts.theme)
lyr3.find('.ui-widget-content').append(msg);else
lyr3.append(msg);if(msg.jquery||msg.nodeType)
$(msg).show();}
if(($.browser.msie||opts.forceIframe)&&opts.showOverlay)
lyr1.show();if(opts.fadeIn){var cb=opts.onBlock?opts.onBlock:noOp;var cb1=(opts.showOverlay&&!msg)?cb:noOp;var cb2=msg?cb:noOp;if(opts.showOverlay)
lyr2._fadeIn(opts.fadeIn,cb1);if(msg)
lyr3._fadeIn(opts.fadeIn,cb2);}
else{if(opts.showOverlay)
lyr2.show();if(msg)
lyr3.show();if(opts.onBlock)
opts.onBlock();}
bind(1,el,opts);if(full){pageBlock=lyr3[0];pageBlockEls=$(':input:enabled:visible',pageBlock);if(opts.focusInput)
setTimeout(focus,20);}
else
center(lyr3[0],opts.centerX,opts.centerY);if(opts.timeout){var to=setTimeout(function(){full?$.unblockUI(opts):$(el).unblock(opts);},opts.timeout);$(el).data('blockUI.timeout',to);}};function remove(el,opts){var full=(el==window);var $el=$(el);var data=$el.data('blockUI.history');var to=$el.data('blockUI.timeout');if(to){clearTimeout(to);$el.removeData('blockUI.timeout');}
opts=$.extend({},$.blockUI.defaults,opts||{});bind(0,el,opts);var els;if(full)
els=$('body').children().filter('.blockUI').add('body > .blockUI');else
els=$('.blockUI',el);if(full)
pageBlock=pageBlockEls=null;if(opts.fadeOut){els.fadeOut(opts.fadeOut);setTimeout(function(){reset(els,data,opts,el);},opts.fadeOut);}
else
reset(els,data,opts,el);};function reset(els,data,opts,el){els.each(function(i,o){if(this.parentNode)
this.parentNode.removeChild(this);});if(data&&data.el){data.el.style.display=data.display;data.el.style.position=data.position;if(data.parent)
data.parent.appendChild(data.el);$(el).removeData('blockUI.history');}
if(typeof opts.onUnblock=='function')
opts.onUnblock(el,opts);};function bind(b,el,opts){var full=el==window,$el=$(el);if(!b&&(full&&!pageBlock||!full&&!$el.data('blockUI.isBlocked')))
return;if(!full)
$el.data('blockUI.isBlocked',b);if(!opts.bindEvents||(b&&!opts.showOverlay))
return;var events='mousedown mouseup keydown keypress';b?$(document).bind(events,opts,handler):$(document).unbind(events,handler);};function handler(e){if(e.keyCode&&e.keyCode==9){if(pageBlock&&e.data.constrainTabKey){var els=pageBlockEls;var fwd=!e.shiftKey&&e.target===els[els.length-1];var back=e.shiftKey&&e.target===els[0];if(fwd||back){setTimeout(function(){focus(back)},10);return false;}}}
var opts=e.data;if($(e.target).parents('div.'+opts.blockMsgClass).length>0)
return true;return $(e.target).parents().children().filter('div.blockUI').length==0;};function focus(back){if(!pageBlockEls)
return;var e=pageBlockEls[back===true?pageBlockEls.length-1:0];if(e)
e.focus();};function center(el,x,y){var p=el.parentNode,s=el.style;var l=((p.offsetWidth-el.offsetWidth)/2)-sz(p,'borderLeftWidth');var t=((p.offsetHeight-el.offsetHeight)/2)-sz(p,'borderTopWidth');if(x)s.left=l>0?(l+'px'):'0';if(y)s.top=t>0?(t+'px'):'0';};function sz(el,p){return parseInt($.css(el,p))||0;};})(jQuery);
/**
* jQuery Cookie plugin
*
* Copyright (c) 2010 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
jQuery.cookie=function(key,value,options){if(arguments.length>1&&String(value)!=="[object Object]"){options=jQuery.extend({},options);if(value===null||value===undefined){options.expires=-1;}
if(typeof options.expires==='number'){var days=options.expires,t=options.expires=new Date();t.setDate(t.getDate()+days);}
value=String(value);return(document.cookie=[encodeURIComponent(key),'=',options.raw?value:encodeURIComponent(value),options.expires?'; expires='+options.expires.toUTCString():'',options.path?'; path='+options.path:'',options.domain?'; domain='+options.domain:'',options.secure?'; secure':''].join(''));}
options=value||{};var result,decode=options.raw?function(s){return s;}:decodeURIComponent;return(result=new RegExp('(?:^|; )'+encodeURIComponent(key)+'=([^;]*)').exec(document.cookie))?decode(result[1]):null;};
/*
* Date prototype extensions. Doesn't depend on any
* other code. Doens't overwrite existing methods.
*
* Adds dayNames, abbrDayNames, monthNames and abbrMonthNames static properties and isLeapYear,
* isWeekend, isWeekDay, getDaysInMonth, getDayName, getMonthName, getDayOfYear, getWeekOfYear,
* setDayOfYear, addYears, addMonths, addDays, addHours, addMinutes, addSeconds methods
*
* Copyright (c) 2006 Jšrn Zaefferer and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
*
* Additional methods and properties added by Kelvin Luck: firstDayOfWeek, dateFormat, zeroTime, asString, fromString -
* I've added my name to these methods so you know who to blame if they are broken!
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
Date.dayNames=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];Date.abbrDayNames=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];Date.monthNames=['January','February','March','April','May','June','July','August','September','October','November','December'];Date.abbrMonthNames=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];Date.firstDayOfWeek=1;Date.format='dd/mm/yyyy';Date.fullYearStart='20';(function(){function add(name,method){if(!Date.prototype[name]){Date.prototype[name]=method;}};add("isLeapYear",function(){var y=this.getFullYear();return(y%4==0&&y%100!=0)||y%400==0;});add("isWeekend",function(){return this.getDay()==0||this.getDay()==6;});add("isWeekDay",function(){return!this.isWeekend();});add("getDaysInMonth",function(){return[31,(this.isLeapYear()?29:28),31,30,31,30,31,31,30,31,30,31][this.getMonth()];});add("getDayName",function(abbreviated){return abbreviated?Date.abbrDayNames[this.getDay()]:Date.dayNames[this.getDay()];});add("getMonthName",function(abbreviated){return abbreviated?Date.abbrMonthNames[this.getMonth()]:Date.monthNames[this.getMonth()];});add("getDayOfYear",function(){var tmpdtm=new Date("1/1/"+this.getFullYear());return Math.floor((this.getTime()-tmpdtm.getTime())/86400000);});add("getWeekOfYear",function(){return Math.ceil(this.getDayOfYear()/7);});add("setDayOfYear",function(day){this.setMonth(0);this.setDate(day);return this;});add("addYears",function(num){this.setFullYear(this.getFullYear()+num);return this;});add("addMonths",function(num){var tmpdtm=this.getDate();this.setMonth(this.getMonth()+num);if(tmpdtm>this.getDate())
this.addDays(-this.getDate());return this;});add("addDays",function(num){this.setTime(this.getTime()+(num*86400000));return this;});add("addHours",function(num){this.setHours(this.getHours()+num);return this;});add("addMinutes",function(num){this.setMinutes(this.getMinutes()+num);return this;});add("addSeconds",function(num){this.setSeconds(this.getSeconds()+num);return this;});add("zeroTime",function(){this.setMilliseconds(0);this.setSeconds(0);this.setMinutes(0);this.setHours(0);return this;});add("asString",function(format){var r=format||Date.format;return r.split('yyyy').join(this.getFullYear()).split('yy').join((this.getFullYear()+'').substring(2)).split('mmmm').join(this.getMonthName(false)).split('mmm').join(this.getMonthName(true)).split('mm').join(_zeroPad(this.getMonth()+1)).split('dd').join(_zeroPad(this.getDate())).split('hh').join(_zeroPad(this.getHours())).split('min').join(_zeroPad(this.getMinutes())).split('ss').join(_zeroPad(this.getSeconds()));});Date.fromString=function(s,format)
{var f=format||Date.format;var d=new Date('01/01/1977');var mLength=0;var iM=f.indexOf('mmmm');if(iM>-1){for(var i=0;i<Date.monthNames.length;i++){var mStr=s.substr(iM,Date.monthNames[i].length);if(Date.monthNames[i]==mStr){mLength=Date.monthNames[i].length-4;break;}}
d.setMonth(i);}else{iM=f.indexOf('mmm');if(iM>-1){var mStr=s.substr(iM,3);for(var i=0;i<Date.abbrMonthNames.length;i++){if(Date.abbrMonthNames[i]==mStr)break;}
d.setMonth(i);}else{d.setMonth(Number(s.substr(f.indexOf('mm'),2))-1);}}
var iY=f.indexOf('yyyy');if(iY>-1){if(iM<iY)
{iY+=mLength;}
d.setFullYear(Number(s.substr(iY,4)));}else{if(iM<iY)
{iY+=mLength;}
d.setFullYear(Number(Date.fullYearStart+s.substr(f.indexOf('yy'),2)));}
var iD=f.indexOf('dd');if(iM<iD)
{iD+=mLength;}
d.setDate(Number(s.substr(iD,2)));if(isNaN(d.getTime())){return false;}
return d;};var _zeroPad=function(num){var s='0'+num;return s.substring(s.length-2)};})();
/*
* Easy Tooltip 1.0 - jQuery plugin
* written by Alen Grakalic
* http://cssglobe.com/post/4380/easy-tooltip--jquery-plugin
*
* Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
*/
(function($){$.fn.easyTooltip=function(options){var defaults={xOffset:10,yOffset:25,tooltipId:"easyTooltip",clickRemove:false,content:"",useElement:""};var options=$.extend(defaults,options);var content;this.each(function(){var title=$(this).attr("tip");$(this).hover(function(e){content=(options.content!="")?options.content:title;content=(options.useElement!="")?$("#"+options.useElement).html():content;$(this).attr("title","");if(content!=""&&content!=undefined){$("body").append("<div id='"+options.tooltipId+"'>"+content+"</div>");$("#"+options.tooltipId).css("position","absolute").css("top",(e.pageY-options.yOffset)+"px").css("left",(e.pageX+options.xOffset)+"px").css("display","none").fadeIn("fast")}},function(){$("#"+options.tooltipId).remove();$(this).attr("title",title)});$(this).mousemove(function(e){$("#"+options.tooltipId).css("top",(e.pageY-options.yOffset)+"px").css("left",(e.pageX+options.xOffset)+"px")});if(options.clickRemove){$(this).mousedown(function(e){$("#"+options.tooltipId).remove();$(this).attr("title",title)})}})}})(jQuery);
jQuery(function(){
jQuery(".tips").easyTooltip();
});
/**
* Spoofs placeholders in browsers that don't support them (eg Firefox 3)
*
* Copyright 2011 Dan Bentley
* Licensed under the Apache License 2.0
*
* Author: Dan Bentley [github.com/danbentley]
*/
(function($){if("placeholder"in document.createElement("input"))return;$(document).ready(function(){$(':input[placeholder]').each(function(){setupPlaceholder($(this));});$('form').submit(function(e){clearPlaceholdersBeforeSubmit($(this));});});function setupPlaceholder(input){var placeholderText=input.attr('placeholder');if(input.val()==='')input.val(placeholderText);input.bind({focus:function(e){if(input.val()===placeholderText)input.val('');},blur:function(e){if(input.val()==='')input.val(placeholderText);}});}
function clearPlaceholdersBeforeSubmit(form){form.find(':input[placeholder]').each(function(){var el=$(this);if(el.val()===el.attr('placeholder'))el.val('');});}})(jQuery);
/**
* jQuery.ScrollTo - Easy element scrolling using jQuery.
* Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* Date: 5/25/2009
* @author Ariel Flesler
* @version 1.4.2
*
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
*/
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

View File

@ -0,0 +1,46 @@
/*
* FancyBox - jQuery Plugin
* Simple and fancy lightbox alternative
*
* Examples and documentation at: http://fancybox.net
*
* Copyright (c) 2008 - 2010 Janis Skarnelis
* That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
*
* Version: 1.3.4 (11/11/2010)
* Requires: jQuery v1.3+
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
;(function(b){var m,t,u,f,D,j,E,n,z,A,q=0,e={},o=[],p=0,d={},l=[],G=null,v=new Image,J=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,W=/[^\.]\.(swf)\s*$/i,K,L=1,y=0,s="",r,i,h=false,B=b.extend(b("<div/>")[0],{prop:0}),M=b.browser.msie&&b.browser.version<7&&!window.XMLHttpRequest,N=function(){t.hide();v.onerror=v.onload=null;G&&G.abort();m.empty()},O=function(){if(false===e.onError(o,q,e)){t.hide();h=false}else{e.titleShow=false;e.width="auto";e.height="auto";m.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');
F()}},I=function(){var a=o[q],c,g,k,C,P,w;N();e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));w=e.onStart(o,q,e);if(w===false)h=false;else{if(typeof w=="object")e=b.extend(e,w);k=e.title||(a.nodeName?b(a).attr("title"):a.title)||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(k===""&&e.orig&&e.titleFromAlt)k=e.orig.attr("alt");c=e.href||(a.nodeName?b(a).attr("href"):a.href)||null;if(/^(?:javascript)/i.test(c)||
c=="#")c=null;if(e.type){g=e.type;if(!c)c=e.content}else if(e.content)g="html";else if(c)g=c.match(J)?"image":c.match(W)?"swf":b(a).hasClass("iframe")?"iframe":c.indexOf("#")===0?"inline":"ajax";if(g){if(g=="inline"){a=c.substr(c.indexOf("#"));g=b(a).length>0?"inline":"ajax"}e.type=g;e.href=c;e.title=k;if(e.autoDimensions)if(e.type=="html"||e.type=="inline"||e.type=="ajax"){e.width="auto";e.height="auto"}else e.autoDimensions=false;if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=
false;e.enableEscapeButton=false;e.showCloseButton=false}e.padding=parseInt(e.padding,10);e.margin=parseInt(e.margin,10);m.css("padding",e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(j.children())});switch(g){case "html":m.html(e.content);F();break;case "inline":if(b(a).parent().is("#fancybox-content")===true){h=false;break}b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(j.children())}).bind("fancybox-cancel",
function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();v=new Image;v.onerror=function(){O()};v.onload=function(){h=true;v.onerror=v.onload=null;e.width=v.width;e.height=v.height;b("<img />").attr({id:"fancybox-img",src:v.src,alt:e.title}).appendTo(m);Q()};v.src=c;break;case "swf":e.scrolling="no";C='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+c+
'"></param>';P="";b.each(e.swf,function(x,H){C+='<param name="'+x+'" value="'+H+'"></param>';P+=" "+x+'="'+H+'"'});C+='<embed src="'+c+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+P+"></embed></object>";m.html(C);F();break;case "ajax":h=false;b.fancybox.showActivity();e.ajax.win=e.ajax.success;G=b.ajax(b.extend({},e.ajax,{url:c,data:e.ajax.data||{},error:function(x){x.status>0&&O()},success:function(x,H,R){if((typeof R=="object"?R:G).status==200){if(typeof e.ajax.win==
"function"){w=e.ajax.win(c,x,H,R);if(w===false){t.hide();return}else if(typeof w=="string"||typeof w=="object")x=w}m.html(x);F()}}}));break;case "iframe":Q()}}else O()}},F=function(){var a=e.width,c=e.height;a=a.toString().indexOf("%")>-1?parseInt((b(window).width()-e.margin*2)*parseFloat(a)/100,10)+"px":a=="auto"?"auto":a+"px";c=c.toString().indexOf("%")>-1?parseInt((b(window).height()-e.margin*2)*parseFloat(c)/100,10)+"px":c=="auto"?"auto":c+"px";m.wrapInner('<div style="width:'+a+";height:"+c+
";overflow: "+(e.scrolling=="auto"?"auto":e.scrolling=="yes"?"scroll":"hidden")+';position:relative;"></div>');e.width=m.width();e.height=m.height();Q()},Q=function(){var a,c;t.hide();if(f.is(":visible")&&false===d.onCleanup(l,p,d)){b.event.trigger("fancybox-cancel");h=false}else{h=true;b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");f.is(":visible")&&d.titlePosition!=="outside"&&f.css("height",f.height());l=o;p=q;d=e;if(d.overlayShow){u.css({"background-color":d.overlayColor,
opacity:d.overlayOpacity,cursor:d.hideOnOverlayClick?"pointer":"auto",height:b(document).height()});if(!u.is(":visible")){M&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});u.show()}}else u.hide();i=X();s=d.title||"";y=0;n.empty().removeAttr("style").removeClass();if(d.titleShow!==false){if(b.isFunction(d.titleFormat))a=d.titleFormat(s,l,p,d);else a=s&&s.length?
d.titlePosition=="float"?'<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+s+'</td><td id="fancybox-title-float-right"></td></tr></table>':'<div id="fancybox-title-'+d.titlePosition+'">'+s+"</div>":false;s=a;if(!(!s||s==="")){n.addClass("fancybox-title-"+d.titlePosition).html(s).appendTo("body").show();switch(d.titlePosition){case "inside":n.css({width:i.width-d.padding*2,marginLeft:d.padding,marginRight:d.padding});
y=n.outerHeight(true);n.appendTo(D);i.height+=y;break;case "over":n.css({marginLeft:d.padding,width:i.width-d.padding*2,bottom:d.padding}).appendTo(D);break;case "float":n.css("left",parseInt((n.width()-i.width-40)/2,10)*-1).appendTo(f);break;default:n.css({width:i.width-d.padding*2,paddingLeft:d.padding,paddingRight:d.padding}).appendTo(f)}}}n.hide();if(f.is(":visible")){b(E.add(z).add(A)).hide();a=f.position();r={top:a.top,left:a.left,width:f.width(),height:f.height()};c=r.width==i.width&&r.height==
i.height;j.fadeTo(d.changeFade,0.3,function(){var g=function(){j.html(m.contents()).fadeTo(d.changeFade,1,S)};b.event.trigger("fancybox-change");j.empty().removeAttr("filter").css({"border-width":d.padding,width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2});if(c)g();else{B.prop=0;b(B).animate({prop:1},{duration:d.changeSpeed,easing:d.easingChange,step:T,complete:g})}})}else{f.removeAttr("style");j.css("border-width",d.padding);if(d.transitionIn=="elastic"){r=V();j.html(m.contents());
f.show();if(d.opacity)i.opacity=0;B.prop=0;b(B).animate({prop:1},{duration:d.speedIn,easing:d.easingIn,step:T,complete:S})}else{d.titlePosition=="inside"&&y>0&&n.show();j.css({width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2}).html(m.contents());f.css(i).fadeIn(d.transitionIn=="none"?0:d.speedIn,S)}}}},Y=function(){if(d.enableEscapeButton||d.enableKeyboardNav)b(document).bind("keydown.fb",function(a){if(a.keyCode==27&&d.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if((a.keyCode==
37||a.keyCode==39)&&d.enableKeyboardNav&&a.target.tagName!=="INPUT"&&a.target.tagName!=="TEXTAREA"&&a.target.tagName!=="SELECT"){a.preventDefault();b.fancybox[a.keyCode==37?"prev":"next"]()}});if(d.showNavArrows){if(d.cyclic&&l.length>1||p!==0)z.show();if(d.cyclic&&l.length>1||p!=l.length-1)A.show()}else{z.hide();A.hide()}},S=function(){if(!b.support.opacity){j.get(0).style.removeAttribute("filter");f.get(0).style.removeAttribute("filter")}e.autoDimensions&&j.css("height","auto");f.css("height","auto");
s&&s.length&&n.show();d.showCloseButton&&E.show();Y();d.hideOnContentClick&&j.bind("click",b.fancybox.close);d.hideOnOverlayClick&&u.bind("click",b.fancybox.close);b(window).bind("resize.fb",b.fancybox.resize);d.centerOnScroll&&b(window).bind("scroll.fb",b.fancybox.center);if(d.type=="iframe")b('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" '+(b.browser.msie?'allowtransparency="true""':"")+' scrolling="'+e.scrolling+'" src="'+d.href+'"></iframe>').appendTo(j);
f.show();h=false;b.fancybox.center();d.onComplete(l,p,d);var a,c;if(l.length-1>p){a=l[p+1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}if(p>0){a=l[p-1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}},T=function(a){var c={width:parseInt(r.width+(i.width-r.width)*a,10),height:parseInt(r.height+(i.height-r.height)*a,10),top:parseInt(r.top+(i.top-r.top)*a,10),left:parseInt(r.left+(i.left-r.left)*a,10)};if(typeof i.opacity!=="undefined")c.opacity=a<0.5?0.5:a;f.css(c);
j.css({width:c.width-d.padding*2,height:c.height-y*a-d.padding*2})},U=function(){return[b(window).width()-d.margin*2,b(window).height()-d.margin*2,b(document).scrollLeft()+d.margin,b(document).scrollTop()+d.margin]},X=function(){var a=U(),c={},g=d.autoScale,k=d.padding*2;c.width=d.width.toString().indexOf("%")>-1?parseInt(a[0]*parseFloat(d.width)/100,10):d.width+k;c.height=d.height.toString().indexOf("%")>-1?parseInt(a[1]*parseFloat(d.height)/100,10):d.height+k;if(g&&(c.width>a[0]||c.height>a[1]))if(e.type==
"image"||e.type=="swf"){g=d.width/d.height;if(c.width>a[0]){c.width=a[0];c.height=parseInt((c.width-k)/g+k,10)}if(c.height>a[1]){c.height=a[1];c.width=parseInt((c.height-k)*g+k,10)}}else{c.width=Math.min(c.width,a[0]);c.height=Math.min(c.height,a[1])}c.top=parseInt(Math.max(a[3]-20,a[3]+(a[1]-c.height-40)*0.5),10);c.left=parseInt(Math.max(a[2]-20,a[2]+(a[0]-c.width-40)*0.5),10);return c},V=function(){var a=e.orig?b(e.orig):false,c={};if(a&&a.length){c=a.offset();c.top+=parseInt(a.css("paddingTop"),
10)||0;c.left+=parseInt(a.css("paddingLeft"),10)||0;c.top+=parseInt(a.css("border-top-width"),10)||0;c.left+=parseInt(a.css("border-left-width"),10)||0;c.width=a.width();c.height=a.height();c={width:c.width+d.padding*2,height:c.height+d.padding*2,top:c.top-d.padding-20,left:c.left-d.padding-20}}else{a=U();c={width:d.padding*2,height:d.padding*2,top:parseInt(a[3]+a[1]*0.5,10),left:parseInt(a[2]+a[0]*0.5,10)}}return c},Z=function(){if(t.is(":visible")){b("div",t).css("top",L*-40+"px");L=(L+1)%12}else clearInterval(K)};
b.fn.fancybox=function(a){if(!b(this).length)return this;b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(c){c.preventDefault();if(!h){h=true;b(this).blur();o=[];q=0;c=b(this).attr("rel")||"";if(!c||c==""||c==="nofollow")o.push(this);else{o=b("a[rel="+c+"], area[rel="+c+"]");q=o.index(this)}I()}});return this};b.fancybox=function(a,c){var g;if(!h){h=true;g=typeof c!=="undefined"?c:{};o=[];q=parseInt(g.index,10)||0;if(b.isArray(a)){for(var k=
0,C=a.length;k<C;k++)if(typeof a[k]=="object")b(a[k]).data("fancybox",b.extend({},g,a[k]));else a[k]=b({}).data("fancybox",b.extend({content:a[k]},g));o=jQuery.merge(o,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},g,a));else a=b({}).data("fancybox",b.extend({content:a},g));o.push(a)}if(q>o.length||q<0)q=0;I()}};b.fancybox.showActivity=function(){clearInterval(K);t.show();K=setInterval(Z,66)};b.fancybox.hideActivity=function(){t.hide()};b.fancybox.next=function(){return b.fancybox.pos(p+
1)};b.fancybox.prev=function(){return b.fancybox.pos(p-1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a);o=l;if(a>-1&&a<l.length){q=a;I()}else if(d.cyclic&&l.length>1){q=a>=l.length?0:l.length-1;I()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");N();e.onCancel(o,q,e);h=false}};b.fancybox.close=function(){function a(){u.fadeOut("fast");n.empty().hide();f.hide();b.event.trigger("fancybox-cleanup");j.empty();d.onClosed(l,p,d);l=e=[];p=q=0;d=e={};h=false}if(!(h||f.is(":hidden"))){h=
true;if(d&&false===d.onCleanup(l,p,d))h=false;else{N();b(E.add(z).add(A)).hide();b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");j.find("iframe").attr("src",M&&/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank");d.titlePosition!=="inside"&&n.empty();f.stop();if(d.transitionOut=="elastic"){r=V();var c=f.position();i={top:c.top,left:c.left,width:f.width(),height:f.height()};if(d.opacity)i.opacity=1;n.empty().hide();B.prop=1;
b(B).animate({prop:0},{duration:d.speedOut,easing:d.easingOut,step:T,complete:a})}else f.fadeOut(d.transitionOut=="none"?0:d.speedOut,a)}}};b.fancybox.resize=function(){u.is(":visible")&&u.css("height",b(document).height());b.fancybox.center(true)};b.fancybox.center=function(a){var c,g;if(!h){g=a===true?1:0;c=U();!g&&(f.width()>c[0]||f.height()>c[1])||f.stop().animate({top:parseInt(Math.max(c[3]-20,c[3]+(c[1]-j.height()-40)*0.5-d.padding)),left:parseInt(Math.max(c[2]-20,c[2]+(c[0]-j.width()-40)*0.5-
d.padding))},typeof a=="number"?a:200)}};b.fancybox.init=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('<div id="fancybox-tmp"></div>'),t=b('<div id="fancybox-loading"><div></div></div>'),u=b('<div id="fancybox-overlay"></div>'),f=b('<div id="fancybox-wrap"></div>'));D=b('<div id="fancybox-outer"></div>').append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>').appendTo(f);
D.append(j=b('<div id="fancybox-content"></div>'),E=b('<a id="fancybox-close"></a>'),n=b('<div id="fancybox-title"></div>'),z=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),A=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));E.click(b.fancybox.close);t.click(b.fancybox.cancel);z.click(function(a){a.preventDefault();b.fancybox.prev()});A.click(function(a){a.preventDefault();b.fancybox.next()});
b.fn.mousewheel&&f.bind("mousewheel.fb",function(a,c){if(h)a.preventDefault();else if(b(a.target).get(0).clientHeight==0||b(a.target).get(0).scrollHeight===b(a.target).get(0).clientHeight){a.preventDefault();b.fancybox[c>0?"prev":"next"]()}});b.support.opacity||f.addClass("fancybox-ie");if(M){t.addClass("fancybox-ie6");f.addClass("fancybox-ie6");b('<iframe id="fancybox-hide-sel-frame" src="'+(/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank")+'" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(D)}}};
b.fn.fancybox.defaults={padding:10,margin:40,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.7,overlayColor:"#777",titleShow:true,titlePosition:"float",titleFormat:null,titleFromAlt:false,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing",
easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,enableKeyboardNav:true,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},onClosed:function(){},onError:function(){}};b(document).ready(function(){b.fancybox.init()})})(jQuery);

350
assets/js/script.js Executable file
View File

@ -0,0 +1,350 @@
jQuery.fn.animateHighlight = function(highlightColor, duration) {
var highlightBg = highlightColor || "#FFFF9C";
var animateMs = duration || 1500;
var originalBg = this.css("backgroundColor");
this.stop().css("background-color", highlightBg).animate({backgroundColor: originalBg}, animateMs);
};
jQuery(function(){
// Lightbox
jQuery('a.zoom').fancybox({
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'speedIn' : 600,
'speedOut' : 200,
'overlayShow' : true
});
// Star ratings
jQuery('#rating').hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>');
jQuery('p.stars a').click(function(){
jQuery('#rating').val(jQuery(this).text());
jQuery('p.stars a').removeClass('active');
jQuery(this).addClass('active');
return false;
});
// Price slider
var min_price = jQuery('.price_slider_amount #min_price').val();
var max_price = jQuery('.price_slider_amount #max_price').val();
if (params.min_price) {
current_min_price = params.min_price;
} else {
current_min_price = min_price;
}
if (params.max_price) {
current_max_price = params.max_price;
} else {
current_max_price = max_price;
}
jQuery('.price_slider').slider({
range: true,
min: min_price,
max: max_price,
values: [ current_min_price, current_max_price ],
create : function( event, ui ) {
jQuery( ".price_slider_amount span" ).html( params.currency_symbol + current_min_price + " - " + params.currency_symbol + current_max_price );
jQuery( ".price_slider_amount #min_price" ).val(current_min_price);
jQuery( ".price_slider_amount #max_price" ).val(current_max_price);
},
slide: function( event, ui ) {
jQuery( ".price_slider_amount span" ).html( params.currency_symbol + ui.values[ 0 ] + " - " + params.currency_symbol + ui.values[ 1 ] );
jQuery( "input#min_price" ).val(ui.values[ 0 ]);
jQuery( "input#max_price" ).val(ui.values[ 1 ]);
}
});
// Quantity buttons
jQuery("div.quantity, td.quantity").append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');
jQuery(".plus").click(function()
{
var currentVal = parseInt(jQuery(this).prev(".qty").val());
if (!currentVal || currentVal=="" || currentVal == "NaN") currentVal = 0;
jQuery(this).prev(".qty").val(currentVal + 1);
});
jQuery(".minus").click(function()
{
var currentVal = parseInt(jQuery(this).next(".qty").val());
if (currentVal == "NaN") currentVal = 0;
if (currentVal > 0)
{
jQuery(this).next(".qty").val(currentVal - 1);
}
});
/* states */
var states_json = params.countries.replace(/&quot;/g, '"');
var states = jQuery.parseJSON( states_json );
jQuery('select.country_to_state').change(function(){
var country = jQuery(this).val();
var state_box = jQuery('#' + jQuery(this).attr('rel'));
var input_name = jQuery(state_box).attr('name');
var input_id = jQuery(state_box).attr('id');
if (states[country]) {
var options = '';
var state = states[country];
for(var index in state) {
options = options + '<option value="' + index + '">' + state[index] + '</option>';
}
if (jQuery(state_box).is('input')) {
// Change for select
jQuery(state_box).replaceWith('<select name="' + input_name + '" id="' + input_id + '"><option value="">' + params.select_state_text + '</option></select>');
state_box = jQuery('#' + jQuery(this).attr('rel'));
}
jQuery(state_box).append(options);
} else {
if (jQuery(state_box).is('select')) {
jQuery(state_box).replaceWith('<input type="text" placeholder="' + params.state_text + '" name="' + input_name + '" id="' + input_id + '" />');
state_box = jQuery('#' + jQuery(this).attr('rel'));
}
}
}).change();
/* Tabs */
jQuery('#tabs .panel:not(#tabs .panel)').hide();
jQuery('#tabs li a').click(function(){
var href = jQuery(this).attr('href');
jQuery('#tabs li').removeClass('active');
jQuery('div.panel').hide();
jQuery('div' + href).show();
jQuery(this).parent().addClass('active');
jQuery.cookie('current_tab', href);
return false;
});
if (jQuery('#tabs li.active').size()==0) {
jQuery('#tabs li:first a').click();
} else {
jQuery('#tabs li.active a').click();
}
/* Shipping calculator */
jQuery('.shipping-calculator-form').hide();
jQuery('.shipping-calculator-button').click(function() {
jQuery('.shipping-calculator-form').slideToggle('slow', function() {
// Animation complete.
});
});
// Stop anchors moving the viewport
jQuery(".shipping-calculator-button").click(function() { return false; });
// Variations
function check_variations() {
var not_set = false;
jQuery('.variations select').each(function(){
if (jQuery(this).val()=="") not_set = true;
});
jQuery('.variations_button, .single_variation').slideUp();
if (!not_set) {
jQuery('.variations').block({ message: null, overlayCSS: { background: '#fff url(' + params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
var data = {
action: 'jigoshop_get_variation',
variation_data: jQuery('form.variations_form').serialize(),
security: params.get_variation_nonce
};
jQuery.post( params.ajax_url, data, function(response) {
var img = jQuery('div.images img:eq(0)');
var link = jQuery('div.images a.zoom');
var o_src = jQuery(img).attr('original-src');
var o_link = jQuery(link).attr('original-href');
if (response.length > 1) {
variation_response = jQuery.parseJSON( response );
var variation_image = variation_response.image_src;
var variation_link = variation_response.image_link;
jQuery('.single_variation').html( variation_response.price_html + variation_response.availability_html );
if (!o_src) {
jQuery(img).attr('original-src', jQuery(img).attr('src'));
}
if (!o_link) {
jQuery(link).attr('original-href', jQuery(link).attr('href'));
}
if (variation_image.length > 1) {
jQuery(img).attr('src', variation_image);
jQuery(link).attr('href', variation_link);
} else {
jQuery(img).attr('src', o_src);
jQuery(link).attr('href', o_link);
}
jQuery('.variations_button, .single_variation').slideDown();
} else {
if (o_src) {
jQuery(img).attr('src', o_src);
jQuery(link).attr('href', o_link);
}
jQuery('.single_variation').slideDown();
jQuery('.single_variation').html( '<p>' + params.variation_not_available_text + '</p>' );
}
jQuery('.variations').unblock();
});
} else {
jQuery('.variations_button').hide();
}
}
jQuery('.variations select').change(function(){
check_variations();
});
});
if (params.is_checkout==1) {
var updateTimer;
function update_checkout() {
var method = jQuery('#shipping_method').val();
var country = jQuery('#billing-country').val();
var state = jQuery('#billing-state').val();
var postcode = jQuery('input#billing-postcode').val();
if (jQuery('#shiptobilling input').is(':checked') || jQuery('#shiptobilling input').size()==0) {
var s_country = jQuery('#billing-country').val();
var s_state = jQuery('#billing-state').val();
var s_postcode = jQuery('input#billing-postcode').val();
} else {
var s_country = jQuery('#shipping-country').val();
var s_state = jQuery('#shipping-state').val();
var s_postcode = jQuery('input#shipping-postcode').val();
}
jQuery('#order_methods, #order_review').block({ message: null, overlayCSS: { background: '#fff url(' + params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
jQuery.ajax({
type: 'POST',
url: params.review_order_url,
data: { shipping_method: method, country: country, state: state, postcode: postcode, s_country: s_country, s_state: s_state, s_postcode: s_postcode },
success: function( code ) {
jQuery('#order_methods, #order_review').remove();
jQuery('#order_review_heading').after(code);
jQuery('#order_review input[name=payment_method]:checked').click();
},
dataType: "html"
});
}
jQuery(function(){
jQuery('p.password').hide();
jQuery('input.show_password').change(function(){
jQuery('p.password').slideToggle();
});
jQuery('div.shipping-address').hide();
jQuery('#shiptobilling input').change(function(){
jQuery('div.shipping-address').hide();
if (!jQuery(this).is(':checked')) {
jQuery('div.shipping-address').slideDown();
}
}).change();
if (params.option_guest_checkout=='yes') {
jQuery('div.create-account').hide();
jQuery('input#createaccount').change(function(){
jQuery('div.create-account').hide();
if (jQuery(this).is(':checked')) {
jQuery('div.create-account').slideDown();
}
}).change();
}
jQuery('.payment_methods input.input-radio').live('click', function(){
jQuery('div.payment_box').hide();
if (jQuery(this).is(':checked')) {
jQuery('div.payment_box.' + jQuery(this).attr('ID')).slideDown();
}
});
jQuery('#order_review input[name=payment_method]:checked').click();
jQuery('form.login').hide();
jQuery('a.showlogin').click(function(){
jQuery('form.login').slideToggle();
});
/* Update totals */
jQuery('#shipping_method').live('change', function(){
clearTimeout(updateTimer);
update_checkout();
}).change();
jQuery('input#billing-country, input#billing-state, #billing-postcode, input#shipping-country, input#shipping-state, #shipping-postcode').live('keydown', function(){
clearTimeout(updateTimer);
updateTimer = setTimeout("update_checkout()", '1000');
});
jQuery('select#billing-country, select#billing-state, select#shipping-country, select#shipping-state, #shiptobilling input').live('change', function(){
clearTimeout(updateTimer);
update_checkout();
});
/* AJAX Form Submission */
jQuery('form.checkout').submit(function(){
var form = this;
jQuery(form).block({ message: null, overlayCSS: { background: '#fff url(' + params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
jQuery.ajax({
type: 'POST',
url: params.checkout_url,
data: jQuery(form).serialize(),
success: function( code ) {
jQuery('.jigoshop_error, .jigoshop_message').remove();
try {
success = jQuery.parseJSON( code );
window.location = decodeURI(success.redirect);
}
catch(err) {
jQuery(form).prepend( code );
jQuery(form).unblock();
jQuery.scrollTo(jQuery(form).parent(), { easing:'swing' });
}
},
dataType: "html"
});
return false;
});
});
}

300
assets/js/write-panels.js Normal file
View File

@ -0,0 +1,300 @@
jQuery( function($){
// TABS
jQuery('ul.tabs').show();
jQuery('div.panel-wrap').each(function(){
jQuery('div.panel:not(div.panel:first)', this).hide();
});
jQuery('ul.tabs a').click(function(){
var panel_wrap = jQuery(this).closest('div.panel-wrap');
jQuery('ul.tabs li', panel_wrap).removeClass('active');
jQuery(this).parent().addClass('active');
jQuery('div.panel', panel_wrap).hide();
jQuery( jQuery(this).attr('href') ).show();
return false;
});
// ORDERS
jQuery('#order_items_list button.remove_row').live('click', function(){
var answer = confirm(params.remove_item_notice);
if (answer){
jQuery(this).parent().parent().remove();
}
return false;
});
jQuery('button.calc_totals').live('click', function(){
var answer = confirm(params.cart_total);
if (answer){
var item_count = jQuery('#order_items_list tr.item').size();
var subtotal = 0;
var discount = jQuery('input#order_discount').val();
var shipping = jQuery('input#order_shipping').val();
var shipping_tax = parseFloat(jQuery('input#order_shipping_tax').val());
var tax = 0;
var itemTotal = 0;
var total = 0;
if (!discount) discount = 0;
if (!shipping) shipping = 0;
if (!shipping_tax) shipping_tax = 0;
// Items
if (item_count>0) {
for (i=0; i<item_count; i++) {
itemCost = jQuery('input[name^=item_cost]:eq(' + i + ')').val();
itemQty = parseInt(jQuery('input[name^=item_quantity]:eq(' + i + ')').val());
itemTax = jQuery('input[name^=item_tax_rate]:eq(' + i + ')').val();
if (!itemCost) itemCost = 0;
if (!itemTax) itemTax = 0;
totalItemTax = 0;
totalItemCost = itemCost * itemQty;
if (itemTax && itemTax>0) {
//taxRate = Math.round( ((itemTax / 100) + 1) * 100)/100; // tax rate to 2 decimal places
taxRate = itemTax/100;
//totalItemTax = itemCost * taxRate;
itemCost = (itemCost * taxRate);
totalItemTax = Math.round(itemCost*Math.pow(10,2))/Math.pow(10,2);
alert(totalItemTax);
totalItemTax = totalItemTax * itemQty;
}
itemTotal = itemTotal + totalItemCost;
tax = tax + totalItemTax;
}
}
subtotal = itemTotal;
total = parseFloat(subtotal) + parseFloat(tax) - parseFloat(discount) + parseFloat(shipping) + parseFloat(shipping_tax);
if (total < 0 ) total = 0;
jQuery('input#order_subtotal').val( subtotal.toFixed(2) );
jQuery('input#order_tax').val( tax.toFixed(2) );
jQuery('input#order_shipping_tax').val( shipping_tax.toFixed(2) );
jQuery('input#order_total').val( total.toFixed(2) );
}
return false;
});
jQuery('button.add_shop_order_item').click(function(){
var item_id = jQuery('select.item_id').val();
if (item_id) {
jQuery('table.jigoshop_order_items').block({ message: null, overlayCSS: { background: '#fff url(' + params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
var data = {
action: 'jigoshop_add_order_item',
item_to_add: jQuery('select.item_id').val(),
security: params.add_order_item_nonce
};
jQuery.post( params.ajax_url, data, function(response) {
jQuery('table.jigoshop_order_items tbody#order_items_list').append( response );
jQuery('table.jigoshop_order_items').unblock();
jQuery('select.item_id').css('border-color', '').val('');
});
} else {
jQuery('select.item_id').css('border-color', 'red');
}
});
jQuery('button.add_meta').live('click', function(){
jQuery(this).parent().parent().parent().parent().append('<tr><td><input type="text" name="meta_name[][]" placeholder="' + params.meta_name + '" /></td><td><input type="text" name="meta_value[][]" placeholder="' + params.meta_value + '" /></td></tr>');
});
jQuery('button.billing-same-as-shipping').live('click', function(){
var answer = confirm(params.copy_billing);
if (answer){
jQuery('input#shipping_first_name').val( jQuery('input#billing_first_name').val() );
jQuery('input#shipping_last_name').val( jQuery('input#billing_last_name').val() );
jQuery('input#shipping_company').val( jQuery('input#billing_company').val() );
jQuery('input#shipping_address_1').val( jQuery('input#billing_address_1').val() );
jQuery('input#shipping_address_2').val( jQuery('input#billing_address_2').val() );
jQuery('input#shipping_city').val( jQuery('input#billing_city').val() );
jQuery('input#shipping_postcode').val( jQuery('input#billing_postcode').val() );
jQuery('input#shipping_country').val( jQuery('input#billing_country').val() );
jQuery('input#shipping_state').val( jQuery('input#billing_state').val() );
}
return false;
});
// PRODUCT TYPE SPECIFIC OPTIONS
$('select#product-type').change(function(){
// Get value
var select_val = jQuery(this).val();
// Hide options
$('#jigoshop-product-type-options .inside > div').hide();
$('#'+select_val+'_product_options').show();
// Show option
if (select_val=='variable') {
jQuery('.inventory_tab, .pricing_tab').show();
jQuery('.menu_order_field, .parent_id_field').val('').hide();
} else if (select_val=='simple') {
jQuery('.inventory_tab, .pricing_tab').show();
jQuery('.menu_order_field, .parent_id_field').show();
} else if (select_val=='grouped') {
jQuery('.inventory_tab, .pricing_tab').hide();
jQuery('.menu_order_field, .parent_id_field').val('').hide();
} else if (select_val=='downloadable') {
jQuery('.inventory_tab, .pricing_tab').show();
jQuery('.menu_order_field, .parent_id_field').show();
} else if (select_val=='virtual') {
jQuery('.inventory_tab, .pricing_tab').show();
jQuery('.menu_order_field, .parent_id_field').show();
}
$('body').trigger('jigoshop-product-type-change', select_val, $(this) );
}).change();
// STOCK OPTIONS
jQuery('input#manage_stock').change(function(){
if (jQuery(this).is(':checked')) jQuery('div.stock_fields').show();
else jQuery('div.stock_fields').hide();
}).change();
// DATE PICKER FIELDS
Date.firstDayOfWeek = 1;
Date.format = 'yyyy-mm-dd';
jQuery('.date-pick').datePicker();
jQuery('#sale_price_dates_from').bind(
'dpClosed',
function(e, selectedDates)
{
var d = selectedDates[0];
if (d) {
d = new Date(d);
jQuery('#sale_price_dates_to').dpSetStartDate(d.addDays(1).asString());
}
}
);
jQuery('#sale_price_dates_to').bind(
'dpClosed',
function(e, selectedDates)
{
var d = selectedDates[0];
if (d) {
d = new Date(d);
jQuery('#sale_price_dates_from').dpSetEndDate(d.addDays(-1).asString());
}
}
);
// ATTRIBUTE TABLES
// Initial order
var jigoshop_attributes_table_items = jQuery('#attributes_list').children('tr').get();
jigoshop_attributes_table_items.sort(function(a, b) {
var compA = jQuery(a).attr('rel');
var compB = jQuery(b).attr('rel');
return (compA < compB) ? -1 : (compA > compB) ? 1 : 0;
})
jQuery(jigoshop_attributes_table_items).each( function(idx, itm) { jQuery('#attributes_list').append(itm); } );
// Show
function show_attribute_table() {
jQuery('table.jigoshop_attributes, table.jigoshop_variable_attributes').each(function(){
if (jQuery('tbody tr', this).size()==0)
jQuery(this).parent().hide();
else
jQuery(this).parent().show();
});
}
show_attribute_table();
function row_indexes() {
jQuery('#attributes_list tr').each(function(index, el){ jQuery('.attribute_position', el).val( parseInt( jQuery(el).index('#attributes_list tr') ) ); });
};
// Add rows
jQuery('button.add_attribute').click(function(){
var size = jQuery('table.jigoshop_attributes tbody tr').size();
var attribute_type = jQuery('select.attribute_taxonomy').val();
if (!attribute_type) {
// Add custom attribute row
jQuery('table.jigoshop_attributes tbody').append('<tr><td class="center"><button type="button" class="button move_up">&uarr;</button><button type="button" class="move_down button">&darr;</button><input type="hidden" name="attribute_position[' + size + ']" class="attribute_position" value="' + size + '" /></td><td><input type="text" name="attribute_names[' + size + ']" /><input type="hidden" name="attribute_is_taxonomy[' + size + ']" value="0" /></td><td><input type="text" name="attribute_values[' + size + ']" /></td><td class="center"><input type="checkbox" checked="checked" name="attribute_visibility[' + size + ']" value="1" /></td><td class="center"><input type="checkbox" name="attribute_variation[' + size + ']" value="1" /></td><td class="center"><button type="button" class="remove_row button">&times;</button></td></tr>');
} else {
// Reveal taxonomy row
var thisrow = jQuery('table.jigoshop_attributes tbody tr.' + attribute_type);
jQuery('table.jigoshop_attributes tbody').append( jQuery(thisrow) );
jQuery(thisrow).show();
row_indexes();
}
show_attribute_table();
});
jQuery('button.hide_row').live('click', function(){
var answer = confirm("Remove this attribute?")
if (answer){
jQuery(this).parent().parent().find('select, input[type=text]').val('');
jQuery(this).parent().parent().hide();
show_attribute_table();
}
return false;
});
jQuery('#attributes_list button.remove_row').live('click', function(){
var answer = confirm("Remove this attribute?")
if (answer){
jQuery(this).parent().parent().remove();
show_attribute_table();
row_indexes();
}
return false;
});
jQuery('button.move_up').live('click', function(){
var row = jQuery(this).parent().parent();
var prev_row = jQuery(row).prev('tr');
jQuery(row).after(prev_row);
row_indexes();
});
jQuery('button.move_down').live('click', function(){
var row = jQuery(this).parent().parent();
var next_row = jQuery(row).next('tr');
jQuery(row).before(next_row);
row_indexes();
});
});

267
classes/jigoshop.class.php Normal file
View File

@ -0,0 +1,267 @@
<?php
/**
* Contains the main functions for jigoshop, stores variables, and handles error messages
*
*
* @package JigoShop
* @category Core
* @author Jigowatt
* @since 1.0
*/
class jigoshop {
private static $_instance;
private static $_cache;
public static $errors = array();
public static $messages = array();
public static $attribute_taxonomies;
public static $plugin_url;
public static $plugin_path;
const SHOP_SMALL_W = '150';
const SHOP_SMALL_H = '150';
const SHOP_TINY_W = '36';
const SHOP_TINY_H = '36';
const SHOP_THUMBNAIL_W = '90';
const SHOP_THUMBNAIL_H = '90';
const SHOP_LARGE_W = '300';
const SHOP_LARGE_H = '300';
/** constructor */
function __construct () {
global $wpdb;
// Vars
self::$attribute_taxonomies = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."jigoshop_attribute_taxonomies;");
if (isset($_SESSION['errors'])) self::$errors = $_SESSION['errors'];
if (isset($_SESSION['messages'])) self::$messages = $_SESSION['messages'];
unset($_SESSION['messages']);
unset($_SESSION['errors']);
// Hooks
add_filter('wp_redirect', array(&$this, 'redirect'), 1, 2);
}
/** get */
public static function get() {
if (!isset(self::$_instance)) {
$c = __CLASS__;
self::$_instance = new $c;
}
return self::$_instance;
}
/**
* Get the plugin url
*
* @return string url
*/
public static function plugin_url() {
if(self::$plugin_url) return self::$plugin_url;
if (is_ssl()) :
return self::$plugin_url = str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename( dirname(dirname(__FILE__)));
else :
return self::$plugin_url = WP_PLUGIN_URL . "/" . plugin_basename( dirname(dirname(__FILE__)));
endif;
}
/**
* Get the plugin path
*
* @return string url
*/
public static function plugin_path() {
if(self::$plugin_path) return self::$plugin_path;
return self::$plugin_path = WP_PLUGIN_DIR . "/" . plugin_basename( dirname(dirname(__FILE__)));
}
/**
* Return the URL with https if SSL is on
*
* @return string url
*/
public static function force_ssl( $url ) {
if (is_ssl()) $url = str_replace('http:', 'https:', $url);
return $url;
}
/**
* Get a var
*
* Variable is filtered by jigoshop_get_var_{var name}
*
* @param string var
* @return string variable
*/
public static function get_var($var) {
$return = '';
switch ($var) :
case "version" : $return = JIGOSHOP_VERSION; break;
case "shop_small_w" : $return = self::SHOP_SMALL_W; break;
case "shop_small_h" : $return = self::SHOP_SMALL_H; break;
case "shop_tiny_w" : $return = self::SHOP_TINY_W; break;
case "shop_tiny_h" : $return = self::SHOP_TINY_H; break;
case "shop_thumbnail_w" : $return = self::SHOP_THUMBNAIL_W; break;
case "shop_thumbnail_h" : $return = self::SHOP_THUMBNAIL_H; break;
case "shop_large_w" : $return = self::SHOP_LARGE_W; break;
case "shop_large_h" : $return = self::SHOP_LARGE_H; break;
endswitch;
return apply_filters( 'jigoshop_get_var_'.$var, $return );
}
/**
* Add an error
*
* @param string error
*/
function add_error( $error ) { self::$errors[] = $error; }
/**
* Add a message
*
* @param string message
*/
function add_message( $message ) { self::$messages[] = $message; }
/** Clear messages and errors from the session data */
function clear_messages() {
self::$errors = self::$messages = array();
unset($_SESSION['messages']);
unset($_SESSION['errors']);
}
/**
* Get error count
*
* @return int
*/
function error_count() { return sizeof(self::$errors); }
/**
* Get message count
*
* @return int
*/
function message_count() { return sizeof(self::$messages); }
/**
* Output the errors and messages
*
* @return bool
*/
public static function show_messages() {
if (isset(self::$errors) && sizeof(self::$errors)>0) :
echo '<div class="jigoshop_error">'.self::$errors[0].'</div>';
self::clear_messages();
return true;
elseif (isset(self::$messages) && sizeof(self::$messages)>0) :
echo '<div class="jigoshop_message">'.self::$messages[0].'</div>';
self::clear_messages();
return true;
else :
return false;
endif;
}
public static function nonce_field ($action, $referer = true , $echo = true) {
$name = '_n';
$action = 'jigoshop-' . $action;
return wp_nonce_field($action, $name, $referer, $echo);
}
public static function nonce_url ($action, $url = '') {
$name = '_n';
$action = 'jigoshop-' . $action;
$url = add_query_arg( $name, wp_create_nonce( $action ), $url);
return $url;
}
/**
* Check a nonce and sets jigoshop error in case it is invalid
* To fail silently, set the error_message to an empty string
*
* @param string $name the nonce name
* @param string $action then nonce action
* @param string $method the http request method _POST, _GET or _REQUEST
* @param string $error_message custom error message, or false for default message, or an empty string to fail silently
*
* @return bool
*/
public static function verify_nonce($action, $method='_POST', $error_message = false) {
$name = '_n';
$action = 'jigoshop-' . $action;
if( $error_message === false ) $error_message = __('Action failed. Please refresh the page and retry.', 'jigoshop');
if(!in_array($method, array('_GET', '_POST', '_REQUEST'))) $method = '_POST';
/*
$request = $GLOBALS[$method];
if ( isset($request[$name]) && wp_verify_nonce($request[$name], $action) ) return true;
*/
if ( isset($_REQUEST[$name]) && wp_verify_nonce($_REQUEST[$name], $action) ) return true;
if( $error_message ) jigoshop::add_error( $error_message );
return false;
}
/**
* Redirection hook which stores messages into session data
*
* @param location
* @param status
* @return location
*/
function redirect( $location, $status ) {
$_SESSION['errors'] = self::$errors;
$_SESSION['messages'] = self::$messages;
return $location;
}
static public function shortcode_wrapper ($function, $atts=array()) {
if( $content = jigoshop::cache_get( $function . '-shortcode', $atts ) ) return $content;
ob_start();
call_user_func($function, $atts);
return jigoshop::cache( $function . '-shortcode', ob_get_clean(), $atts);
}
/**
* Cache API
*/
public static function cache ( $id, $data, $args=array() ) {
if( ! isset(self::$_cache[ $id ]) ) self::$_cache[ $id ] = array();
if( empty($args) ) self::$_cache[ $id ][0] = $data;
else self::$_cache[ $id ][ serialize($args) ] = $data;
return $data;
}
public static function cache_get ( $id, $args=array() ) {
if( ! isset(self::$_cache[ $id ]) ) return null;
if( empty($args) && isset(self::$_cache[ $id ][0]) ) return self::$_cache[ $id ][0];
elseif ( isset(self::$_cache[ $id ][ serialize($args) ] ) ) return self::$_cache[ $id ][ serialize($args) ];
}
}

View File

@ -0,0 +1,566 @@
<?php
/**
* Jigoshop cart
* @class jigoshop_cart
*
* The JigoShop cart class stores cart data and active coupons as well as handling customer sessions and some cart related urls.
* The cart class also has a price calculation function which calls upon other classes to calcualte totals.
*
* @author Jigowatt
* @category Classes
* @package JigoShop
*/
class jigoshop_cart {
private static $_instance;
public static $cart_contents_total;
public static $cart_contents_total_ex_tax;
public static $cart_contents_weight;
public static $cart_contents_count;
public static $cart_contents_tax;
public static $cart_contents;
public static $total;
public static $subtotal;
public static $subtotal_ex_tax;
public static $tax_total;
public static $discount_total;
public static $shipping_total;
public static $shipping_tax_total;
public static $applied_coupons;
/** constructor */
function __construct() {
add_action('init', array($this, 'init'), 1);
}
/** get class instance */
public static function get() {
if (!isset(self::$_instance)) {
$c = __CLASS__;
self::$_instance = new $c;
}
return self::$_instance;
}
public function init () {
self::$applied_coupons = array();
self::get_cart_from_session();
if ( isset($_SESSION['coupons']) ) self::$applied_coupons = $_SESSION['coupons'];
self::calculate_totals();
}
/** Gets the cart data from the PHP session */
function get_cart_from_session() {
if ( isset($_SESSION['cart']) && is_array($_SESSION['cart']) ) :
$cart = $_SESSION['cart'];
foreach ($cart as $values) :
if ($values['variation_id']>0) :
$_product = &new jigoshop_product_variation($values['variation_id']);
else :
$_product = &new jigoshop_product($values['product_id']);
endif;
if ($_product->exists) :
self::$cart_contents[] = array(
'product_id' => $values['product_id'],
'variation_id' => $values['variation_id'],
'variation' => $values['variation'],
'quantity' => $values['quantity'],
'data' => $_product
);
endif;
endforeach;
else :
self::$cart_contents = array();
endif;
if (!is_array(self::$cart_contents)) self::$cart_contents = array();
}
/** sets the php session data for the cart and coupon */
function set_session() {
$cart = array();
$_SESSION['cart'] = self::$cart_contents;
$_SESSION['coupons'] = self::$applied_coupons;
self::calculate_totals();
}
/** Empty the cart */
function empty_cart() {
unset($_SESSION['cart']);
unset($_SESSION['coupons']);
}
/** Check if product is in the cart */
function find_product_in_cart( $product_id, $variation = '' ) {
foreach (self::$cart_contents as $cart_item_key => $cart_item) :
if ($variation) :
if ($cart_item['product_id'] == $product_id && $cart_item['variation']==$variation) :
return $cart_item_key;
endif;
else :
if ($cart_item['product_id'] == $product_id) :
return $cart_item_key;
endif;
endif;
endforeach;
}
/**
* Add a product to the cart
*
* @param string product_id contains the id of the product to add to the cart
* @param string quantity contains the quantity of the item to add
*/
function add_to_cart( $product_id, $quantity = 1, $variation = '', $variation_id = '' ) {
$found_cart_item_key = self::find_product_in_cart($product_id, $variation);
if (is_numeric($found_cart_item_key)) :
$quantity = $quantity + self::$cart_contents[$found_cart_item_key]['quantity'];
self::$cart_contents[$found_cart_item_key]['quantity'] = $quantity;
else :
$cart_item_key = sizeof(self::$cart_contents);
$data = &new jigoshop_product( $product_id );
self::$cart_contents[$cart_item_key] = array(
'product_id' => $product_id,
'variation_id' => $variation_id,
'variation' => $variation,
'quantity' => $quantity,
'data' => $data
);
endif;
self::set_session();
}
/**
* Set the quantity for an item in the cart
*
* @param string cart_item_key contains the id of the cart item
* @param string quantity contains the quantity of the item
*/
function set_quantity( $cart_item, $quantity = 1 ) {
if ($quantity==0 || $quantity<0) :
unset(self::$cart_contents[$cart_item]);
else :
self::$cart_contents[$cart_item]['quantity'] = $quantity;
endif;
self::set_session();
}
/**
* Returns the contents of the cart
*
* @return array cart_contents
*/
function get_cart() {
return self::$cart_contents;
}
/**
* Gets cross sells based on the items in the cart
*
* @return array cross_sells item ids of cross sells
*/
function get_cross_sells() {
$cross_sells = array();
$in_cart = array();
if (sizeof(self::$cart_contents)>0) : foreach (self::$cart_contents as $cart_item_key => $values) :
if ($values['quantity']>0) :
$cross_sells = array_merge($values['data']->get_cross_sells(), $cross_sells);
$in_cart[] = $values['product_id'];
endif;
endforeach; endif;
$cross_sells = array_diff($cross_sells, $in_cart);
return $cross_sells;
}
/** gets the url to the cart page */
function get_cart_url() {
$cart_page_id = get_option('jigoshop_cart_page_id');
if ($cart_page_id) return get_permalink($cart_page_id);
}
/** gets the url to the checkout page */
function get_checkout_url() {
$checkout_page_id = get_option('jigoshop_checkout_page_id');
if ($checkout_page_id) :
if (is_ssl()) return str_replace('http:', 'https:', get_permalink($checkout_page_id));
return get_permalink($checkout_page_id);
endif;
}
/** gets the url to remove an item from the cart */
function get_remove_url( $cart_item_key ) {
$cart_page_id = get_option('jigoshop_cart_page_id');
if ($cart_page_id) return jigoshop::nonce_url( 'cart', add_query_arg('remove_item', $cart_item_key, get_permalink($cart_page_id)));
}
/** looks through the cart to see if shipping is actually required */
function needs_shipping() {
if (!jigoshop_shipping::$enabled) return false;
if (!is_array(self::$cart_contents)) return false;
$needs_shipping = false;
foreach (self::$cart_contents as $cart_item_key => $values) :
$_product = $values['data'];
if ( $_product->is_type( 'simple' ) || $_product->is_type( 'variable' ) ) :
$needs_shipping = true;
endif;
endforeach;
return $needs_shipping;
}
/** Sees if we need a shipping address */
function ship_to_billing_address_only() {
$ship_to_billing_address_only = get_option('jigoshop_ship_to_billing_address_only');
if ($ship_to_billing_address_only=='yes') return true;
return false;
}
/** looks at the totals to see if payment is actually required */
function needs_payment() {
if ( self::$total > 0 ) return true;
return false;
}
/** looks through the cart to check each item is in stock */
function check_cart_item_stock() {
$error = new WP_Error();
foreach (self::$cart_contents as $cart_item_key => $values) :
$_product = $values['data'];
if ($_product->managing_stock()) :
if ($_product->is_in_stock() && $_product->has_enough_stock( $values['quantity'] )) :
// :)
else :
$error->add( 'out-of-stock', sprintf(__('Sorry, we do not have enough "%s" in stock to fulfill your order. Please edit your cart and try again. We apologise for any inconvenience caused.', 'jigoshop'), $_product->get_title() ) );
return $error;
endif;
else :
if (!$_product->is_in_stock()) :
$error->add( 'out-of-stock', sprintf(__('Sorry, we do not have enough "%s" in stock to fulfill your order. Please edit your cart and try again. We apologise for any inconvenience caused.', 'jigoshop'), $_product->get_title() ) );
return $error;
endif;
endif;
endforeach;
return true;
}
/** calculate totals for the items in the cart */
public static function calculate_totals() {
$_tax = &new jigoshop_tax();
self::$total = 0;
self::$cart_contents_total = 0;
self::$cart_contents_total_ex_tax = 0;
self::$cart_contents_weight = 0;
self::$cart_contents_count = 0;
self::$cart_contents_tax = 0;
self::$tax_total = 0;
self::$shipping_tax_total = 0;
self::$subtotal = 0;
self::$subtotal_ex_tax = 0;
self::$discount_total = 0;
self::$shipping_total = 0;
if (sizeof(self::$cart_contents)>0) : foreach (self::$cart_contents as $cart_item_key => $values) :
$_product = $values['data'];
if ($_product->exists() && $values['quantity']>0) :
self::$cart_contents_count = self::$cart_contents_count + $values['quantity'];
self::$cart_contents_weight = self::$cart_contents_weight + ($_product->get_weight() * $values['quantity']);
$total_item_price = $_product->get_price() * $values['quantity'] * 100; // Into pounds
if ( get_option('jigoshop_calc_taxes')=='yes') :
if ( $_product->is_taxable() ) :
$rate = $_tax->get_rate( $_product->data['tax_class'] );
if (get_option('jigoshop_prices_include_tax')=='yes') :
$tax_amount = $_tax->calc_tax( $total_item_price, $rate, true );
else :
$tax_amount = $_tax->calc_tax( $total_item_price, $rate, false );
endif;
if (get_option('jigoshop_prices_include_tax')=='yes' && jigoshop_customer::is_customer_outside_base() && defined('JIGOSHOP_CHECKOUT') && JIGOSHOP_CHECKOUT ) :
/**
* Our prices include tax so we need to take the base tax rate into consideration of our shop's country
*
* Lets get the base rate first
*/
$base_rate = $_tax->get_shop_base_rate( $_product->data['tax_class'] );
// Calc tax for base country
$base_tax_amount = round($_tax->calc_tax( $total_item_price, $base_rate, true ));
// Now calc tax for user county (which now excludes tax)
$tax_amount = round($_tax->calc_tax( ($total_item_price-$base_tax_amount), $rate, false ));
// Finally, update $total_item_price to reflect tax amounts
$total_item_price = ($total_item_price - $base_tax_amount + $tax_amount);
endif;
endif;
endif;
$total_item_price = $total_item_price / 100; // Back to pounds
$tax_amount = ( isset($tax_amount) ? $tax_amount : 0 ) / 100; // Back to pounds
self::$cart_contents_tax = self::$cart_contents_tax + $tax_amount;
self::$cart_contents_total = self::$cart_contents_total + $total_item_price;
self::$cart_contents_total_ex_tax = self::$cart_contents_total_ex_tax + ($_product->get_price_excluding_tax() * $values['quantity']);
// Product Discounts
if (self::$applied_coupons) foreach (self::$applied_coupons as $code) :
$coupon = jigoshop_coupons::get_coupon($code);
if ($coupon['type']=='fixed_product' && in_array($values['product_id'], $coupon['products'])) :
self::$discount_total = self::$discount_total + ( $coupon['amount'] * $values['quantity'] );
endif;
endforeach;
endif;
endforeach; endif;
// Cart Shipping
if (self::needs_shipping()) jigoshop_shipping::calculate_shipping(); else jigoshop_shipping::reset_shipping();
self::$shipping_total = jigoshop_shipping::$shipping_total;
self::$shipping_tax_total = jigoshop_shipping::$shipping_tax;
self::$tax_total = self::$cart_contents_tax;
// Subtotal
self::$subtotal_ex_tax = self::$cart_contents_total_ex_tax;
self::$subtotal = self::$cart_contents_total;
// Cart Discounts
if (self::$applied_coupons) foreach (self::$applied_coupons as $code) :
$coupon = jigoshop_coupons::get_coupon($code);
if (jigoshop_coupons::is_valid($code)) :
if ($coupon['type']=='fixed_cart') :
self::$discount_total = self::$discount_total + $coupon['amount'];
elseif ($coupon['type']=='percent') :
self::$discount_total = self::$discount_total + ( self::$subtotal / 100 ) * $coupon['amount'];
endif;
endif;
endforeach;
// Total
if (get_option('jigoshop_prices_include_tax')=='yes') :
self::$total = self::$subtotal + self::$shipping_tax_total - self::$discount_total + jigoshop_shipping::$shipping_total;
else :
self::$total = self::$subtotal + self::$tax_total + self::$shipping_tax_total - self::$discount_total + jigoshop_shipping::$shipping_total;
endif;
if (self::$total < 0) self::$total = 0;
}
/** gets the total (after calculation) */
function get_total() {
return jigoshop_price(self::$total);
}
/** gets the cart contens total (after calculation) */
function get_cart_total() {
return jigoshop_price(self::$cart_contents_total);
}
/** gets the sub total (after calculation) */
function get_cart_subtotal() {
if (get_option('jigoshop_display_totals_tax')=='excluding' || ( defined('JIGOSHOP_CHECKOUT') && JIGOSHOP_CHECKOUT )) :
if (get_option('jigoshop_prices_include_tax')=='yes') :
$return = jigoshop_price(self::$subtotal - self::$tax_total);
else :
$return = jigoshop_price(self::$subtotal);
endif;
if (self::$tax_total>0) :
$return .= __(' <small>(ex. tax)</small>', 'jigoshop');
endif;
return $return;
else :
if (get_option('jigoshop_prices_include_tax')=='yes') :
$return = jigoshop_price(self::$subtotal);
else :
$return = jigoshop_price(self::$subtotal + self::$tax_total);
endif;
if (self::$tax_total>0) :
$return .= __(' <small>(inc. tax)</small>', 'jigoshop');
endif;
return $return;
endif;
}
/** gets the cart tax (after calculation) */
function get_cart_tax() {
$cart_total_tax = self::$tax_total + self::$shipping_tax_total;
if ($cart_total_tax > 0) return jigoshop_price( $cart_total_tax );
return false;
}
/** gets the shipping total (after calculation) */
function get_cart_shipping_total() {
if (isset(jigoshop_shipping::$shipping_label)) :
if (jigoshop_shipping::$shipping_total>0) :
if (get_option('jigoshop_display_totals_tax')=='excluding') :
$return = jigoshop_price(jigoshop_shipping::$shipping_total);
if (self::$shipping_tax_total>0) :
$return .= __(' <small>(ex. tax)</small>', 'jigoshop');
endif;
return $return;
else :
$return = jigoshop_price(jigoshop_shipping::$shipping_total + jigoshop_shipping::$shipping_tax);
if (self::$shipping_tax_total>0) :
$return .= __(' <small>(inc. tax)</small>', 'jigoshop');
endif;
return $return;
endif;
else :
return __('Free!', 'jigoshop');
endif;
endif;
}
/** gets title of the chosen shipping method */
function get_cart_shipping_title() {
if (isset(jigoshop_shipping::$shipping_label)) :
return __('via ','jigoshop') . jigoshop_shipping::$shipping_label;
endif;
return false;
}
/**
* Applies a coupon code
*
* @param string code The code to apply
* @return bool True if the coupon is applied, false if it does not exist or cannot be applied
*/
function add_discount( $coupon_code ) {
if ($the_coupon = jigoshop_coupons::get_coupon($coupon_code)) :
// Check if applied
if (jigoshop_cart::has_discount($coupon_code)) :
jigoshop::add_error( __('Discount code already applied!', 'jigoshop') );
return false;
endif;
// Check it can be used with cart
if (!jigoshop_coupons::is_valid($coupon_code)) :
jigoshop::add_error( __('Invalid coupon.', 'jigoshop') );
return false;
endif;
// If its individual use then remove other coupons
if ($the_coupon['individual_use']=='yes') :
self::$applied_coupons = array();
endif;
foreach (self::$applied_coupons as $coupon) :
$coupon = jigoshop_coupons::get_coupon($coupon);
if ($coupon['individual_use']=='yes') :
self::$applied_coupons = array();
endif;
endforeach;
self::$applied_coupons[] = $coupon_code;
self::set_session();
jigoshop::add_message( __('Discount code applied successfully.', 'jigoshop') );
return true;
else :
jigoshop::add_error( __('Coupon does not exist!', 'jigoshop') );
return false;
endif;
return false;
}
/** returns whether or not a discount has been applied */
function has_discount( $code ) {
if (in_array($code, self::$applied_coupons)) return true;
return false;
}
/** gets the total discount amount */
function get_total_discount() {
if (self::$discount_total) return jigoshop_price(self::$discount_total); else return false;
}
/** clears the cart/coupon data and re-calcs totals */
function clear_cache() {
self::$cart_contents = array();
self::$applied_coupons = array();
unset( $_SESSION['cart'] );
unset( $_SESSION['coupons'] );
self::calculate_totals();
}
}

View File

@ -0,0 +1,677 @@
<?php
/**
* Checkout
* @class jigoshop_checkout
*
* The JigoShop checkout class handles the checkout process, collecting user data and processing the payment.
*
* @author Jigowatt
* @category Classes
* @package JigoShop
*/
class jigoshop_checkout {
var $posted;
var $billing_fields;
var $shipping_fields;
var $must_create_account;
var $creating_account;
protected static $instance;
/** constructor */
protected function __construct () {
add_action('jigoshop_checkout_billing',array(&$this,'checkout_form_billing'));
add_action('jigoshop_checkout_shipping',array(&$this,'checkout_form_shipping'));
$this->must_create_account = true;
if (get_option('jigoshop_enable_guest_checkout')=='yes' || is_user_logged_in()) $this->must_create_account = false;
$this->billing_fields = array(
array( 'name'=>'billing-first_name', 'label' => __('First Name', 'jigoshop'), 'placeholder' => __('First Name', 'jigoshop'), 'required' => true, 'class' => array('form-row-first') ),
array( 'name'=>'billing-last_name', 'label' => __('Last Name', 'jigoshop'), 'placeholder' => __('Last Name', 'jigoshop'), 'required' => true, 'class' => array('form-row-last') ),
array( 'name'=>'billing-company', 'label' => __('Company', 'jigoshop'), 'placeholder' => __('Company', 'jigoshop') ),
array( 'name'=>'billing-address', 'label' => __('Address', 'jigoshop'), 'placeholder' => __('Address 1', 'jigoshop'), 'required' => true, 'class' => array('form-row-first') ),
array( 'name'=>'billing-address-2', 'label' => __('Address 2', 'jigoshop'), 'placeholder' => __('Address 2', 'jigoshop'), 'class' => array('form-row-last'), 'label_class' => array('hidden') ),
array( 'name'=>'billing-city', 'label' => __('City', 'jigoshop'), 'placeholder' => __('City', 'jigoshop'), 'required' => true, 'class' => array('form-row-first') ),
array( 'validate' => 'postcode', 'format' => 'postcode', 'name'=>'billing-postcode', 'label' => __('Postcode', 'jigoshop'), 'placeholder' => __('Postcode', 'jigoshop'), 'required' => true, 'class' => array('form-row-last') ),
array( 'type'=> 'country', 'name'=>'billing-country', 'label' => __('Country', 'jigoshop'), 'required' => true, 'class' => array('form-row-first'), 'rel' => 'billing-state' ),
array( 'type'=> 'state', 'name'=>'billing-state', 'label' => __('State/County', 'jigoshop'), 'required' => true, 'class' => array('form-row-last'), 'rel' => 'billing-country' ),
array( 'name'=>'billing-email', 'validate' => 'email', 'label' => __('Email Address', 'jigoshop'), 'placeholder' => __('you@yourdomain.com', 'jigoshop'), 'required' => true, 'class' => array('form-row-first') ),
array( 'name'=>'billing-phone', 'validate' => 'phone', 'label' => __('Phone', 'jigoshop'), 'placeholder' => __('Phone number', 'jigoshop'), 'required' => true, 'class' => array('form-row-last') )
);
$this->shipping_fields = array(
array( 'name'=>'shipping-first_name', 'label' => __('First Name', 'jigoshop'), 'placeholder' => __('First Name', 'jigoshop'), 'required' => true, 'class' => array('form-row-first') ),
array( 'name'=>'shipping-last_name', 'label' => __('Last Name', 'jigoshop'), 'placeholder' => __('Last Name', 'jigoshop'), 'required' => true, 'class' => array('form-row-last') ),
array( 'name'=>'shipping-company', 'label' => __('Company', 'jigoshop'), 'placeholder' => __('Company', 'jigoshop') ),
array( 'name'=>'shipping-address', 'label' => __('Address', 'jigoshop'), 'placeholder' => __('Address 1', 'jigoshop'), 'required' => true, 'class' => array('form-row-first') ),
array( 'name'=>'shipping-address-2', 'label' => __('Address 2', 'jigoshop'), 'placeholder' => __('Address 2', 'jigoshop'), 'class' => array('form-row-last'), 'label_class' => array('hidden') ),
array( 'name'=>'shipping-city', 'label' => __('City', 'jigoshop'), 'placeholder' => __('City', 'jigoshop'), 'required' => true, 'class' => array('form-row-first') ),
array( 'validate' => 'postcode', 'format' => 'postcode', 'name'=>'shipping-postcode', 'label' => __('Postcode', 'jigoshop'), 'placeholder' => __('Postcode', 'jigoshop'), 'required' => true, 'class' => array('form-row-last') ),
array( 'type'=> 'country', 'name'=>'shipping-country', 'label' => __('Country', 'jigoshop'), 'required' => true, 'class' => array('form-row-first'), 'rel' => 'shipping-state' ),
array( 'type'=> 'state', 'name'=>'shipping-state', 'label' => __('State/County', 'jigoshop'), 'required' => true, 'class' => array('form-row-last'), 'rel' => 'shipping-country' )
);
}
public static function instance () {
if(!self::$instance) {
$class = __CLASS__;
self::$instance = new $class;
}
return self::$instance;
}
/** Output the billing information form */
function checkout_form_billing() {
if (jigoshop_cart::ship_to_billing_address_only()) :
echo '<h3>'.__('Billing &amp Shipping', 'jigoshop').'</h3>';
else :
echo '<h3>'.__('Billing Address', 'jigoshop').'</h3>';
endif;
// Billing Details
foreach ($this->billing_fields as $field) :
$this->checkout_form_field( $field );
endforeach;
// Registration Form
if (!is_user_logged_in()) :
if (get_option('jigoshop_enable_guest_checkout')=='yes') :
echo '<p class="form-row"><input class="input-checkbox" id="createaccount" ';
if ($this->get_value('createaccount')) echo 'checked="checked" ';
echo 'type="checkbox" name="createaccount" /> <label for="createaccount" class="checkbox">'.__('Create an account?', 'jigoshop').'</label></p>';
endif;
echo '<div class="create-account">';
$this->checkout_form_field( array( 'type' => 'text', 'name' => 'account-username', 'label' => __('Account username', 'jigoshop'), 'placeholder' => __('Username', 'jigoshop') ) );
$this->checkout_form_field( array( 'type' => 'password', 'name' => 'account-password', 'label' => __('Account password', 'jigoshop'), 'placeholder' => __('Password', 'jigoshop'),'class' => array('form-row-first')) );
$this->checkout_form_field( array( 'type' => 'password', 'name' => 'account-password-2', 'label' => __('Account password', 'jigoshop'), 'placeholder' => __('Password', 'jigoshop'),'class' => array('form-row-last'), 'label_class' => array('hidden')) );
echo '<p><small>'.__('Save time in the future and check the status of your order by creating an account.', 'jigoshop').'</small></p></div>';
endif;
}
/** Output the shipping information form */
function checkout_form_shipping() {
// Shipping Details
if (jigoshop_cart::needs_shipping() && !jigoshop_cart::ship_to_billing_address_only()) :
echo '<p class="form-row" id="shiptobilling"><input class="input-checkbox" ';
if (!$_POST) $shiptobilling = apply_filters('shiptobilling_default', 1); else $shiptobilling = $this->get_value('shiptobilling');
if ($shiptobilling) echo 'checked="checked" ';
echo 'type="checkbox" name="shiptobilling" /> <label for="shiptobilling" class="checkbox">'.__('Ship to same address?', 'jigoshop').'</label></p>';
echo '<h3>'.__('Shipping Address', 'jigoshop').'</h3>';
echo'<div class="shipping-address">';
foreach ($this->shipping_fields as $field) :
$this->checkout_form_field( $field );
endforeach;
echo'</div>';
elseif (jigoshop_cart::ship_to_billing_address_only()) :
echo '<h3>'.__('Notes/Comments', 'jigoshop').'</h3>';
endif;
$this->checkout_form_field( array( 'type' => 'textarea', 'class' => array('notes'), 'name' => 'order_comments', 'label' => __('Order Notes', 'jigoshop'), 'placeholder' => __('Notes about your order, e.g. special notes for delivery.', 'jigoshop') ) );
}
/**
* Outputs a form field
*
* @param array args contains a list of args for showing the field, merged with defaults (below)
*/
function checkout_form_field( $args ) {
$defaults = array(
'type' => 'input',
'name' => '',
'label' => '',
'placeholder' => '',
'required' => false,
'class' => array(),
'label_class' => array(),
'rel' => '',
'return' => false
);
$args = wp_parse_args( $args, $defaults );
if ($args['required']) $required = ' <span class="required">*</span>'; else $required = '';
if (in_array('form-row-last', $args['class'])) $after = '<div class="clear"></div>'; else $after = '';
$field = '';
switch ($args['type']) :
case "country" :
$field = '<p class="form-row '.implode(' ', $args['class']).'">
<label for="'.$args['name'].'" class="'.implode(' ', $args['label_class']).'">'.$args['label'].$required.'</label>
<select name="'.$args['name'].'" id="'.$args['name'].'" class="country_to_state" rel="'.$args['rel'].'">
<option value="">'.__('Select a country&hellip;', 'jigoshop').'</option>';
foreach(jigoshop_countries::get_allowed_countries() as $key=>$value) :
$field .= '<option value="'.$key.'"';
if ($this->get_value($args['name'])==$key) $field .= 'selected="selected"';
elseif (!$this->get_value($args['name']) && jigoshop_customer::get_country()==$key) $field .= 'selected="selected"';
$field .= '>'.__($value, 'jigoshop').'</option>';
endforeach;
$field .= '</select></p>'.$after;
break;
case "state" :
$field = '<p class="form-row '.implode(' ', $args['class']).'">
<label for="'.$args['name'].'" class="'.implode(' ', $args['label_class']).'">'.$args['label'].$required.'</label>';
$current_cc = $this->get_value($args['rel']);
if (!$current_cc) $current_cc = jigoshop_customer::get_country();
$current_r = $this->get_value($args['name']);
if (!$current_r) $current_r = jigoshop_customer::get_state();
$states = jigoshop_countries::$states;
if (isset( $states[$current_cc][$current_r] )) :
// Dropdown
$field .= '<select name="'.$args['name'].'" id="'.$args['name'].'"><option value="">'.__('Select a state&hellip;', 'jigoshop').'</option>';
foreach($states[$current_cc] as $key=>$value) :
$field .= '<option value="'.$key.'"';
if ($current_r==$key) $field .= 'selected="selected"';
$field .= '>'.__($value, 'jigoshop').'</option>';
endforeach;
$field .= '</select>';
else :
// Input
$field .= '<input type="text" class="input-text" value="'.$current_r.'" placeholder="'.__('State/County', 'jigoshop').'" name="'.$args['name'].'" id="'.$args['name'].'" />';
endif;
$field .= '</p>'.$after;
break;
case "textarea" :
$field = '<p class="form-row '.implode(' ', $args['class']).'">
<label for="'.$args['name'].'" class="'.implode(' ', $args['label_class']).'">'.$args['label'].$required.'</label>
<textarea name="'.$args['name'].'" class="input-text" id="'.$args['name'].'" placeholder="'.$args['placeholder'].'" cols="5" rows="2">'. $this->get_value( $args['name'] ).'</textarea>
</p>'.$after;
break;
default :
$field = '<p class="form-row '.implode(' ', $args['class']).'">
<label for="'.$args['name'].'" class="'.implode(' ', $args['label_class']).'">'.$args['label'].$required.'</label>
<input type="'.$args['type'].'" class="input-text" name="'.$args['name'].'" id="'.$args['name'].'" placeholder="'.$args['placeholder'].'" value="'. $this->get_value( $args['name'] ).'" />
</p>'.$after;
break;
endswitch;
if ($args['return']) return $field; else echo $field;
}
/** Process the checkout after the confirm order button is pressed */
function process_checkout() {
global $wpdb;
if (isset($_POST) && $_POST && !isset($_POST['login'])) :
jigoshop_cart::calculate_totals();
jigoshop::verify_nonce('process_checkout');
if (sizeof(jigoshop_cart::$cart_contents)==0) :
jigoshop::add_error( sprintf(__('Sorry, your session has expired. <a href="%s">Return to homepage &rarr;</a>','jigoshop'), home_url()) );
endif;
// Checkout fields
$this->posted['shiptobilling'] = isset($_POST['shiptobilling']) ? jigowatt_clean($_POST['shiptobilling']) : '';
$this->posted['payment_method'] = isset($_POST['payment_method']) ? jigowatt_clean($_POST['payment_method']) : '';
$this->posted['shipping_method'] = isset($_POST['shipping_method']) ? jigowatt_clean($_POST['shipping_method']) : '';
$this->posted['order_comments'] = isset($_POST['order_comments']) ? jigowatt_clean($_POST['order_comments']) : '';
$this->posted['terms'] = isset($_POST['terms']) ? jigowatt_clean($_POST['terms']) : '';
$this->posted['createaccount'] = isset($_POST['createaccount']) ? jigowatt_clean($_POST['createaccount']) : '';
$this->posted['account-username'] = isset($_POST['account-username']) ? jigowatt_clean($_POST['account-username']) : '';
$this->posted['account-password'] = isset($_POST['account-password']) ? jigowatt_clean($_POST['account-password']) : '';
$this->posted['account-password-2'] = isset($_POST['account-password-2']) ? jigowatt_clean($_POST['account-password-2']) : '';
if (jigoshop_cart::ship_to_billing_address_only()) $this->posted['shiptobilling'] = 'true';
// Billing Information
foreach ($this->billing_fields as $field) :
$this->posted[$field['name']] = isset($_POST[$field['name']]) ? jigowatt_clean($_POST[$field['name']]) : '';
// Format
if (isset($field['format'])) switch ( $field['format'] ) :
case 'postcode' : $this->posted[$field['name']] = strtolower(str_replace(' ', '', $this->posted[$field['name']])); break;
endswitch;
// Required
if ( isset($field['required']) && $field['required'] && empty($this->posted[$field['name']]) ) jigoshop::add_error( $field['label'] . __(' (billing) is a required field.','jigoshop') );
// Validation
if (isset($field['validate']) && !empty($this->posted[$field['name']])) switch ( $field['validate'] ) :
case 'phone' :
if (!jigoshop_validation::is_phone( $this->posted[$field['name']] )) : jigoshop::add_error( $field['label'] . __(' (billing) is not a valid number.','jigoshop') ); endif;
break;
case 'email' :
if (!jigoshop_validation::is_email( $this->posted[$field['name']] )) : jigoshop::add_error( $field['label'] . __(' (billing) is not a valid email address.','jigoshop') ); endif;
break;
case 'postcode' :
if (!jigoshop_validation::is_postcode( $this->posted[$field['name']], $_POST['billing-country'] )) : jigoshop::add_error( $field['label'] . __(' (billing) is not a valid postcode/ZIP.','jigoshop') );
else :
$this->posted[$field['name']] = jigoshop_validation::format_postcode( $this->posted[$field['name']], $_POST['billing-country'] );
endif;
break;
endswitch;
endforeach;
// Shipping Information
if (jigoshop_cart::needs_shipping() && !jigoshop_cart::ship_to_billing_address_only() && empty($this->posted['shiptobilling'])) :
foreach ($this->shipping_fields as $field) :
if (isset( $_POST[$field['name']] )) $this->posted[$field['name']] = jigowatt_clean($_POST[$field['name']]); else $this->posted[$field['name']] = '';
// Format
if (isset($field['format'])) switch ( $field['format'] ) :
case 'postcode' : $this->posted[$field['name']] = strtolower(str_replace(' ', '', $this->posted[$field['name']])); break;
endswitch;
// Required
if ( isset($field['required']) && $field['required'] && empty($this->posted[$field['name']]) ) jigoshop::add_error( $field['label'] . __(' (shipping) is a required field.','jigoshop') );
// Validation
if (isset($field['validate']) && !empty($this->posted[$field['name']])) switch ( $field['validate'] ) :
case 'postcode' :
if (!jigoshop_validation::is_postcode( $this->posted[$field['name']], $this->posted['shipping-country'] )) : jigoshop::add_error( $field['label'] . __(' (shipping) is not a valid postcode/ZIP.','jigoshop') );
else :
$this->posted[$field['name']] = jigoshop_validation::format_postcode( $this->posted[$field['name']], $this->posted['shipping-country'] );
endif;
break;
endswitch;
endforeach;
endif;
if (is_user_logged_in()) :
$this->creating_account = false;
elseif (isset($this->posted['createaccount']) && $this->posted['createaccount']) :
$this->creating_account = true;
elseif ($this->must_create_account) :
$this->creating_account = true;
else :
$this->creating_account = false;
endif;
if ($this->creating_account && !$user_id) :
if ( empty($this->posted['account-username']) ) jigoshop::add_error( __('Please enter an account username.','jigoshop') );
if ( empty($this->posted['account-password']) ) jigoshop::add_error( __('Please enter an account password.','jigoshop') );
if ( $this->posted['account-password-2'] !== $this->posted['account-password'] ) jigoshop::add_error( __('Passwords do not match.','jigoshop') );
// Check the username
if ( !validate_username( $this->posted['account-username'] ) ) :
jigoshop::add_error( __('Invalid email/username.','jigoshop') );
elseif ( username_exists( $this->posted['account-username'] ) ) :
jigoshop::add_error( __('An account is already registered with that username. Please choose another.','jigoshop') );
endif;
// Check the e-mail address
if ( email_exists( $this->posted['billing-email'] ) ) :
jigoshop::add_error( __('An account is already registered with your email address. Please login.','jigoshop') );
endif;
endif;
// Terms
if (!isset($_POST['update_totals']) && empty($this->posted['terms']) && get_option('jigoshop_terms_page_id')>0 ) jigoshop::add_error( __('You must accept our Terms &amp; Conditions.','jigoshop') );
if (jigoshop_cart::needs_shipping()) :
// Shipping Method
$available_methods = jigoshop_shipping::get_available_shipping_methods();
if (!isset($available_methods[$this->posted['shipping_method']])) :
jigoshop::add_error( __('Invalid shipping method.','jigoshop') );
endif;
endif;
if (jigoshop_cart::needs_payment()) :
// Payment Method
$available_gateways = jigoshop_payment_gateways::get_available_payment_gateways();
if (!isset($available_gateways[$this->posted['payment_method']])) :
jigoshop::add_error( __('Invalid payment method.','jigoshop') );
else :
// Payment Method Field Validation
$available_gateways[$this->posted['payment_method']]->validate_fields();
endif;
endif;
if (!isset($_POST['update_totals']) && jigoshop::error_count()==0) :
$user_id = get_current_user_id();
while (1) :
// Create customer account and log them in
if ($this->creating_account && !$user_id) :
$reg_errors = new WP_Error();
do_action('register_post', $this->posted['billing-email'], $this->posted['billing-email'], $reg_errors);
$errors = apply_filters( 'registration_errors', $reg_errors, $this->posted['billing-email'], $this->posted['billing-email'] );
// if there are no errors, let's create the user account
if ( !$reg_errors->get_error_code() ) :
$user_pass = $this->posted['account-password'];
$user_id = wp_create_user( $this->posted['account-username'], $user_pass, $this->posted['billing-email'] );
if ( !$user_id ) {
jigoshop::add_error( sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'jigoshop'), get_option('admin_email')));
break;
}
// Change role
wp_update_user( array ('ID' => $user_id, 'role' => 'customer') ) ;
// send the user a confirmation and their login details
wp_new_user_notification( $user_id, $user_pass );
// set the WP login cookie
$secure_cookie = is_ssl() ? true : false;
wp_set_auth_cookie($user_id, true, $secure_cookie);
else :
jigoshop::add_error( $reg_errors->get_error_message() );
break;
endif;
endif;
// Get shipping/billing
if ( !empty($this->posted['shiptobilling']) ) :
$shipping_first_name = $this->posted['billing-first_name'];
$shipping_last_name = $this->posted['billing-last_name'];
$shipping_company = $this->posted['billing-company'];
$shipping_address_1 = $this->posted['billing-address'];
$shipping_address_2 = $this->posted['billing-address-2'];
$shipping_city = $this->posted['billing-city'];
$shipping_state = $this->posted['billing-state'];
$shipping_postcode = $this->posted['billing-postcode'];
$shipping_country = $this->posted['billing-country'];
elseif ( jigoshop_cart::needs_shipping() ) :
$shipping_first_name = $this->posted['shipping-first_name'];
$shipping_last_name = $this->posted['shipping-last_name'];
$shipping_company = $this->posted['shipping-company'];
$shipping_address_1 = $this->posted['shipping-address'];
$shipping_address_2 = $this->posted['shipping-address-2'];
$shipping_city = $this->posted['shipping-city'];
$shipping_state = $this->posted['shipping-state'];
$shipping_postcode = $this->posted['shipping-postcode'];
$shipping_country = $this->posted['shipping-country'];
endif;
// Save billing/shipping to user meta fields
if ($user_id>0) :
update_user_meta( $user_id, 'billing-first_name', $this->posted['billing-first_name'] );
update_user_meta( $user_id, 'billing-last_name', $this->posted['billing-last_name'] );
update_user_meta( $user_id, 'billing-company', $this->posted['billing-company'] );
update_user_meta( $user_id, 'billing-email', $this->posted['billing-email'] );
update_user_meta( $user_id, 'billing-address', $this->posted['billing-address'] );
update_user_meta( $user_id, 'billing-address-2', $this->posted['billing-address-2'] );
update_user_meta( $user_id, 'billing-city', $this->posted['billing-city'] );
update_user_meta( $user_id, 'billing-postcode', $this->posted['billing-postcode'] );
update_user_meta( $user_id, 'billing-country', $this->posted['billing-country'] );
update_user_meta( $user_id, 'billing-state', $this->posted['billing-state'] );
update_user_meta( $user_id, 'billing-phone', $this->posted['billing-phone'] );
if ( empty($this->posted['shiptobilling']) && jigoshop_cart::needs_shipping() ) :
update_user_meta( $user_id, 'shipping-first_name', $this->posted['shipping-first_name'] );
update_user_meta( $user_id, 'shipping-last_name', $this->posted['shipping-last_name'] );
update_user_meta( $user_id, 'shipping-company', $this->posted['shipping-company'] );
update_user_meta( $user_id, 'shipping-address', $this->posted['shipping-address'] );
update_user_meta( $user_id, 'shipping-address-2', $this->posted['shipping-address-2'] );
update_user_meta( $user_id, 'shipping-city', $this->posted['shipping-city'] );
update_user_meta( $user_id, 'shipping-postcode', $this->posted['shipping-postcode'] );
update_user_meta( $user_id, 'shipping-country', $this->posted['shipping-country'] );
update_user_meta( $user_id, 'shipping-state', $this->posted['shipping-state'] );
elseif ( $this->posted['shiptobilling'] && jigoshop_cart::needs_shipping() ) :
update_user_meta( $user_id, 'shipping-first_name', $this->posted['billing-first_name'] );
update_user_meta( $user_id, 'shipping-last_name', $this->posted['billing-last_name'] );
update_user_meta( $user_id, 'shipping-company', $this->posted['billing-company'] );
update_user_meta( $user_id, 'shipping-address', $this->posted['billing-address'] );
update_user_meta( $user_id, 'shipping-address-2', $this->posted['billing-address-2'] );
update_user_meta( $user_id, 'shipping-city', $this->posted['billing-city'] );
update_user_meta( $user_id, 'shipping-postcode', $this->posted['billing-postcode'] );
update_user_meta( $user_id, 'shipping-country', $this->posted['billing-country'] );
update_user_meta( $user_id, 'shipping-state', $this->posted['billing-state'] );
endif;
endif;
// Create Order (send cart variable so we can record items and reduce inventory). Only create if this is a new order, not if the payment was rejected last time.
$_tax = new jigoshop_tax();
$order_data = array(
'post_type' => 'shop_order',
'post_title' => 'Order &ndash; '.date('F j, Y @ h:i A'),
'post_status' => 'publish',
'post_excerpt' => $this->posted['order_comments'],
'post_author' => 1
);
// Order meta data
$data = array();
$data['billing_first_name'] = $this->posted['billing-first_name'];
$data['billing_last_name'] = $this->posted['billing-last_name'];
$data['billing_company'] = $this->posted['billing-company'];
$data['billing_address_1'] = $this->posted['billing-address'];
$data['billing_address_2'] = $this->posted['billing-address-2'];
$data['billing_city'] = $this->posted['billing-city'];
$data['billing_postcode'] = $this->posted['billing-postcode'];
$data['billing_country'] = $this->posted['billing-country'];
$data['billing_state'] = $this->posted['billing-state'];
$data['billing_email'] = $this->posted['billing-email'];
$data['billing_phone'] = $this->posted['billing-phone'];
$data['shipping_first_name'] = $shipping_first_name;
$data['shipping_last_name'] = $shipping_last_name;
$data['shipping_company'] = $shipping_company;
$data['shipping_address_1'] = $shipping_address_1;
$data['shipping_address_2'] = $shipping_address_2;
$data['shipping_city'] = $shipping_city;
$data['shipping_postcode'] = $shipping_postcode;
$data['shipping_country'] = $shipping_country;
$data['shipping_state'] = $shipping_state;
$data['shipping_method'] = $this->posted['shipping_method'];
$data['payment_method'] = $this->posted['payment_method'];
$data['order_subtotal'] = number_format(jigoshop_cart::$subtotal_ex_tax, 2, '.', '');
$data['order_shipping'] = number_format(jigoshop_cart::$shipping_total, 2, '.', '');
$data['order_discount'] = number_format(jigoshop_cart::$discount_total, 2, '.', '');
$data['order_tax'] = number_format(jigoshop_cart::$tax_total, 2, '.', '');
$data['order_shipping_tax'] = number_format(jigoshop_cart::$shipping_tax_total, 2, '.', '');
$data['order_total'] = number_format(jigoshop_cart::$total, 2, '.', '');
// Cart items
$order_items = array();
foreach (jigoshop_cart::$cart_contents as $cart_item_key => $values) :
$_product = $values['data'];
// Calc item tax to store
$rate = '';
if ( $_product->is_taxable()) :
$rate = $_tax->get_rate( $_product->data['tax_class'] );
endif;
$order_items[] = apply_filters('new_order_item', array(
'id' => $values['product_id'],
'variation_id' => $values['variation_id'],
'name' => $_product->get_title(),
'qty' => (int) $values['quantity'],
'cost' => $_product->get_price_excluding_tax(),
'taxrate' => $rate
));
// Check stock levels
if ($_product->managing_stock()) :
if (!$_product->is_in_stock() || !$_product->has_enough_stock( $values['quantity'] )) :
jigoshop::add_error( sprintf(__('Sorry, we do not have enough "%s" in stock to fulfill your order. Please edit your cart and try again. We apologise for any inconvenience caused.', 'jigoshop'), $_product->get_title() ) );
break;
endif;
else :
if (!$_product->is_in_stock()) :
jigoshop::add_error( sprintf(__('Sorry, we do not have enough "%s" in stock to fulfill your order. Please edit your cart and try again. We apologise for any inconvenience caused.', 'jigoshop'), $_product->get_title() ) );
break;
endif;
endif;
endforeach;
if (jigoshop::error_count()>0) break;
// Insert or update the post data
if (isset($_SESSION['order_awaiting_payment']) && $_SESSION['order_awaiting_payment'] > 0) :
$order_id = (int) $_SESSION['order_awaiting_payment'];
$order_data['ID'] = $order_id;
wp_update_post( $order_data );
else :
$order_id = wp_insert_post( $order_data );
if (is_wp_error($order_id)) :
jigoshop::add_error( 'Error: Unable to create order. Please try again.' );
break;
endif;
endif;
// Update post meta
update_post_meta( $order_id, 'order_data', $data );
update_post_meta( $order_id, 'order_key', uniqid('order_') );
update_post_meta( $order_id, 'customer_user', (int) $user_id );
update_post_meta( $order_id, 'order_items', $order_items );
wp_set_object_terms( $order_id, 'pending', 'shop_order_status' );
$order = &new jigoshop_order($order_id);
// Inserted successfully
do_action('jigoshop_new_order', $order_id);
if (jigoshop_cart::needs_payment()) :
// Store Order ID in session so it can be re-used after payment failure
$_SESSION['order_awaiting_payment'] = $order_id;
// Process Payment
$result = $available_gateways[$this->posted['payment_method']]->process_payment( $order_id );
// Redirect to success/confirmation/payment page
if ($result['result']=='success') :
if (is_ajax()) :
ob_clean();
echo json_encode($result);
exit;
else :
wp_safe_redirect( $result['redirect'] );
exit;
endif;
endif;
else :
// No payment was required for order
$order->payment_complete();
// Empty the Cart
jigoshop_cart::empty_cart();
// Redirect to success/confirmation/payment page
if (is_ajax()) :
ob_clean();
echo json_encode( array('redirect' => get_permalink(get_option('jigoshop_thanks_page_id'))) );
exit;
else :
wp_safe_redirect( get_permalink(get_option('jigoshop_thanks_page_id')) );
exit;
endif;
endif;
// Break out of loop
break;
endwhile;
endif;
// If we reached this point then there were errors
if (is_ajax()) :
ob_clean();
jigoshop::show_messages();
exit;
else :
jigoshop::show_messages();
endif;
endif;
}
/** Gets the value either from the posted data, or from the users meta data */
function get_value( $input ) {
if (isset( $this->posted[$input] ) && !empty($this->posted[$input])) :
return $this->posted[$input];
elseif (is_user_logged_in()) :
if (get_user_meta( get_current_user_id(), $input, true )) return get_user_meta( get_current_user_id(), $input, true );
$current_user = wp_get_current_user();
switch ( $input ) :
case "billing-email" :
return $current_user->user_email;
break;
endswitch;
endif;
}
}

View File

@ -0,0 +1,574 @@
<?php
/**
* Jigoshop countries
* @class jigoshop_countries
*
* The JigoShop countries class stores country/state data.
*
* @author Jigowatt
* @category Classes
* @package JigoShop
*/
class jigoshop_countries {
public static $countries = array(
'AD' => 'Andorra',
'AE' => 'United Arab Emirates',
'AF' => 'Afghanistan',
'AG' => 'Antigua and Barbuda',
'AI' => 'Anguilla',
'AL' => 'Albania',
'AM' => 'Armenia',
'AN' => 'Netherlands Antilles',
'AO' => 'Angola',
'AQ' => 'Antarctica',
'AR' => 'Argentina',
'AS' => 'American Samoa',
'AT' => 'Austria',
'AU' => 'Australia',
'AW' => 'Aruba',
'AX' => 'Aland Islands',
'AZ' => 'Azerbaijan',
'BA' => 'Bosnia and Herzegovina',
'BB' => 'Barbados',
'BD' => 'Bangladesh',
'BE' => 'Belgium',
'BF' => 'Burkina Faso',
'BG' => 'Bulgaria',
'BH' => 'Bahrain',
'BI' => 'Burundi',
'BJ' => 'Benin',
'BL' => 'Saint Barthélemy',
'BM' => 'Bermuda',
'BN' => 'Brunei',
'BO' => 'Bolivia',
'BR' => 'Brazil',
'BS' => 'Bahamas',
'BT' => 'Bhutan',
'BV' => 'Bouvet Island',
'BW' => 'Botswana',
'BY' => 'Belarus',
'BZ' => 'Belize',
'CA' => 'Canada',
'CC' => 'Cocos (Keeling) Islands',
'CD' => 'Congo (Kinshasa)',
'CF' => 'Central African Republic',
'CG' => 'Congo (Brazzaville)',
'CH' => 'Switzerland',
'CI' => 'Ivory Coast',
'CK' => 'Cook Islands',
'CL' => 'Chile',
'CM' => 'Cameroon',
'CN' => 'China',
'CO' => 'Colombia',
'CR' => 'Costa Rica',
'CU' => 'Cuba',
'CV' => 'Cape Verde',
'CX' => 'Christmas Island',
'CY' => 'Cyprus',
'CZ' => 'Czech Republic',
'DE' => 'Germany',
'DJ' => 'Djibouti',
'DK' => 'Denmark',
'DM' => 'Dominica',
'DO' => 'Dominican Republic',
'DZ' => 'Algeria',
'EC' => 'Ecuador',
'EE' => 'Estonia',
'EG' => 'Egypt',
'EH' => 'Western Sahara',
'ER' => 'Eritrea',
'ES' => 'Spain',
'ET' => 'Ethiopia',
'FI' => 'Finland',
'FJ' => 'Fiji',
'FK' => 'Falkland Islands',
'FM' => 'Micronesia',
'FO' => 'Faroe Islands',
'FR' => 'France',
'GA' => 'Gabon',
'GB' => 'United Kingdom',
'GD' => 'Grenada',
'GE' => 'Georgia',
'GF' => 'French Guiana',
'GG' => 'Guernsey',
'GH' => 'Ghana',
'GI' => 'Gibraltar',
'GL' => 'Greenland',
'GM' => 'Gambia',
'GN' => 'Guinea',
'GP' => 'Guadeloupe',
'GQ' => 'Equatorial Guinea',
'GR' => 'Greece',
'GS' => 'South Georgia and the South Sandwich Islands',
'GT' => 'Guatemala',
'GU' => 'Guam',
'GW' => 'Guinea-Bissau',
'GY' => 'Guyana',
'HK' => 'Hong Kong S.A.R., China',
'HM' => 'Heard Island and McDonald Islands',
'HN' => 'Honduras',
'HR' => 'Croatia',
'HT' => 'Haiti',
'HU' => 'Hungary',
'ID' => 'Indonesia',
'IE' => 'Ireland',
'IL' => 'Israel',
'IM' => 'Isle of Man',
'IN' => 'India',
'IO' => 'British Indian Ocean Territory',
'IQ' => 'Iraq',
'IR' => 'Iran',
'IS' => 'Iceland',
'IT' => 'Italy',
'JE' => 'Jersey',
'JM' => 'Jamaica',
'JO' => 'Jordan',
'JP' => 'Japan',
'KE' => 'Kenya',
'KG' => 'Kyrgyzstan',
'KH' => 'Cambodia',
'KI' => 'Kiribati',
'KM' => 'Comoros',
'KN' => 'Saint Kitts and Nevis',
'KP' => 'North Korea',
'KR' => 'South Korea',
'KW' => 'Kuwait',
'KY' => 'Cayman Islands',
'KZ' => 'Kazakhstan',
'LA' => 'Laos',
'LB' => 'Lebanon',
'LC' => 'Saint Lucia',
'LI' => 'Liechtenstein',
'LK' => 'Sri Lanka',
'LR' => 'Liberia',
'LS' => 'Lesotho',
'LT' => 'Lithuania',
'LU' => 'Luxembourg',
'LV' => 'Latvia',
'LY' => 'Libya',
'MA' => 'Morocco',
'MC' => 'Monaco',
'MD' => 'Moldova',
'ME' => 'Montenegro',
'MF' => 'Saint Martin (French part)',
'MG' => 'Madagascar',
'MH' => 'Marshall Islands',
'MK' => 'Macedonia',
'ML' => 'Mali',
'MM' => 'Myanmar',
'MN' => 'Mongolia',
'MO' => 'Macao S.A.R., China',
'MP' => 'Northern Mariana Islands',
'MQ' => 'Martinique',
'MR' => 'Mauritania',
'MS' => 'Montserrat',
'MT' => 'Malta',
'MU' => 'Mauritius',
'MV' => 'Maldives',
'MW' => 'Malawi',
'MX' => 'Mexico',
'MY' => 'Malaysia',
'MZ' => 'Mozambique',
'NA' => 'Namibia',
'NC' => 'New Caledonia',
'NE' => 'Niger',
'NF' => 'Norfolk Island',
'NG' => 'Nigeria',
'NI' => 'Nicaragua',
'NL' => 'Netherlands',
'NO' => 'Norway',
'NP' => 'Nepal',
'NR' => 'Nauru',
'NU' => 'Niue',
'NZ' => 'New Zealand',
'OM' => 'Oman',
'PA' => 'Panama',
'PE' => 'Peru',
'PF' => 'French Polynesia',
'PG' => 'Papua New Guinea',
'PH' => 'Philippines',
'PK' => 'Pakistan',
'PL' => 'Poland',
'PM' => 'Saint Pierre and Miquelon',
'PN' => 'Pitcairn',
'PR' => 'Puerto Rico',
'PS' => 'Palestinian Territory',
'PT' => 'Portugal',
'PW' => 'Palau',
'PY' => 'Paraguay',
'QA' => 'Qatar',
'RE' => 'Reunion',
'RO' => 'Romania',
'RS' => 'Serbia',
'RU' => 'Russia',
'RW' => 'Rwanda',
'SA' => 'Saudi Arabia',
'SB' => 'Solomon Islands',
'SC' => 'Seychelles',
'SD' => 'Sudan',
'SE' => 'Sweden',
'SG' => 'Singapore',
'SH' => 'Saint Helena',
'SI' => 'Slovenia',
'SJ' => 'Svalbard and Jan Mayen',
'SK' => 'Slovakia',
'SL' => 'Sierra Leone',
'SM' => 'San Marino',
'SN' => 'Senegal',
'SO' => 'Somalia',
'SR' => 'Suriname',
'ST' => 'Sao Tome and Principe',
'SV' => 'El Salvador',
'SY' => 'Syria',
'SZ' => 'Swaziland',
'TC' => 'Turks and Caicos Islands',
'TD' => 'Chad',
'TF' => 'French Southern Territories',
'TG' => 'Togo',
'TH' => 'Thailand',
'TJ' => 'Tajikistan',
'TK' => 'Tokelau',
'TL' => 'Timor-Leste',
'TM' => 'Turkmenistan',
'TN' => 'Tunisia',
'TO' => 'Tonga',
'TR' => 'Turkey',
'TT' => 'Trinidad and Tobago',
'TV' => 'Tuvalu',
'TW' => 'Taiwan',
'TZ' => 'Tanzania',
'UA' => 'Ukraine',
'UG' => 'Uganda',
'UM' => 'United States Minor Outlying Islands',
'US' => 'United States',
'UY' => 'Uruguay',
'UZ' => 'Uzbekistan',
'VA' => 'Vatican',
'VC' => 'Saint Vincent and the Grenadines',
'VE' => 'Venezuela',
'VG' => 'British Virgin Islands',
'VI' => 'U.S. Virgin Islands',
'VN' => 'Vietnam',
'VU' => 'Vanuatu',
'WF' => 'Wallis and Futuna',
'WS' => 'Samoa',
'YE' => 'Yemen',
'YT' => 'Mayotte',
'ZA' => 'South Africa',
'ZM' => 'Zambia',
'ZW' => 'Zimbabwe',
'USAF' => 'US Armed Forces' ,
'VE' => 'Venezuela',
);
public static $states = array(
'AU' => array(
'ACT' => 'Australian Capital Territory' ,
'NSW' => 'New South Wales' ,
'NT' => 'Northern Territory' ,
'QLD' => 'Queensland' ,
'SA' => 'South Australia' ,
'TAS' => 'Tasmania' ,
'VIC' => 'Victoria' ,
'WA' => 'Western Australia'
),
'CA' => array(
'AB' => 'Alberta' ,
'BC' => 'British Columbia' ,
'MB' => 'Manitoba' ,
'NB' => 'New Brunswick' ,
'NF' => 'Newfoundland' ,
'NT' => 'Northwest Territories' ,
'NS' => 'Nova Scotia' ,
'NU' => 'Nunavut' ,
'ON' => 'Ontario' ,
'PE' => 'Prince Edward Island' ,
'PQ' => 'Quebec' ,
'SK' => 'Saskatchewan' ,
'YT' => 'Yukon Territory'
),
/*'GB' => array(
'England' => array(
'Avon' => 'Avon',
'Bedfordshire' => 'Bedfordshire',
'Berkshire' => 'Berkshire',
'Bristol' => 'Bristol',
'Buckinghamshire' => 'Buckinghamshire',
'Cambridgeshire' => 'Cambridgeshire',
'Cheshire' => 'Cheshire',
'Cleveland' => 'Cleveland',
'Cornwall' => 'Cornwall',
'Cumbria' => 'Cumbria',
'Derbyshire' => 'Derbyshire',
'Devon' => 'Devon',
'Dorset' => 'Dorset',
'Durham' => 'Durham',
'East Riding of Yorkshire' => 'East Riding of Yorkshire',
'East Sussex' => 'East Sussex',
'Essex' => 'Essex',
'Gloucestershire' => 'Gloucestershire',
'Greater Manchester' => 'Greater Manchester',
'Hampshire' => 'Hampshire',
'Herefordshire' => 'Herefordshire',
'Hertfordshire' => 'Hertfordshire',
'Humberside' => 'Humberside',
'Isle of Wight' => 'Isle of Wight',
'Isles of Scilly' => 'Isles of Scilly',
'Kent' => 'Kent',
'Lancashire' => 'Lancashire',
'Leicestershire' => 'Leicestershire',
'Lincolnshire' => 'Lincolnshire',
'London' => 'London',
'Merseyside' => 'Merseyside',
'Middlesex' => 'Middlesex',
'Norfolk' => 'Norfolk',
'North Yorkshire' => 'North Yorkshire',
'Northamptonshire' => 'Northamptonshire',
'Northumberland' => 'Northumberland',
'Nottinghamshire' => 'Nottinghamshire',
'Oxfordshire' => 'Oxfordshire',
'Rutland' => 'Rutland',
'Shropshire' => 'Shropshire',
'Somerset' => 'Somerset',
'South Yorkshire' => 'South Yorkshire',
'Staffordshire' => 'Staffordshire',
'Suffolk' => 'Suffolk',
'Surrey' => 'Surrey',
'Tyne and Wear' => 'Tyne and Wear',
'Warwickshire' => 'Warwickshire',
'West Midlands' => 'West Midlands',
'West Sussex' => 'West Sussex',
'West Yorkshire' => 'West Yorkshire',
'Wiltshire' => 'Wiltshire',
'Worcestershire' => 'Worcestershire'
),
'Northern Ireland' => array(
'Antrim' => 'Antrim',
'Armagh' => 'Armagh',
'Down' => 'Down',
'Fermanagh' => 'Fermanagh',
'Londonderry' => 'Londonderry',
'Tyrone' => 'Tyrone'
),
'Scotland' => array(
'Aberdeen City' => 'Aberdeen City',
'Aberdeenshire' => 'Aberdeenshire',
'Angus' => 'Angus',
'Argyll and Bute' => 'Argyll and Bute',
'Borders' => 'Borders',
'Clackmannan' => 'Clackmannan',
'Dumfries and Galloway' => 'Dumfries and Galloway',
'East Ayrshire' => 'East Ayrshire',
'East Dunbartonshire' => 'East Dunbartonshire',
'East Lothian' => 'East Lothian',
'East Renfrewshire' => 'East Renfrewshire',
'Edinburgh City' => 'Edinburgh City',
'Falkirk' => 'Falkirk',
'Fife' => 'Fife',
'Glasgow' => 'Glasgow',
'Highland' => 'Highland',
'Inverclyde' => 'Inverclyde',
'Midlothian' => 'Midlothian',
'Moray' => 'Moray',
'North Ayrshire' => 'North Ayrshire',
'North Lanarkshire' => 'North Lanarkshire',
'Orkney' => 'Orkney',
'Perthshire and Kinross' => 'Perthshire and Kinross',
'Renfrewshire' => 'Renfrewshire',
'Roxburghshire' => 'Roxburghshire',
'Shetland' => 'Shetland',
'South Ayrshire' => 'South Ayrshire',
'South Lanarkshire' => 'South Lanarkshire',
'Stirling' => 'Stirling',
'West Dunbartonshire' => 'West Dunbartonshire',
'West Lothian' => 'West Lothian',
'Western Isles' => 'Western Isles',
),
'Wales' => array(
'Blaenau Gwent' => 'Blaenau Gwent',
'Bridgend' => 'Bridgend',
'Caerphilly' => 'Caerphilly',
'Cardiff' => 'Cardiff',
'Carmarthenshire' => 'Carmarthenshire',
'Ceredigion' => 'Ceredigion',
'Conwy' => 'Conwy',
'Denbighshire' => 'Denbighshire',
'Flintshire' => 'Flintshire',
'Gwynedd' => 'Gwynedd',
'Isle of Anglesey' => 'Isle of Anglesey',
'Merthyr Tydfil' => 'Merthyr Tydfil',
'Monmouthshire' => 'Monmouthshire',
'Neath Port Talbot' => 'Neath Port Talbot',
'Newport' => 'Newport',
'Pembrokeshire' => 'Pembrokeshire',
'Powys' => 'Powys',
'Rhondda Cynon Taff' => 'Rhondda Cynon Taff',
'Swansea' => 'Swansea',
'Torfaen' => 'Torfaen',
'The Vale of Glamorgan' => 'The Vale of Glamorgan',
'Wrexham' => 'Wrexham'
)
),*/
'US' => array(
'AL' => 'Alabama' ,
'AK' => 'Alaska ' ,
'AZ' => 'Arizona' ,
'AR' => 'Arkansas' ,
'CA' => 'California' ,
'CO' => 'Colorado' ,
'CT' => 'Connecticut' ,
'DE' => 'Delaware' ,
'DC' => 'District Of Columbia' ,
'FL' => 'Florida' ,
'GA' => 'Georgia' ,
'HI' => 'Hawaii' ,
'ID' => 'Idaho' ,
'IL' => 'Illinois' ,
'IN' => 'Indiana' ,
'IA' => 'Iowa' ,
'KS' => 'Kansas' ,
'KY' => 'Kentucky' ,
'LA' => 'Louisiana' ,
'ME' => 'Maine' ,
'MD' => 'Maryland' ,
'MA' => 'Massachusetts' ,
'MI' => 'Michigan' ,
'MN' => 'Minnesota' ,
'MS' => 'Mississippi' ,
'MO' => 'Missouri' ,
'MT' => 'Montana' ,
'NE' => 'Nebraska' ,
'NV' => 'Nevada' ,
'NH' => 'New Hampshire' ,
'NJ' => 'New Jersey' ,
'NM' => 'New Mexico' ,
'NY' => 'New York' ,
'NC' => 'North Carolina' ,
'ND' => 'North Dakota' ,
'OH' => 'Ohio' ,
'OK' => 'Oklahoma' ,
'OR' => 'Oregon' ,
'PA' => 'Pennsylvania' ,
'RI' => 'Rhode Island' ,
'SC' => 'South Carolina' ,
'SD' => 'South Dakota' ,
'TN' => 'Tennessee' ,
'TX' => 'Texas' ,
'UT' => 'Utah' ,
'VT' => 'Vermont' ,
'VA' => 'Virginia' ,
'WA' => 'Washington' ,
'WV' => 'West Virginia' ,
'WI' => 'Wisconsin' ,
'WY' => 'Wyoming'
),
'USAF' => array(
'AA' => 'Americas' ,
'AE' => 'Europe' ,
'AP' => 'Pacific'
)
);
/** get base country */
function get_base_country() {
$default = get_option('jigoshop_default_country');
if (strstr($default, ':')) :
$country = current(explode(':', $default));
$state = end(explode(':', $default));
else :
$country = $default;
$state = '';
endif;
return $country;
}
/** get base state */
function get_base_state() {
$default = get_option('jigoshop_default_country');
if (strstr($default, ':')) :
$country = current(explode(':', $default));
$state = end(explode(':', $default));
else :
$country = $default;
$state = '';
endif;
return $state;
}
/** get countries we allow only */
function get_allowed_countries() {
$countries = self::$countries;
asort($countries);
if (get_option('jigoshop_allowed_countries')!=='specific') return $countries;
$allowed_countries = array();
$allowed_countries_raw = get_option('jigoshop_specific_allowed_countries');
foreach ($allowed_countries_raw as $country) :
$allowed_countries[$country] = $countries[$country];
endforeach;
asort($allowed_countries);
return $allowed_countries;
}
/** Gets the correct string for shipping - ether 'to the' or 'to' */
function shipping_to_prefix() {
$return = '';
if (in_array(jigoshop_customer::get_country(), array( 'GB', 'US', 'AE', 'CZ', 'DO', 'NL', 'PH', 'USAF' ))) $return = __('to the', 'jigoshop');
else $return = __('to', 'jigoshop');
$return = apply_filters('shipping_to_prefix', $return, jigoshop_customer::get_shipping_country());
return $return;
}
function estimated_for_prefix() {
$return = '';
if (in_array(jigoshop_customer::get_country(), array( 'GB', 'US', 'AE', 'CZ', 'DO', 'NL', 'PH', 'USAF' ))) $return = __('the ', 'jigoshop');
$return = apply_filters('estimated_for_prefix', $return, jigoshop_customer::get_shipping_country());
return $return;
}
/** get states */
function get_states( $cc ) {
if (isset( self::$states[$cc] )) return self::$states[$cc];
}
/** Outputs the list of countries and states for use in dropdown boxes */
function country_dropdown_options( $selected_country = '', $selected_state = '', $escape=false ) {
$countries = self::$countries;
asort($countries);
if ( $countries ) foreach ( $countries as $key=>$value) :
if ( $states = self::get_states($key) ) :
echo '<optgroup label="'.$value.'">';
echo '<option value="'.$key.'"';
if ($selected_country==$key && $selected_state=='*') echo ' selected="selected"';
echo '>'.$value.' &mdash; '.__('All states', 'jigoshop').'</option>';
foreach ($states as $state_key=>$state_value) :
echo '<option value="'.$key.':'.$state_key.'"';
if ($selected_country==$key && $selected_state==$state_key) echo ' selected="selected"';
echo '>'.$value.' &mdash; '. ($escape ? esc_js($state_value) : $state_value) .'</option>';
endforeach;
echo '</optgroup>';
else :
echo '<option';
if ($selected_country==$key && $selected_state=='*') echo ' selected="selected"';
echo ' value="'.$key.'">'. ($escape ? esc_js( __($value, 'jigoshop') ) : __($value, 'jigoshop') ) .'</option>';
endif;
endforeach;
}
}

View File

@ -0,0 +1,41 @@
<?php
/**
* Jigoshop coupons
* @class jigoshop_coupons
*
* The JigoShop coupons class gets coupon data from storage
*
* @author Jigowatt
* @category Classes
* @package JigoShop
*/
class jigoshop_coupons {
/** get coupons from the options database */
function get_coupons() {
$coupons = get_option('jigoshop_coupons') ? $coupons = (array) get_option('jigoshop_coupons') : $coupons = array();
return $coupons;
}
/** get coupon with $code */
function get_coupon($code) {
$coupons = get_option('jigoshop_coupons') ? $coupons = (array) get_option('jigoshop_coupons') : $coupons = array();
if (isset($coupons[$code])) return $coupons[$code];
return false;
}
/** Check coupon is valid by looking at cart */
function is_valid($code) {
$coupon = self::get_coupon($code);
if (sizeof($coupon['products'])>0) :
$valid = false;
if (sizeof(jigoshop_cart::$cart_contents)>0) : foreach (jigoshop_cart::$cart_contents as $item_id => $values) :
if (in_array($item_id, $coupon['products'])) :
$valid = true;
endif;
endforeach; endif;
return $valid;
endif;
return true;
}
}

View File

@ -0,0 +1,196 @@
<?php
/**
* Customer
* @class jigoshop_customer
*
* The JigoShop custoemr class handles storage of the current customer's data, such as location.
*
* @author Jigowatt
* @category Classes
* @package JigoShop
*/
class jigoshop_customer {
private static $_instance;
/** constructor */
function __construct() {
if ( !isset($_SESSION['customer']) ) :
$default = get_option('jigoshop_default_country');
if (strstr($default, ':')) :
$country = current(explode(':', $default));
$state = end(explode(':', $default));
else :
$country = $default;
$state = '';
endif;
$data = array(
'country' => $country,
'state' => $state,
'postcode' => '',
'shipping_country' => $country,
'shipping_state' => $state,
'shipping_postcode' => ''
);
$_SESSION['customer'] = $data;
endif;
}
/** get class instance */
public static function get() {
if (!isset(self::$_instance)) {
$c = __CLASS__;
self::$_instance = new $c;
}
return self::$_instance;
}
/** Is customer outside base country? */
public static function is_customer_outside_base() {
if (isset($_SESSION['customer']['country'])) :
$default = get_option('jigoshop_default_country');
if (strstr($default, ':')) :
$country = current(explode(':', $default));
$state = end(explode(':', $default));
else :
$country = $default;
$state = '';
endif;
if ($country!==$_SESSION['customer']['country']) return true;
endif;
return false;
}
/** Gets the state from the current session */
public static function get_state() {
if (isset($_SESSION['customer']['state'])) return $_SESSION['customer']['state'];
}
/** Gets the country from the current session */
public static function get_country() {
if (isset($_SESSION['customer']['country'])) return $_SESSION['customer']['country'];
}
/** Gets the postcode from the current session */
public static function get_postcode() {
if (isset($_SESSION['customer']['postcode'])) return strtolower(str_replace(' ', '', $_SESSION['customer']['postcode']));
}
/** Gets the state from the current session */
public static function get_shipping_state() {
if (isset($_SESSION['customer']['shipping_state'])) return $_SESSION['customer']['shipping_state'];
}
/** Gets the country from the current session */
public static function get_shipping_country() {
if (isset($_SESSION['customer']['shipping_country'])) return $_SESSION['customer']['shipping_country'];
}
/** Gets the postcode from the current session */
public static function get_shipping_postcode() {
if (isset($_SESSION['customer']['shipping_postcode'])) return strtolower(str_replace(' ', '', $_SESSION['customer']['shipping_postcode']));
}
/** Sets session data for the location */
public static function set_location( $country, $state, $postcode = '' ) {
$data = (array) $_SESSION['customer'];
$data['country'] = $country;
$data['state'] = $state;
$data['postcode'] = $postcode;
$_SESSION['customer'] = $data;
}
/** Sets session data for the country */
public static function set_country( $country ) {
$_SESSION['customer']['country'] = $country;
}
/** Sets session data for the state */
public static function set_state( $state ) {
$_SESSION['customer']['state'] = $state;
}
/** Sets session data for the postcode */
public static function set_postcode( $postcode ) {
$_SESSION['customer']['postcode'] = $postcode;
}
/** Sets session data for the location */
public static function set_shipping_location( $country, $state = '', $postcode = '' ) {
$data = (array) $_SESSION['customer'];
$data['shipping_country'] = $country;
$data['shipping_state'] = $state;
$data['shipping_postcode'] = $postcode;
$_SESSION['customer'] = $data;
}
/** Sets session data for the country */
public static function set_shipping_country( $country ) {
$_SESSION['customer']['shipping_country'] = $country;
}
/** Sets session data for the state */
public static function set_shipping_state( $state ) {
$_SESSION['customer']['shipping_state'] = $state;
}
/** Sets session data for the postcode */
public static function set_shipping_postcode( $postcode ) {
$_SESSION['customer']['shipping_postcode'] = $postcode;
}
/**
* Gets a user's downloadable products if they are logged in
*
* @return array downloads Array of downloadable products
*/
public static function get_downloadable_products() {
global $wpdb;
$downloads = array();
if (is_user_logged_in()) :
$jigoshop_orders = &new jigoshop_orders();
$jigoshop_orders->get_customer_orders( get_current_user_id() );
if ($jigoshop_orders->orders) foreach ($jigoshop_orders->orders as $order) :
if ( $order->status == 'completed' ) {
$results = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."jigoshop_downloadable_product_permissions WHERE order_key = \"".$order->order_key."\" AND user_id = ".get_current_user_id().";" );
$user_info = get_userdata(get_current_user_id());
if ($results) foreach ($results as $result) :
$_product = &new jigoshop_product( $result->product_id );
if ($_product->exists) :
$download_name = $_product->get_title();
else :
$download_name = '#' . $result->product_id;
endif;
$downloads[] = array(
'download_url' => add_query_arg('download_file', $result->product_id, add_query_arg('order', $result->order_key, add_query_arg('email', $user_info->user_email, home_url()))),
'product_id' => $result->product_id,
'download_name' => $download_name,
'order_key' => $result->order_key,
'downloads_remaining' => $result->downloads_remaining
);
endforeach;
}
endforeach;
endif;
return $downloads;
}
}

View File

@ -0,0 +1,404 @@
<?php
/**
* Order
* @class jigoshop_order
*
* The JigoShop order class handles order data.
*
* @author Jigowatt
* @category Classes
* @package JigoShop
*/
class jigoshop_order {
private $_data = array();
public function __get($variable) {
return isset($this->_data[$variable]) ? $this->_data[$variable] : null;
}
public function __set($variable, $value) {
$this->_data[$variable] = $value;
}
/** Get the order if ID is passed, otherwise the order is new and empty */
function jigoshop_order( $id='' ) {
if ($id>0) $this->get_order( $id );
}
/** Gets an order from the database */
function get_order( $id = 0 ) {
if (!$id) return false;
if ($result = get_post( $id )) :
$this->populate( $result );
return true;
endif;
return false;
}
/** Populates an order from the loaded post data */
function populate( $result ) {
// Standard post data
$this->id = $result->ID;
$this->order_date = $result->post_date;
$this->modified_date = $result->post_modified;
$this->customer_note = $result->post_excerpt;
// Custom field data
$this->order_key = (string) get_post_meta( $this->id, 'order_key', true );
$this->user_id = (int) get_post_meta( $this->id, 'customer_user', true );
$this->items = (array) get_post_meta( $this->id, 'order_items', true );
$this->order_data = (array) maybe_unserialize( get_post_meta( $this->id, 'order_data', true ) );
$this->billing_first_name = (string) $this->get_value_from_data('billing_first_name');
$this->billing_last_name = (string) $this->get_value_from_data('billing_last_name');
$this->billing_company = (string) $this->get_value_from_data('billing_company');
$this->billing_address_1 = (string) $this->get_value_from_data('billing_address_1');
$this->billing_address_2 = (string) $this->get_value_from_data('billing_address_2');
$this->billing_city = (string) $this->get_value_from_data('billing_city');
$this->billing_postcode = (string) $this->get_value_from_data('billing_postcode');
$this->billing_country = (string) $this->get_value_from_data('billing_country');
$this->billing_state = (string) $this->get_value_from_data('billing_state');
$this->billing_email = (string) $this->get_value_from_data('billing_email');
$this->billing_phone = (string) $this->get_value_from_data('billing_phone');
$this->shipping_first_name = (string) $this->get_value_from_data('shipping_first_name');
$this->shipping_last_name = (string) $this->get_value_from_data('shipping_last_name');
$this->shipping_company = (string) $this->get_value_from_data('shipping_company');
$this->shipping_address_1 = (string) $this->get_value_from_data('shipping_address_1');
$this->shipping_address_2 = (string) $this->get_value_from_data('shipping_address_2');
$this->shipping_city = (string) $this->get_value_from_data('shipping_city');
$this->shipping_postcode = (string) $this->get_value_from_data('shipping_postcode');
$this->shipping_country = (string) $this->get_value_from_data('shipping_country');
$this->shipping_state = (string) $this->get_value_from_data('shipping_state');
$this->shipping_method = (string) $this->get_value_from_data('shipping_method');
$this->payment_method = (string) $this->get_value_from_data('payment_method');
$this->order_subtotal = (string) $this->get_value_from_data('order_subtotal');
$this->order_shipping = (string) $this->get_value_from_data('order_shipping');
$this->order_discount = (string) $this->get_value_from_data('order_discount');
$this->order_tax = (string) $this->get_value_from_data('order_tax');
$this->order_shipping_tax = (string) $this->get_value_from_data('order_shipping_tax');
$this->order_total = (string) $this->get_value_from_data('order_total');
// Formatted Addresses
$formatted_address = array();
$country = ($this->billing_country && isset(jigoshop_countries::$countries[$this->billing_country])) ? jigoshop_countries::$countries[$this->billing_country] : $this->billing_country;
$address = array_map('trim', array(
$this->billing_address_1,
$this->billing_address_2,
$this->billing_city,
$this->billing_state,
$this->billing_postcode,
$country
));
foreach ($address as $part) if (!empty($part)) $formatted_address[] = $part;
$this->formatted_billing_address = implode(', ', $formatted_address);
if ($this->shipping_address_1) :
$formatted_address = array();
$country = ($this->shipping_country && isset(jigoshop_countries::$countries[$this->shipping_country])) ? jigoshop_countries::$countries[$this->shipping_country] : $this->shipping_country;
$address = array_map('trim', array(
$this->shipping_address_1,
$this->shipping_address_2,
$this->shipping_city,
$this->shipping_state,
$this->shipping_postcode,
$country
));
foreach ($address as $part) if (!empty($part)) $formatted_address[] = $part;
$this->formatted_shipping_address = implode(', ', $formatted_address);
endif;
// Taxonomy data
$terms = wp_get_object_terms( $this->id, 'shop_order_status' );
if (!is_wp_error($terms) && $terms) :
$term = current($terms);
$this->status = $term->slug;
else :
$this->status = 'pending';
endif;
}
function get_value_from_data( $key ) {
if (isset($this->order_data[$key])) return $this->order_data[$key]; else return '';
}
/** Gets shipping and product tax */
function get_total_tax() {
return $this->order_tax + $this->order_shipping_tax;
}
/** Gets subtotal */
function get_subtotal_to_display() {
$subtotal = jigoshop_price($this->order_subtotal);
if ($this->order_tax>0) :
$subtotal .= __(' <small>(ex. tax)</small>', 'jigoshop');
endif;
return $subtotal;
}
/** Gets shipping */
function get_shipping_to_display() {
if ($this->order_shipping > 0) :
$shipping = jigoshop_price($this->order_shipping);
if ($this->order_shipping_tax > 0) :
$shipping .= sprintf(__(' <small>(ex. tax) via %s</small>', 'jigoshop'), ucwords($this->shipping_method));
endif;
else :
$shipping = __('Free!', 'jigoshop');
endif;
return $shipping;
}
/** Get a product (either product or variation) */
function get_product_from_item( $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;
return $_product;
}
/** Output items for display in emails */
function email_order_items_list( $show_download_links = false, $show_sku = false ) {
$return = '';
foreach($this->items as $item) :
$_product = $this->get_product_from_item( $item );
$return .= $item['qty'] . ' x ' . apply_filters('jigoshop_order_product_title', $item['name'], $_product);
if ($show_sku) :
$return .= ' (#' . $_product->sku . ')';
endif;
$return .= ' - ' . strip_tags(jigoshop_price( $item['cost']*$item['qty'], array('ex_tax_label' => 1 )));
if (isset($_product->variation_data)) :
$return .= PHP_EOL . jigoshop_get_formatted_variation( $_product->variation_data, true );
endif;
if ($show_download_links) :
if ($_product->exists) :
if ($_product->is_type('downloadable')) :
$return .= PHP_EOL . ' - ' . $this->get_downloadable_file_url( $item['id'] ) . '';
endif;
endif;
endif;
$return .= PHP_EOL;
endforeach;
return $return;
}
/** Generates a URL so that a customer can checkout/pay for their (unpaid - pending) order via a link */
function get_checkout_payment_url() {
$payment_page = get_permalink(get_option('jigoshop_pay_page_id'));
if (get_option('jigoshop_force_ssl_checkout')=='yes' || is_ssl()) $payment_page = str_replace('http:', 'https:', $payment_page);
return add_query_arg('pay_for_order', 'true', add_query_arg('order', $this->order_key, add_query_arg('order_id', $this->id, $payment_page)));
}
/** Generates a URL so that a customer can cancel their (unpaid - pending) order */
function get_cancel_order_url() {
return jigoshop::nonce_url( 'cancel_order', add_query_arg('cancel_order', 'true', add_query_arg('order', $this->order_key, add_query_arg('order_id', $this->id, home_url()))));
}
/** Gets a downloadable products file url */
function get_downloadable_file_url( $item_id ) {
$user_email = $this->billing_email;
if ($this->user_id>0) :
$user_info = get_userdata($this->user_id);
if ($user_info->user_email) :
$user_email = $user_info->user_email;
endif;
endif;
return add_query_arg('download_file', $item_id, add_query_arg('order', $this->order_key, add_query_arg('email', $user_email, home_url())));
}
/**
* Adds a note (comment) to the order
*
* @param string $note Note to add
* @param int $private Currently unused
*/
function add_order_note( $note, $private = 1 ) {
$comment_post_ID = $this->id;
$comment_author = 'JigoShop';
$comment_author_email = 'jigoshop@' . str_replace('www.', '', str_replace('http://', '', site_url()));
$comment_author_url = '';
$comment_content = $note;
$comment_type = '';
$comment_parent = 0;
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
$commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] );
$commentdata['comment_agent'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 254);
$commentdata['comment_date'] = current_time('mysql');
$commentdata['comment_date_gmt'] = current_time('mysql', 1);
$comment_id = wp_insert_comment( $commentdata );
add_comment_meta($comment_id, 'private', $private);
}
/**
* Adds a note (comment) to the order
*
* @param string $new_status Status to change the order to
* @param string $note Optional note to add
*/
function update_status( $new_status, $note = '' ) {
if ($note) $note .= ' ';
$new_status = get_term_by( 'slug', sanitize_title( $new_status ), 'shop_order_status');
if ($new_status) :
wp_set_object_terms($this->id, $new_status->slug, 'shop_order_status');
if ( $this->status != $new_status->slug ) :
// Status was changed
do_action( 'order_status_'.$new_status->slug, $this->id );
do_action( 'order_status_'.$this->status.'_to_'.$new_status->slug, $this->id );
$this->add_order_note( $note . sprintf( __('Order status changed from %s to %s.', 'jigoshop'), $this->status, $new_status->slug ) );
clean_term_cache( '', 'shop_order_status' );
endif;
endif;
}
/**
* Cancel the order and restore the cart (before payment)
*
* @param string $note Optional note to add
*/
function cancel_order( $note = '' ) {
unset($_SESSION['order_awaiting_payment']);
$this->update_status('cancelled', $note);
}
/**
* When a payment is complete this function is called
*
* Most of the time this should mark an order as 'processing' so that admin can process/post the items
* If the cart contains only downloadable items then the order is 'complete' since the admin needs to take no action
* Stock levels are reduced at this point
*/
function payment_complete() {
unset($_SESSION['order_awaiting_payment']);
$downloadable_order = false;
if (sizeof($this->items)>0) foreach ($this->items as $item) :
if ($item['id']>0) :
$_product = $this->get_product_from_item( $item );
if ( $_product->exists && $_product->is_type('downloadable') ) :
$downloadable_order = true;
continue;
endif;
endif;
$downloadable_order = false;
break;
endforeach;
if ($downloadable_order) :
$this->update_status('completed');
else :
$this->update_status('processing');
endif;
// Payment is complete so reduce stock levels
$this->reduce_order_stock();
}
/**
* Reduce stock levels
*/
function reduce_order_stock() {
// Reduce stock levels and do any other actions with products in the cart
if (sizeof($this->items)>0) foreach ($this->items as $item) :
if ($item['id']>0) :
$_product = $this->get_product_from_item( $item );
if ( $_product->exists && $_product->managing_stock() ) :
$old_stock = $_product->stock;
$new_quantity = $_product->reduce_stock( $item['qty'] );
$this->add_order_note( sprintf( __('Item #%s stock reduced from %s to %s.', 'jigoshop'), $item['id'], $old_stock, $new_quantity) );
if ($new_quantity<0) :
do_action('jigoshop_product_on_backorder_notification', $item['id'], $item['qty']);
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', $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', $item['id']);
endif;
endif;
endif;
endforeach;
$this->add_order_note( __('Order item stock reduced successfully.', 'jigoshop') );
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* Orders
* @class jigoshop_orders
*
* The JigoShop orders class loads orders and calculates counts
*
* @author Jigowatt
* @category Classes
* @package JigoShop
*/
class jigoshop_orders {
var $orders;
var $count;
var $completed_count;
var $pending_count;
var $cancelled_count;
var $on_hold_count;
var $processing_count;
var $refunded_count;
/** Loads orders and counts them */
function jigoshop_orders() {
$this->orders = array();
// Get Counts
$this->pending_count = get_term_by( 'slug', 'pending', 'shop_order_status' )->count;
$this->completed_count = get_term_by( 'slug', 'completed', 'shop_order_status' )->count;
$this->cancelled_count = get_term_by( 'slug', 'cancelled', 'shop_order_status' )->count;
$this->on_hold_count = get_term_by( 'slug', 'on-hold', 'shop_order_status' )->count;
$this->refunded_count = get_term_by( 'slug', 'refunded', 'shop_order_status' )->count;
$this->processing_count = get_term_by( 'slug', 'processing', 'shop_order_status' )->count;
$this->count = wp_count_posts( 'shop_order' )->publish;
}
/**
* Loads a customers orders
*
* @param int $user_id ID of the user to load the orders for
* @param int $limit How many orders to load
*/
function get_customer_orders( $user_id, $limit = 5 ) {
$args = array(
'numberposts' => $limit,
'meta_key' => 'customer_user',
'meta_value' => $user_id,
'post_type' => 'shop_order',
'post_status' => 'publish'
);
$results = get_posts($args);
if ($results) :
foreach ($results as $result) :
$order = &new jigoshop_order();
$order->populate($result);
$this->orders[] = $order;
endforeach;
endif;
}
}

View File

@ -0,0 +1,560 @@
<?php
/**
* Product Class
* @class jigoshop_product
*
* The JigoShop product class handles individual product data.
*
* @author Jigowatt
* @category Classes
* @package JigoShop
*/
class jigoshop_product {
var $id;
var $exists;
var $data;
var $sku;
var $attributes;
var $post;
var $stock;
var $children;
var $visibility;
var $product_type;
var $price;
var $sale_price_dates_to;
var $sale_price_dates_from;
/**
* Loads all product data from custom fields
*
* @param int $id ID of the product to load
*/
function jigoshop_product( $id ) {
$this->id = $id;
$product_custom_fields = get_post_custom( $this->id );
if (isset($product_custom_fields['SKU'][0]) && !empty($product_custom_fields['SKU'][0])) $this->sku = $product_custom_fields['SKU'][0]; else $this->sku = $this->id;
if (isset($product_custom_fields['product_data'][0])) $this->data = maybe_unserialize( $product_custom_fields['product_data'][0] ); else $this->data = '';
if (isset($product_custom_fields['product_attributes'][0])) $this->attributes = maybe_unserialize( $product_custom_fields['product_attributes'][0] ); else $this->attributes = array();
if (isset($product_custom_fields['price'][0])) $this->price = $product_custom_fields['price'][0]; else $this->price = 0;
if (isset($product_custom_fields['visibility'][0])) $this->visibility = $product_custom_fields['visibility'][0]; else $this->visibility = 'hidden';
if (isset($product_custom_fields['stock'][0])) $this->stock = $product_custom_fields['stock'][0]; else $this->stock = 0;
// Again just in case, to fix WP bug
$this->data = maybe_unserialize( $this->data );
$this->attributes = maybe_unserialize( $this->attributes );
$terms = wp_get_object_terms( $id, 'product_type' );
if (!is_wp_error($terms) && $terms) :
$term = current($terms);
$this->product_type = $term->slug;
else :
$this->product_type = 'simple';
endif;
$this->get_children();
if ($this->data) :
$this->exists = true;
else :
$this->exists = false;
endif;
}
/** Returns the product's children */
function get_children() {
if (!is_array($this->children)) :
$this->children = array();
if ($this->is_type('variable')) $child_post_type = 'product_variation'; else $child_post_type = 'product';
if ( $children_products =& get_children( 'post_parent='.$this->id.'&post_type='.$child_post_type.'&orderby=menu_order&order=ASC' ) ) :
if ($children_products) foreach ($children_products as $child) :
if ($this->is_type('variable')) :
$child->product = &new jigoshop_product_variation( $child->ID );
else :
$child->product = &new jigoshop_product( $child->ID );
endif;
endforeach;
$this->children = (array) $children_products;
endif;
endif;
return $this->children;
}
/**
* Reduce stock level of the product
*
* @param int $by Amount to reduce by
*/
function reduce_stock( $by = 1 ) {
if ($this->managing_stock()) :
$reduce_to = $this->stock - $by;
update_post_meta($this->id, 'stock', $reduce_to);
return $reduce_to;
endif;
}
/**
* Increase stock level of the product
*
* @param int $by Amount to increase by
*/
function increase_stock( $by = 1 ) {
if ($this->managing_stock()) :
$increase_to = $this->stock + $by;
update_post_meta($this->id, 'stock', $increase_to);
return $increase_to;
endif;
}
/**
* Checks the product type
*
* @param string $type Type to check against
*/
function is_type( $type ) {
if (is_array($type) && in_array($this->product_type, $type)) return true;
elseif ($this->product_type==$type) return true;
return false;
}
/** Returns whether or not the product has any child product */
function has_child () {
return sizeof($this->children) ? true : false;
}
/** Returns whether or not the product post exists */
function exists() {
if ($this->exists) return true;
return false;
}
/** Returns whether or not the product is taxable */
function is_taxable() {
if (isset($this->data['tax_status']) && $this->data['tax_status']=='taxable') return true;
return false;
}
/** Returns whether or not the product shipping is taxable */
function is_shipping_taxable() {
if (isset($this->data['tax_status']) && ($this->data['tax_status']=='taxable' || $this->data['tax_status']=='shipping')) return true;
return false;
}
/** Get the product's post data */
function get_post_data() {
if (empty($this->post)) :
$this->post = get_post( $this->id );
endif;
return $this->post;
}
/** Get the title of the post */
function get_title () {
$this->get_post_data();
return apply_filters('jigoshop_product_title', $this->post->post_title, $this);
}
/** Get the add to url */
function add_to_cart_url() {
if ($this->is_type('variable')) :
$url = add_query_arg('add-to-cart', 'variation');
$url = add_query_arg('product', $this->id, $url);
elseif ( $this->has_child() ) :
$url = add_query_arg('add-to-cart', 'group');
$url = add_query_arg('product', $this->id, $url);
else :
$url = add_query_arg('add-to-cart', $this->id);
endif;
$url = jigoshop::nonce_url( 'add_to_cart', $url );
return $url;
}
/** Returns whether or not the product is stock managed */
function managing_stock() {
if (get_option('jigoshop_manage_stock')=='yes') :
if (isset($this->data['manage_stock']) && $this->data['manage_stock']=='yes') return true;
endif;
return false;
}
/** Returns whether or not the product is in stock */
function is_in_stock() {
if ($this->managing_stock()) :
if (!$this->backorders_allowed()) :
if ($this->stock==0 || $this->stock<0) :
return false;
else :
if ($this->data['stock_status']=='instock') return true;
return false;
endif;
else :
if ($this->data['stock_status']=='instock') return true;
return false;
endif;
endif;
return true;
}
/** Returns whether or not the product can be backordered */
function backorders_allowed() {
if ($this->data['backorders']=='yes' || $this->data['backorders']=='notify') return true;
return false;
}
/** Returns whether or not the product needs to notify the customer on backorder */
function backorders_require_notification() {
if ($this->data['backorders']=='notify') return true;
return false;
}
/** Returns whether or not the product has enough stock for the order */
function has_enough_stock( $quantity ) {
if ($this->backorders_allowed()) return true;
if ($this->stock >= $quantity) :
return true;
endif;
return false;
}
/** Returns the availability of the product */
function get_availability() {
$availability = "";
$class = "";
if (!$this->managing_stock()) :
if ($this->is_in_stock()) :
//$availability = __('In stock', 'jigoshop'); /* Lets not bother showing stock if its not managed and is available */
else :
$availability = __('Out of stock', 'jigoshop');
$class = 'out-of-stock';
endif;
else :
if ($this->is_in_stock()) :
if ($this->stock > 0) :
$availability = __('In stock', 'jigoshop');
if ($this->backorders_allowed()) :
if ($this->backorders_require_notification()) :
$availability .= ' &ndash; '.$this->stock.' ';
$availability .= __('available', 'jigoshop');
$availability .= __(' (backorders allowed)', 'jigoshop');
endif;
else :
$availability .= ' &ndash; '.$this->stock.' ';
$availability .= __('available', 'jigoshop');
endif;
else :
if ($this->backorders_allowed()) :
if ($this->backorders_require_notification()) :
$availability = __('Available on backorder', 'jigoshop');
else :
$availability = __('In stock', 'jigoshop');
endif;
else :
$availability = __('Out of stock', 'jigoshop');
$class = 'out-of-stock';
endif;
endif;
else :
if ($this->backorders_allowed()) :
$availability = __('Available on backorder', 'jigoshop');
else :
$availability = __('Out of stock', 'jigoshop');
$class = 'out-of-stock';
endif;
endif;
endif;
return array( 'availability' => $availability, 'class' => $class);
}
/** Returns whether or not the product is featured */
function is_featured() {
if (get_post_meta($this->id, 'featured', true)=='yes') return true;
return false;
}
/** Returns whether or not the product is visible */
function is_visible() {
if ($this->visibility=='hidden') return false;
if ($this->visibility=='visible') return true;
if ($this->visibility=='search' && is_search()) return true;
if ($this->visibility=='search' && !is_search()) return false;
if ($this->visibility=='catalog' && is_search()) return false;
if ($this->visibility=='catalog' && !is_search()) return true;
}
/** Returns whether or not the product is on sale */
function is_on_sale() {
if ( $this->has_child() ) :
$onsale = false;
foreach ($this->children as $child) :
if ( isset($child->product->data['sale_price']) && $child->product->data['sale_price']==$child->product->price ) :
return true;
endif;
endforeach;
else :
if ( isset($this->data['sale_price']) && $this->data['sale_price']==$this->price ) :
return true;
endif;
endif;
return false;
}
/** Returns the product's weight */
function get_weight() {
if ($this->data['weight']) return $this->data['weight'];
}
/** Returns the product's price */
function get_price() {
return $this->price;
/*if (!$price) $price = $this->price;
if (get_option('jigoshop_prices_include_tax')=='yes' && $this->is_taxable() && jigoshop_customer::is_customer_outside_base()) :
$_tax = &new jigoshop_tax();
$price = $price * 100;
$base_rate = $_tax->get_shop_base_rate( $this->data['tax_class'] );
$rate = $_tax->get_rate( $this->data['tax_class'] );
$base_tax_amount = round($_tax->calc_tax( $price, $base_rate, true ));
$tax_amount = round($_tax->calc_tax( ($price-$base_tax_amount), $rate, false ));
return ($price - $base_tax_amount + $tax_amount) / 100;
endif;
return $price;*/
}
/** Returns the price (excluding tax) */
function get_price_excluding_tax() {
$price = $this->price;
if (get_option('jigoshop_prices_include_tax')=='yes') :
if ( $rate = $this->get_tax_base_rate() ) :
if ( $rate>0 ) :
$_tax = &new jigoshop_tax();
$tax_amount = $_tax->calc_tax( $price, $rate, true );
$price = $price - $tax_amount;
endif;
endif;
endif;
return $price;
}
/** Returns the base tax rate */
function get_tax_base_rate() {
if ( $this->is_taxable() && get_option('jigoshop_calc_taxes')=='yes') :
$_tax = &new jigoshop_tax();
$rate = $_tax->get_shop_base_rate( $this->data['tax_class'] );
return $rate;
endif;
}
/** Returns the price in html format */
function get_price_html() {
$price = '';
if ( $this->has_child() ) :
$min_price = '';
$max_price = '';
foreach ($this->children as $child) :
$child_price = $child->product->get_price();
if ($child_price<$min_price || $min_price == '') $min_price = $child_price;
if ($child_price>$max_price || $max_price == '') $max_price = $child_price;
endforeach;
$price .= '<span class="from">' . __('From: ', 'jigoshop') . '</span>' . jigoshop_price($min_price);
elseif ($this->is_type('variable')) :
$price .= '<span class="from">' . __('From: ', 'jigoshop') . '</span>' . jigoshop_price($this->get_price());
else :
if ($this->price) :
if ($this->is_on_sale() && isset($this->data['regular_price'])) :
$price .= '<del>'.jigoshop_price( $this->data['regular_price'] ).'</del> <ins>'.jigoshop_price($this->get_price()).'</ins>';
else :
$price .= jigoshop_price($this->get_price());
endif;
endif;
endif;
return $price;
}
/** Returns the upsell product ids */
function get_upsells() {
if (isset($this->data['upsell_ids'])) return (array) $this->data['upsell_ids']; else return array();
}
/** Returns the crosssell product ids */
function get_cross_sells() {
if (isset($this->data['crosssell_ids'])) return (array) $this->data['crosssell_ids']; else return array();
}
/** Returns the product categories */
function get_categories( $sep = ', ', $before = '', $after = '' ) {
return get_the_term_list($this->id, 'product_cat', $before, $sep, $after);
}
/** Returns the product tags */
function get_tags( $sep = ', ', $before = '', $after = '' ) {
return get_the_term_list($this->id, 'product_tag', $before, $sep, $after);
}
/** Get and return related products */
function get_related( $limit = 5 ) {
global $wpdb, $all_post_ids;
// Related products are found from category and tag
$tags_array = array(0);
$cats_array = array(0);
$tags = '';
$cats = '';
// Get tags
$terms = wp_get_post_terms($this->id, 'product_tag');
foreach ($terms as $term) {
$tags_array[] = $term->term_id;
}
$tags = implode(',', $tags_array);
$terms = wp_get_post_terms($this->id, 'product_cat');
foreach ($terms as $term) {
$cats_array[] = $term->term_id;
}
$cats = implode(',', $cats_array);
$q = "
SELECT p.ID
FROM $wpdb->term_taxonomy AS tt, $wpdb->term_relationships AS tr, $wpdb->posts AS p, $wpdb->postmeta AS pm
WHERE
p.ID != $this->id
AND p.post_status = 'publish'
AND p.post_date_gmt < NOW()
AND p.post_type = 'product'
AND pm.meta_key = 'visibility'
AND pm.meta_value IN ('visible', 'catalog')
AND pm.post_id = p.ID
AND
(
(
tt.taxonomy ='product_cat'
AND tt.term_taxonomy_id = tr.term_taxonomy_id
AND tr.object_id = p.ID
AND tt.term_id IN ($cats)
)
OR
(
tt.taxonomy ='product_tag'
AND tt.term_taxonomy_id = tr.term_taxonomy_id
AND tr.object_id = p.ID
AND tt.term_id IN ($tags)
)
)
GROUP BY tr.object_id
ORDER BY RAND()
LIMIT $limit;";
$related = $wpdb->get_col($q);
return $related;
}
/** Returns product attributes */
function get_attributes() {
return $this->attributes;
}
/** Returns whether or not the product has any attributes set */
function has_attributes() {
if (isset($this->attributes) && sizeof($this->attributes)>0) :
foreach ($this->attributes as $attribute) :
if ($attribute['visible'] == 'yes') return true;
endforeach;
endif;
return false;
}
/** Lists a table of attributes for the product page */
function list_attributes() {
$attributes = $this->get_attributes();
if ($attributes && sizeof($attributes)>0) :
echo '<table cellspacing="0" class="shop_attributes">';
$alt = 1;
foreach ($attributes as $attribute) :
if ($attribute['visible'] == 'no') continue;
$alt = $alt*-1;
echo '<tr class="';
if ($alt==1) echo 'alt';
echo '"><th>'.wptexturize($attribute['name']).'</th><td>';
if (is_array($attribute['value'])) $attribute['value'] = implode(', ', $attribute['value']);
echo wpautop(wptexturize($attribute['value']));
echo '</td></tr>';
endforeach;
echo '</table>';
endif;
}
}

View File

@ -0,0 +1,174 @@
<?php
/**
* Product Variation Class
* @class jigoshop_product_variation
*
* The JigoShop product variation class handles product variation data.
*
* @author Jigowatt
* @category Classes
* @package JigoShop
*/
class jigoshop_product_variation extends jigoshop_product {
var $variation;
var $variation_data;
var $variation_id;
var $variation_has_weight;
var $variation_has_price;
var $variation_has_sale_price;
var $variation_has_stock;
var $variation_has_sku;
/**
* Loads all product data from custom fields
*
* @param int $id ID of the product to load
*/
function jigoshop_product_variation( $variation_id ) {
$this->variation_id = $variation_id;
$product_custom_fields = get_post_custom( $this->variation_id );
$this->variation_data = array();
foreach ($product_custom_fields as $name => $value) :
if (!strstr($name, 'tax_')) continue;
$this->variation_data[$name] = $value[0];
endforeach;
$this->get_variation_post_data();
/* Get main product data from parent */
$this->id = $this->variation->post_parent;
$parent_custom_fields = get_post_custom( $this->id );
if (isset($parent_custom_fields['SKU'][0]) && !empty($parent_custom_fields['SKU'][0])) $this->sku = $parent_custom_fields['SKU'][0]; else $this->sku = $this->id;
if (isset($parent_custom_fields['product_data'][0])) $this->data = maybe_unserialize( $parent_custom_fields['product_data'][0] ); else $this->data = '';
if (isset($parent_custom_fields['product_attributes'][0])) $this->attributes = maybe_unserialize( $parent_custom_fields['product_attributes'][0] ); else $this->attributes = array();
if (isset($parent_custom_fields['price'][0])) $this->price = $parent_custom_fields['price'][0]; else $this->price = 0;
if (isset($parent_custom_fields['visibility'][0])) $this->visibility = $parent_custom_fields['visibility'][0]; else $this->visibility = 'hidden';
if (isset($parent_custom_fields['stock'][0])) $this->stock = $parent_custom_fields['stock'][0]; else $this->stock = 0;
// Again just in case, to fix WP bug
$this->data = maybe_unserialize( $this->data );
$this->attributes = maybe_unserialize( $this->attributes );
$this->product_type = 'variable';
if ($this->data) :
$this->exists = true;
else :
$this->exists = false;
endif;
//parent::jigoshop_product( $this->variation->post_parent );
/* Pverride parent data with variation */
if (isset($product_custom_fields['SKU'][0]) && !empty($product_custom_fields['SKU'][0])) :
$this->variation_has_sku = true;
$this->sku = $product_custom_fields['SKU'][0];
endif;
if (isset($product_custom_fields['stock'][0]) && !empty($product_custom_fields['stock'][0])) :
$this->variation_has_stock = true;
$this->stock = $product_custom_fields['stock'][0];
endif;
if (isset($product_custom_fields['weight'][0]) && !empty($product_custom_fields['weight'][0])) :
$this->variation_has_weight = true;
$this->data['weight'] = $product_custom_fields['weight'][0];
endif;
if (isset($product_custom_fields['price'][0]) && !empty($product_custom_fields['price'][0])) :
$this->variation_has_price = true;
$this->price = $product_custom_fields['price'][0];
endif;
if (isset($product_custom_fields['sale_price'][0]) && !empty($product_custom_fields['sale_price'][0])) :
$this->variation_has_sale_price = true;
$this->data['sale_price'] = $product_custom_fields['sale_price'][0];
endif;
}
/** Get the product's post data */
function get_variation_post_data() {
if (empty($this->variation)) :
$this->variation = get_post( $this->variation_id );
endif;
return $this->variation;
}
/** Returns the product's price */
function get_price() {
if ($this->variation_has_price) :
if ($this->variation_has_sale_price) :
return $this->data['sale_price'];
else :
return $this->price;
endif;
else :
return parent::get_price();
endif;
}
/** Returns the price in html format */
function get_price_html() {
if ($this->variation_has_price) :
$price = '';
if ($this->price) :
if ($this->variation_has_sale_price) :
$price .= '<del>'.jigoshop_price( $this->price ).'</del> <ins>'.jigoshop_price( $this->data['sale_price'] ).'</ins>';
else :
$price .= jigoshop_price( $this->price );
endif;
endif;
return $price;
else :
return jigoshop_price(parent::get_price());
endif;
}
/**
* Reduce stock level of the product
*
* @param int $by Amount to reduce by
*/
function reduce_stock( $by = 1 ) {
if ($this->variation_has_stock) :
if ($this->managing_stock()) :
$reduce_to = $this->stock - $by;
update_post_meta($this->variation_id, 'stock', $reduce_to);
return $reduce_to;
endif;
else :
return parent::reduce_stock( $by );
endif;
}
/**
* Increase stock level of the product
*
* @param int $by Amount to increase by
*/
function increase_stock( $by = 1 ) {
if ($this->variation_has_stock) :
if ($this->managing_stock()) :
$increase_to = $this->stock + $by;
update_post_meta($this->variation_id, 'stock', $increase_to);
return $increase_to;
endif;
else :
return parent::increase_stock( $by );
endif;
}
}

View File

@ -0,0 +1,262 @@
<?php
/**
* Contains tax calculations
*
* @package JigoShop
* @category Tax
* @author Jigowatt
* @since 1.0
*/
class jigoshop_tax {
var $total;
var $rates;
/**
* Get the current tax class
*
* @return array
*/
function jigoshop_tax() {
$this->rates = $this->get_tax_rates();
}
/**
* Get an array of tax classes
*
* @return array
*/
function get_tax_classes() {
$classes = get_option('jigoshop_tax_classes');
$classes = explode("\n", $classes);
$classes = array_map('trim', $classes);
$classes_array = array();
if (sizeof($classes)>0) foreach ($classes as $class) :
if ($class) $classes_array[] = $class;
endforeach;
return $classes_array;
}
/**
* Get the tax rates as an array
*
* @return array
*/
function get_tax_rates() {
$tax_rates = get_option('jigoshop_tax_rates');
$tax_rates_array = array();
if ($tax_rates && is_array($tax_rates) && sizeof($tax_rates)>0) foreach( $tax_rates as $rate ) :
if ($rate['class']) :
$tax_rates_array[$rate['country']][$rate['state']][$rate['class']] = array( 'rate' => $rate['rate'], 'shipping' => $rate['shipping'] );
else :
// Standard Rate
$tax_rates_array[$rate['country']][$rate['state']]['*'] = $rate['rate'] = array( 'rate' => $rate['rate'], 'shipping' => $rate['shipping'] );
endif;
endforeach;
return $tax_rates_array;
}
/**
* Searches for a country / state tax rate
*
* @param string country
* @param string state
* @param object Tax Class
* @return int
*/
function find_rate( $country, $state = '*', $tax_class = '' ) {
$rate['rate'] = 0;
if (isset($this->rates[ $country ][ $state ])) :
if ($tax_class) :
if (isset($this->rates[ $country ][ $state ][$tax_class])) :
$rate = $this->rates[ $country ][ $state ][$tax_class];
endif;
else :
$rate = $this->rates[ $country ][ $state ][ '*' ];
endif;
elseif (isset($this->rates[ $country ][ '*' ])) :
if ($tax_class) :
if (isset($this->rates[ $country ][ '*' ][$tax_class])) :
$rate = $this->rates[ $country ][ '*' ][$tax_class];
endif;
else :
$rate = $this->rates[ $country ][ '*' ][ '*' ];
endif;
endif;
return $rate;
}
/**
* Get the current taxation rate using find_rate()
*
* @param object Tax Class
* @return int
*/
function get_rate( $tax_class = '' ) {
/* Checkout uses customer location, otherwise use store base rate */
if ( defined('JIGOSHOP_CHECKOUT') && JIGOSHOP_CHECKOUT ) :
$country = jigoshop_customer::get_country();
$state = jigoshop_customer::get_state();
$rate = $this->find_rate( $country, $state, $tax_class );
return $rate['rate'];
else :
return $this->get_shop_base_rate( $tax_class );
endif;
}
/**
* Get the shop's taxation rate using find_rate()
*
* @param object Tax Class
* @return int
*/
function get_shop_base_rate( $tax_class = '' ) {
$country = jigoshop_countries::get_base_country();
$state = jigoshop_countries::get_base_state();
$rate = $this->find_rate( $country, $state, $tax_class );
return $rate['rate'];
}
/**
* Get the tax rate based on the country and state
*
* @param object Tax Class
* @return mixed
*/
function get_shipping_tax_rate( $tax_class = '' ) {
if (defined('JIGOSHOP_CHECKOUT') && JIGOSHOP_CHECKOUT) :
$country = jigoshop_customer::get_country();
$state = jigoshop_customer::get_state();
else :
$country = jigoshop_countries::get_base_country();
$state = jigoshop_countries::get_base_state();
endif;
// If we are here then shipping is taxable - work it out
if ($tax_class) :
// This will be per item shipping
$rate = $this->find_rate( $country, $state, $tax_class );
if (isset($rate['shipping']) && $rate['shipping']=='yes') :
return $rate['rate'];
else :
// Get standard rate
$rate = $this->find_rate( $country, $state );
if (isset($rate['shipping']) && $rate['shipping']=='yes') return $rate['rate'];
endif;
else :
// This will be per order shipping - loop through the order and find the highest tax class rate
$found_rates = array();
$found_shipping_rates = array();
// Loop cart and find the highest tax band
if (sizeof(jigoshop_cart::$cart_contents)>0) : foreach (jigoshop_cart::$cart_contents as $item) :
if ($item['data']->data['tax_class']) :
$found_rate = $this->find_rate( $country, $state, $item['data']->data['tax_class'] );
$found_rates[] = $found_rate['rate'];
if (isset($found_rate['shipping']) && $found_rate['shipping']=='yes') $found_shipping_rates[] = $found_rate['rate'];
endif;
endforeach; endif;
if (sizeof($found_rates) > 0 && sizeof($found_shipping_rates) > 0) :
rsort($found_rates);
rsort($found_shipping_rates);
if ($found_rates[0] == $found_shipping_rates[0]) :
return $found_shipping_rates[0];
else :
// Use standard rate
$rate = $this->find_rate( $country, $state );
if (isset($rate['shipping']) && $rate['shipping']=='yes') return $rate['rate'];
endif;
else :
// Use standard rate
$rate = $this->find_rate( $country, $state );
if (isset($rate['shipping']) && $rate['shipping']=='yes') return $rate['rate'];
endif;
endif;
return 0; // return false
}
/**
* Calculate the tax using the final value
*
* @param int Price
* @param int Taxation Rate
* @return int
*/
function calc_tax( $price, $rate, $price_includes_tax = true ) {
// To avoid float roudning errors, work with integers (pence)
$price = round($price * 100, 0);
$math_rate = $rate;
if ($price_includes_tax) :
$math_rate = ($math_rate / 100) + 1;
//$price_ex = round($price / $math_rate);
//$tax_amount = round($price - $price_ex);
$price_ex = ($price / $math_rate);
$tax_amount = ($price - $price_ex);
else :
$tax_amount = $price * ($rate/100);
endif;
$tax_amount = $tax_amount / 100; // Back to pounds
return number_format($tax_amount, 4, '.', '');
//return number_format($tax_amount, 2, '.', '');
}
/**
* Calculate the shipping tax using the final value
*
* @param int Price
* @param int Taxation Rate
* @return int
*/
function calc_shipping_tax( $price, $rate ) {
$rate = round($rate, 4);
$tax_amount = $price * ($rate/100);
return round($tax_amount, 2);
}
}

View File

@ -0,0 +1,124 @@
<?php
/**
* Contains Validation functions
*
* @package JigoShop
* @category Validation
* @author Jigowatt
* @since 1.0
*/
class jigoshop_validation {
/**
* Validates an email using wordpress native is_email function
*
* @param string email address
* @return boolean
*/
public static function is_email( $email ) {
return is_email( $email );
}
/**
* Validates a phone number using a regular expression
*
* @param string phone number
* @return boolean
*/
public static function is_phone( $phone ) {
if (strlen(trim(preg_replace('/[\s\#0-9_\-\+\(\)]/', '', $phone)))>0) return false;
return true;
}
/**
* Checks for a valid postcode (UK)
*
* @param string postcode
* @param string country
* @return boolean
*/
public static function is_postcode( $postcode, $country ) {
if (strlen(trim(preg_replace('/[\s\-A-Za-z0-9]/', '', $postcode)))>0) return false;
if ($country=='GB') :
return self::is_GB_postcode( $postcode );
endif;
return true;
}
/* Author: John Gardner */
public static function is_GB_postcode( $toCheck ) {
// Permitted letters depend upon their position in the postcode.
$alpha1 = "[abcdefghijklmnoprstuwyz]"; // Character 1
$alpha2 = "[abcdefghklmnopqrstuvwxy]"; // Character 2
$alpha3 = "[abcdefghjkstuw]"; // Character 3
$alpha4 = "[abehmnprvwxy]"; // Character 4
$alpha5 = "[abdefghjlnpqrstuwxyz]"; // Character 5
// Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA
$pcexp[0] = '^('.$alpha1.'{1}'.$alpha2.'{0,1}[0-9]{1,2})([0-9]{1}'.$alpha5.'{2})$';
// Expression for postcodes: ANA NAA
$pcexp[1] = '^('.$alpha1.'{1}[0-9]{1}'.$alpha3.'{1})([0-9]{1}'.$alpha5.'{2})$';
// Expression for postcodes: AANA NAA
$pcexp[2] = '^('.$alpha1.'{1}'.$alpha2.'[0-9]{1}'.$alpha4.')([0-9]{1}'.$alpha5.'{2})$';
// Exception for the special postcode GIR 0AA
$pcexp[3] = '^(gir)(0aa)$';
// Standard BFPO numbers
$pcexp[4] = '^(bfpo)([0-9]{1,4})$';
// c/o BFPO numbers
$pcexp[5] = '^(bfpo)(c\/o[0-9]{1,3})$';
// Load up the string to check, converting into lowercase and removing spaces
$postcode = strtolower($toCheck);
$postcode = str_replace (' ', '', $postcode);
// Assume we are not going to find a valid postcode
$valid = false;
// Check the string against the six types of postcodes
foreach ($pcexp as $regexp) {
if (ereg($regexp,$postcode, $matches)) {
// Load new postcode back into the form element
$toCheck = strtoupper ($matches[1] . ' ' . $matches [2]);
// Take account of the special BFPO c/o format
$toCheck = ereg_replace ('C\/O', 'c/o ', $toCheck);
// Remember that we have found that the code is valid and break from loop
$valid = true;
break;
}
}
if ($valid){return true;} else {return false;};
}
/**
* Format the postcode according to the country and length of the postcode
*
* @param string postcode
* @param string country
* @return string formatted postcode
*/
public static function format_postcode( $postcode, $country ) {
$postcode = strtoupper(trim($postcode));
$postcode = trim(preg_replace('/[\s]/', '', $postcode));
if ($country=='GB') :
if (strlen($postcode)==7)
$postcode = substr_replace($postcode, ' ', 4, 0);
else
$postcode = substr_replace($postcode, ' ', 3, 0);
endif;
return $postcode;
}
}

108
gateways/cheque.php Executable file
View File

@ -0,0 +1,108 @@
<?php
/*
Provides a Cheque Payment Gateway for testing purposes.
Created by Andrew Benbow (andrew@chromeorange.co.uk)
*/
class jigoshop_cheque extends jigoshop_payment_gateway {
public function __construct() {
$this->id = 'cheque';
$this->icon = '';
$this->has_fields = false;
$this->enabled = get_option('jigoshop_cheque_enabled');
$this->title = get_option('jigoshop_cheque_title');
$this->description = get_option('jigoshop_cheque_description');
add_action('jigoshop_update_options', array(&$this, 'process_admin_options'));
add_option('jigoshop_cheque_enabled', 'yes');
add_option('jigoshop_cheque_title', __('Cheque Payment', 'jigoshop') );
add_option('jigoshop_cheque_description', __('Please send your cheque to Store Name, Store Street, Store Town, Store State / County, Store Postcode.', 'jigoshop'));
add_action('thankyou_cheque', array(&$this, 'thankyou_page'));
}
/**
* Admin Panel Options
* - Options for bits like 'title' and availability on a country-by-country basis
**/
public function admin_options() {
?>
<thead><tr><th scope="col" width="200px"><?php _e('Cheque Payment', 'jigoshop'); ?></th><th scope="col" class="desc"><?php _e('Allows cheque payments. Why would you take cheques in this day and age? Well you probably wouldn\'t but it does allow you to make test purchases without having to use the sandbox area of a payment gateway which is useful for demonstrating to clients and for testing order emails and the \'success\' pages etc.', 'jigoshop'); ?></th></tr></thead>
<tr>
<td class="titledesc"><?php _e('Enable Cheque Payment', 'jigoshop') ?>:</td>
<td class="forminp">
<select name="jigoshop_cheque_enabled" id="jigoshop_cheque_enabled" style="min-width:100px;">
<option value="yes" <?php if (get_option('jigoshop_cheque_enabled') == 'yes') echo 'selected="selected"'; ?>><?php _e('Yes', 'jigoshop'); ?></option>
<option value="no" <?php if (get_option('jigoshop_cheque_enabled') == 'no') echo 'selected="selected"'; ?>><?php _e('No', 'jigoshop'); ?></option>
</select>
</td>
</tr>
<tr>
<td class="titledesc"><a href="#" tip="<?php _e('This controls the title which the user sees during checkout.','jigoshop') ?>" class="tips" tabindex="99"></a><?php _e('Method Title', 'jigoshop') ?>:</td>
<td class="forminp">
<input class="input-text" type="text" name="jigoshop_cheque_title" id="jigoshop_cheque_title" value="<?php if ($value = get_option('jigoshop_cheque_title')) echo $value; else echo 'Cheque Payment'; ?>" />
</td>
</tr>
<tr>
<td class="titledesc"><a href="#" tip="<?php _e('Let the customer know the payee and where they should be sending the cheque too and that their order won\'t be shipping until you receive it.','jigoshop') ?>" class="tips" tabindex="99"></a><?php _e('Customer Message', 'jigoshop') ?>:</td>
<td class="forminp">
<input class="input-text wide-input" type="text" name="jigoshop_cheque_description" id="jigoshop_cheque_description" value="<?php if ($value = get_option('jigoshop_cheque_description')) echo $value; ?>" />
</td>
</tr>
<?php
}
/**
* There are no payment fields for cheques, but we want to show the description if set.
**/
function payment_fields() {
if ($this->description) echo wpautop(wptexturize($this->description));
}
function thankyou_page() {
if ($this->description) echo wpautop(wptexturize($this->description));
}
/**
* Admin Panel Options Processing
* - Saves the options to the DB
**/
public function process_admin_options() {
if(isset($_POST['jigoshop_cheque_enabled'])) update_option('jigoshop_cheque_enabled', jigowatt_clean($_POST['jigoshop_cheque_enabled'])); else @delete_option('jigoshop_cheque_enabled');
if(isset($_POST['jigoshop_cheque_title'])) update_option('jigoshop_cheque_title', jigowatt_clean($_POST['jigoshop_cheque_title'])); else @delete_option('jigoshop_cheque_title');
if(isset($_POST['jigoshop_cheque_description'])) update_option('jigoshop_cheque_description', jigowatt_clean($_POST['jigoshop_cheque_description'])); else @delete_option('jigoshop_cheque_description');
}
/**
* Process the payment and return the result
**/
function process_payment( $order_id ) {
$order = &new jigoshop_order( $order_id );
// Mark as on-hold (we're awaiting the cheque)
$order->update_status('on-hold', __('Awaiting cheque payment', 'jigoshop'));
// Remove cart
jigoshop_cart::empty_cart();
// Return thankyou redirect
return array(
'result' => 'success',
'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(get_option('jigoshop_thanks_page_id'))))
);
}
}
/**
* Add the gateway to JigoShop
**/
function add_cheque_gateway( $methods ) {
$methods[] = 'jigoshop_cheque'; return $methods;
}
add_filter('jigoshop_payment_gateways', 'add_cheque_gateway' );

View File

@ -0,0 +1,44 @@
<?php
/**
* Jigoshop Payment Gateway class
**/
class jigoshop_payment_gateway {
var $id;
var $title;
var $chosen;
var $has_fields;
var $countries;
var $availability;
var $enabled;
var $icon;
var $description;
function is_available() {
if ($this->enabled=="yes") :
return true;
endif;
return false;
}
function set_current() {
$this->chosen = true;
}
function icon() {
if ($this->icon) :
return '<img src="'. jigoshop::force_ssl($this->icon).'" alt="'.$this->title.'" />';
endif;
}
function admin_options() {}
function process_payment() {}
function validate_fields() { return true; }
}

View File

@ -0,0 +1,59 @@
<?php
/**
* Jigoshop Payment Gateways class
**/
class jigoshop_payment_gateways {
private static $instance;
static $payment_gateways;
public static function init() {
$load_gateways = apply_filters('jigoshop_payment_gateways', array());
foreach ($load_gateways as $gateway) :
self::$payment_gateways[] = &new $gateway();
endforeach;
}
public static function get() {
if (!isset(self::$instance)) {
$c = __CLASS__;
self::$instance = new $c;
}
return self::$instance;
}
function payment_gateways() {
$_available_gateways = array();
if (sizeof(self::$payment_gateways) > 0) :
foreach ( self::$payment_gateways as $gateway ) :
$_available_gateways[$gateway->id] = $gateway;
endforeach;
endif;
return $_available_gateways;
}
function get_available_payment_gateways() {
$_available_gateways = array();
foreach ( self::$payment_gateways as $gateway ) :
if ($gateway->is_available()) $_available_gateways[$gateway->id] = $gateway;
endforeach;
return $_available_gateways;
}
}

379
gateways/paypal.php Normal file
View File

@ -0,0 +1,379 @@
<?php
/**
* PayPal Standard Gateway
**/
class paypal extends jigoshop_payment_gateway {
public function __construct() {
$this->id = 'paypal';
$this->icon = jigoshop::plugin_url() . '/assets/images/icons/paypal.png';
$this->has_fields = false;
$this->enabled = get_option('jigoshop_paypal_enabled');
$this->title = get_option('jigoshop_paypal_title');
$this->email = get_option('jigoshop_paypal_email');
$this->description = get_option('jigoshop_paypal_description');
$this->liveurl = 'https://www.paypal.com/webscr';
$this->testurl = 'https://www.sandbox.paypal.com/webscr';
$this->testmode = get_option('jigoshop_paypal_testmode');
$this->send_shipping = get_option('jigoshop_paypal_send_shipping');
add_action( 'init', array(&$this, 'check_ipn_response') );
add_action('valid-paypal-standard-ipn-request', array(&$this, 'successful_request') );
add_action('jigoshop_update_options', array(&$this, 'process_admin_options'));
add_option('jigoshop_paypal_enabled', 'yes');
add_option('jigoshop_paypal_email', '');
add_option('jigoshop_paypal_title', __('PayPal', 'jigoshop') );
add_option('jigoshop_paypal_description', __("Pay via PayPal; you can pay with your credit card if you don't have a PayPal account", 'jigoshop') );
add_option('jigoshop_paypal_testmode', 'no');
add_option('jigoshop_paypal_send_shipping', 'no');
add_action('receipt_paypal', array(&$this, 'receipt_page'));
}
/**
* Admin Panel Options
* - Options for bits like 'title' and availability on a country-by-country basis
**/
public function admin_options() {
?>
<thead><tr><th scope="col" width="200px"><?php _e('PayPal standard', 'jigoshop'); ?></th><th scope="col" class="desc"><?php _e('PayPal standard works by sending the user to <a href="https://www.paypal.com/uk/mrb/pal=JFC9L8JJUZZK2">PayPal</a> to enter their payment information.', 'jigoshop'); ?></th></tr></thead>
<tr>
<td class="titledesc"><?php _e('Enable PayPal standard', 'jigoshop') ?>:</td>
<td class="forminp">
<select name="jigoshop_paypal_enabled" id="jigoshop_paypal_enabled" style="min-width:100px;">
<option value="yes" <?php if (get_option('jigoshop_paypal_enabled') == 'yes') echo 'selected="selected"'; ?>><?php _e('Yes', 'jigoshop'); ?></option>
<option value="no" <?php if (get_option('jigoshop_paypal_enabled') == 'no') echo 'selected="selected"'; ?>><?php _e('No', 'jigoshop'); ?></option>
</select>
</td>
</tr>
<tr>
<td class="titledesc"><a href="#" tip="<?php _e('This controls the title which the user sees during checkout.','jigoshop') ?>" class="tips" tabindex="99"></a><?php _e('Method Title', 'jigoshop') ?>:</td>
<td class="forminp">
<input class="input-text" type="text" name="jigoshop_paypal_title" id="jigoshop_paypal_title" style="min-width:50px;" value="<?php if ($value = get_option('jigoshop_paypal_title')) echo $value; else echo 'PayPal'; ?>" />
</td>
</tr>
<tr>
<td class="titledesc"><a href="#" tip="<?php _e('This controls the description which the user sees during checkout.','jigoshop') ?>" class="tips" tabindex="99"></a><?php _e('Description', 'jigoshop') ?>:</td>
<td class="forminp">
<input class="input-text wide-input" type="text" name="jigoshop_paypal_description" id="jigoshop_paypal_description" style="min-width:50px;" value="<?php if ($value = get_option('jigoshop_paypal_description')) echo $value; ?>" />
</td>
</tr>
<tr>
<td class="titledesc"><a href="#" tip="<?php _e('Please enter your PayPal email address; this is needed in order to take payment!','jigoshop') ?>" class="tips" tabindex="99"></a><?php _e('PayPal email address', 'jigoshop') ?>:</td>
<td class="forminp">
<input class="input-text" type="text" name="jigoshop_paypal_email" id="jigoshop_paypal_email" style="min-width:50px;" value="<?php if ($value = get_option('jigoshop_paypal_email')) echo $value; ?>" />
</td>
</tr>
<tr>
<td class="titledesc"><a href="#" tip="<?php _e('If your checkout page does not ask for shipping details, or if you do not want to send shipping information to PayPal, set this option to no. If you enable this option PayPal may restrict where things can be sent, and will prevent some orders going through for your protection.','jigoshop') ?>" class="tips" tabindex="99"></a><?php _e('Send shipping details to PayPal', 'jigoshop') ?>:</td>
<td class="forminp">
<select name="jigoshop_paypal_send_shipping" id="jigoshop_paypal_send_shipping" style="min-width:100px;">
<option value="yes" <?php if (get_option('jigoshop_paypal_send_shipping') == 'yes') echo 'selected="selected"'; ?>><?php _e('Yes', 'jigoshop'); ?></option>
<option value="no" <?php if (get_option('jigoshop_paypal_send_shipping') == 'no') echo 'selected="selected"'; ?>><?php _e('No', 'jigoshop'); ?></option>
</select>
</td>
</tr>
<tr>
<td class="titledesc"><?php _e('Enable PayPal sandbox', 'jigoshop') ?>:</td>
<td class="forminp">
<select name="jigoshop_paypal_testmode" id="jigoshop_paypal_testmode" style="min-width:100px;">
<option value="yes" <?php if (get_option('jigoshop_paypal_testmode') == 'yes') echo 'selected="selected"'; ?>><?php _e('Yes', 'jigoshop'); ?></option>
<option value="no" <?php if (get_option('jigoshop_paypal_testmode') == 'no') echo 'selected="selected"'; ?>><?php _e('No', 'jigoshop'); ?></option>
</select>
</td>
</tr>
<?php
}
/**
* There are no payment fields for paypal, but we want to show the description if set.
**/
function payment_fields() {
if ($jigoshop_paypal_description = get_option('jigoshop_paypal_description')) echo wpautop(wptexturize($jigoshop_paypal_description));
}
/**
* Admin Panel Options Processing
* - Saves the options to the DB
**/
public function process_admin_options() {
if(isset($_POST['jigoshop_paypal_enabled'])) update_option('jigoshop_paypal_enabled', jigowatt_clean($_POST['jigoshop_paypal_enabled'])); else @delete_option('jigoshop_paypal_enabled');
if(isset($_POST['jigoshop_paypal_title'])) update_option('jigoshop_paypal_title', jigowatt_clean($_POST['jigoshop_paypal_title'])); else @delete_option('jigoshop_paypal_title');
if(isset($_POST['jigoshop_paypal_email'])) update_option('jigoshop_paypal_email', jigowatt_clean($_POST['jigoshop_paypal_email'])); else @delete_option('jigoshop_paypal_email');
if(isset($_POST['jigoshop_paypal_description'])) update_option('jigoshop_paypal_description', jigowatt_clean($_POST['jigoshop_paypal_description'])); else @delete_option('jigoshop_paypal_description');
if(isset($_POST['jigoshop_paypal_testmode'])) update_option('jigoshop_paypal_testmode', jigowatt_clean($_POST['jigoshop_paypal_testmode'])); else @delete_option('jigoshop_paypal_testmode');
if(isset($_POST['jigoshop_paypal_send_shipping'])) update_option('jigoshop_paypal_send_shipping', jigowatt_clean($_POST['jigoshop_paypal_send_shipping'])); else @delete_option('jigoshop_paypal_send_shipping');
}
/**
* Generate the paypal button link
**/
public function generate_paypal_form( $order_id ) {
$order = &new jigoshop_order( $order_id );
if ( $this->testmode == 'yes' ):
$paypal_adr = $this->testurl . '?test_ipn=1&';
else :
$paypal_adr = $this->liveurl . '?';
endif;
$shipping_name = explode(' ', $order->shipping_method);
if (in_array($order->billing_country, array('US','CA'))) :
$phone_args = array(
'night_phone_a' => substr($order->billing_phone,0,3),
'night_phone_b' => substr($order->billing_phone,0,3),
'night_phone_c' => substr($order->billing_phone,0,3),
'day_phone_a' => substr($order->billing_phone,0,3),
'day_phone_b' => substr($order->billing_phone,0,3),
'day_phone_c' => substr($order->billing_phone,0,3)
);
else :
$phone_args = array(
'night_phone_b' => $order->billing_phone,
'day_phone_b' => $order->billing_phone
);
endif;
$paypal_args = array_merge(
array(
'cmd' => '_cart',
'business' => $this->email,
'no_note' => 1,
'currency_code' => get_option('jigoshop_currency'),
'charset' => 'UTF-8',
'rm' => 2,
'upload' => 1,
'return' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(get_option('jigoshop_thanks_page_id')))),
'cancel_return' => $order->get_cancel_order_url(),
//'cancel_return' => home_url(),
// Order key
'custom' => $order_id,
// IPN
'notify_url' => trailingslashit(get_bloginfo('wpurl')).'?paypalListener=paypal_standard_IPN',
// Address info
'first_name' => $order->billing_first_name,
'last_name' => $order->billing_last_name,
'company' => $order->billing_company,
'address1' => $order->billing_address_1,
'address2' => $order->billing_address_2,
'city' => $order->billing_city,
'state' => $order->billing_state,
'zip' => $order->billing_postcode,
'country' => $order->billing_country,
'email' => $order->billing_email,
// Payment Info
'invoice' => $order->order_key,
'tax' => $order->get_total_tax(),
'tax_cart' => $order->get_total_tax(),
'amount' => $order->order_total,
'discount_amount_cart' => $order->order_discount
),
$phone_args
);
if ($this->send_shipping=='yes') :
$paypal_args['no_shipping'] = 0;
$paypal_args['address_override'] = 1;
else :
$paypal_args['no_shipping'] = 1;
endif;
// Cart Contents
$item_loop = 0;
if (sizeof($order->items)>0) : foreach ($order->items as $item) :
$_product = &new jigoshop_product($item['id']);
if ($_product->exists() && $item['qty']) :
$item_loop++;
$paypal_args['item_name_'.$item_loop] = $_product->get_title();
$paypal_args['quantity_'.$item_loop] = $item['qty'];
$paypal_args['amount_'.$item_loop] = $_product->get_price_excluding_tax();
endif;
endforeach; endif;
// Shipping Cost
$item_loop++;
$paypal_args['item_name_'.$item_loop] = __('Shipping cost', 'jigoshop');
$paypal_args['quantity_'.$item_loop] = '1';
$paypal_args['amount_'.$item_loop] = number_format($order->order_shipping, 2);
$paypal_args_array = array();
foreach ($paypal_args as $key => $value) {
$paypal_args_array[] = '<input type="hidden" name="'.$key.'" value="'.$value.'" />';
}
return '<form action="'.$paypal_adr.'" method="post" id="paypal_payment_form">
' . implode('', $paypal_args_array) . '
<input type="submit" class="button-alt" id="submit_paypal_payment_form" value="'.__('Pay via PayPal', 'jigoshop').'" /> <a class="button cancel" href="'.$order->get_cancel_order_url().'">'.__('Cancel order &amp; restore cart', 'jigoshop').'</a>
<script type="text/javascript">
jQuery(function(){
jQuery("body").block(
{
message: "<img src=\"'.jigoshop::plugin_url().'/assets/images/ajax-loader.gif\" alt=\"Redirecting...\" />'.__('Thank you for your order. We are now redirecting you to PayPal to make payment.', 'jigoshop').'",
overlayCSS:
{
background: "#fff",
opacity: 0.6
},
css: {
padding: 20,
textAlign: "center",
color: "#555",
border: "3px solid #aaa",
backgroundColor:"#fff",
cursor: "wait"
}
});
jQuery("#submit_paypal_payment_form").click();
});
</script>
</form>';
}
/**
* Process the payment and return the result
**/
function process_payment( $order_id ) {
$order = &new jigoshop_order( $order_id );
return array(
'result' => 'success',
'redirect' => add_query_arg('order', $order->id, add_query_arg('key', $order->order_key, get_permalink(get_option('jigoshop_pay_page_id'))))
);
}
/**
* receipt_page
**/
function receipt_page( $order ) {
echo '<p>'.__('Thank you for your order, please click the button below to pay with PayPal.', 'jigoshop').'</p>';
echo $this->generate_paypal_form( $order );
}
/**
* Check PayPal IPN validity
**/
function check_ipn_request_is_valid() {
// Add cmd to the post array
$_POST['cmd'] = '_notify-validate';
// Send back post vars to paypal
$params = array( 'body' => $_POST );
// Get url
if ( $this->testmode == 'yes' ):
$paypal_adr = $this->testurl;
else :
$paypal_adr = $this->liveurl;
endif;
// Post back to get a response
$response = wp_remote_post( $paypal_adr, $params );
// Clean
unset($_POST['cmd']);
// check to see if the request was valid
if ( !is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && (strcmp( $response['body'], "VERIFIED") == 0)) {
return true;
}
return false;
}
/**
* Check for PayPal IPN Response
**/
function check_ipn_response() {
if (isset($_GET['paypalListener']) && $_GET['paypalListener'] == 'paypal_standard_IPN'):
$_POST = stripslashes_deep($_POST);
if (self::check_ipn_request_is_valid()) :
do_action("valid-paypal-standard-ipn-request", $_POST);
endif;
endif;
}
/**
* Successful Payment!
**/
function successful_request( $posted ) {
// Custom holds post ID
if ( !empty($posted['txn_type']) && !empty($posted['invoice']) ) {
$accepted_types = array('cart', 'instant', 'express_checkout', 'web_accept', 'masspay', 'send_money');
if (!in_array(strtolower($posted['txn_type']), $accepted_types)) exit;
$order = new jigoshop_order( (int) $posted['custom'] );
if ($order->order_key!==$posted['invoice']) exit;
// Sandbox fix
if ($posted['test_ipn']==1 && $posted['payment_status']=='Pending') $posted['payment_status'] = 'completed';
if ($order->status !== 'completed') :
// We are here so lets check status and do actions
switch (strtolower($posted['payment_status'])) :
case 'completed' :
// Payment completed
$order->add_order_note( __('IPN payment completed', 'jigoshop') );
$order->payment_complete();
break;
case 'denied' :
case 'expired' :
case 'failed' :
case 'voided' :
// Hold order
$order->update_status('on-hold', sprintf(__('Payment %s via IPN.', 'jigoshop'), strtolower(sanitize($posted['payment_status'])) ) );
break;
default:
// No action
break;
endswitch;
endif;
exit;
}
}
}
/**
* Add the gateway to JigoShop
**/
function add_paypal_gateway( $methods ) {
$methods[] = 'paypal'; return $methods;
}
add_filter('jigoshop_payment_gateways', 'add_paypal_gateway' );

300
gateways/skrill.php Normal file
View File

@ -0,0 +1,300 @@
<?php
/** Skrill Gateway **/
class skrill extends jigoshop_payment_gateway {
public function __construct() {
$this->id = 'skrill';
$this->title = 'Skrill';
$this->icon = jigoshop::plugin_url() . '/assets/images/icons/skrill.png';
$this->has_fields = false;
$this->enabled = get_option('jigoshop_skrill_enabled');
$this->title = get_option('jigoshop_skrill_title');
$this->email = get_option('jigoshop_skrill_email');
add_action( 'init', array(&$this, 'check_status_response') );
if(isset($_GET['skrillPayment']) && $_GET['skrillPayment'] == true):
add_action( 'init', array(&$this, 'generate_skrill_form') );
endif;
add_action('valid-skrill-status-report', array(&$this, 'successful_request') );
add_action('jigoshop_update_options', array(&$this, 'process_admin_options'));
add_option('jigoshop_skrill_enabled', 'yes');
add_option('jigoshop_skrill_email', '');
add_option('jigoshop_skrill_title', 'skrill');
add_action('receipt_skrill', array(&$this, 'receipt_skrill'));
}
/**
* Admin Panel Options
* - Options for bits like 'title' and availability on a country-by-country basis
**/
public function admin_options() {
?>
<thead><tr><th scope="col" width="200px"><?php _e('Skrill (Moneybookers)', 'jigoshop'); ?></th><th scope="col" class="desc"><?php _e('Skrill works by using an iFrame to submit payment information securely to Moneybookers.', 'jigoshop'); ?></th></tr></thead>
<tr>
<td class="titledesc"><?php _e('Enable Skrill', 'jigoshop') ?>:</td>
<td class="forminp">
<select name="jigoshop_skrill_enabled" id="jigoshop_skrill_enabled" style="min-width:100px;">
<option value="yes" <?php if (get_option('jigoshop_skrill_enabled') == 'yes') echo 'selected="selected"'; ?>><?php _e('Yes', 'jigoshop'); ?></option>
<option value="no" <?php if (get_option('jigoshop_skrill_enabled') == 'no') echo 'selected="selected"'; ?>><?php _e('No', 'jigoshop'); ?></option>
</select>
</td>
</tr>
<tr>
<td class="titledesc"><a href="#" tip="<?php _e('This controls the title which the user sees during checkout.','jigoshop') ?>" class="tips" tabindex="99"></a><?php _e('Method Title', 'jigoshop') ?>:</td>
<td class="forminp">
<input class="input-text" type="text" name="jigoshop_skrill_title" id="jigoshop_skrill_title" style="min-width:50px;" value="<?php if ($value = get_option('jigoshop_skrill_title')) echo $value; else echo 'skrill'; ?>" />
</td>
</tr>
<tr>
<td class="titledesc"><a href="#" tip="<?php _e('Please enter your skrill email address; this is needed in order to take payment!','jigoshop') ?>" class="tips" tabindex="99"></a><?php _e('Skrill merchant e-mail', 'jigoshop') ?>:</td>
<td class="forminp">
<input class="input-text" type="text" name="jigoshop_skrill_email" id="jigoshop_skrill_email" style="min-width:50px;" value="<?php if ($value = get_option('jigoshop_skrill_email')) echo $value; ?>" />
</td>
</tr>
<tr>
<td class="titledesc"><a href="#" tip="<?php _e('Please enter your skrill secretword; this is needed in order to take payment!','jigoshop') ?>" class="tips" tabindex="99"></a><?php _e('Skrill Secret Word', 'jigoshop') ?>:</td>
<td class="forminp">
<input class="input-text" type="text" name="jigoshop_skrill_secret_word" id="jigoshop_skrill_secret_word" style="min-width:50px;" value="<?php if ($value = get_option('jigoshop_skrill_secret_word')) echo $value; ?>" />
</td>
</tr>
<tr>
<td class="titledesc"><a href="#" tip="<?php _e('Please enter your skrill Customer ID; this is needed in order to take payment!','jigoshop') ?>" class="tips" tabindex="99"></a><?php _e('Skrill Customer ID', 'jigoshop') ?>:</td>
<td class="forminp">
<input class="input-text" type="text" name="jigoshop_skrill_customer_id" id="jigoshop_skrill_customer_id" style="min-width:50px;" value="<?php if ($value = get_option('jigoshop_skrill_customer_id')) echo $value; ?>" />
</td>
</tr>
<?php
}
/**
* Admin Panel Options Processing
* - Saves the options to the DB
**/
public function process_admin_options() {
if(isset($_POST['jigoshop_skrill_enabled'])) update_option('jigoshop_skrill_enabled', jigowatt_clean($_POST['jigoshop_skrill_enabled'])); else @delete_option('jigoshop_skrill_enabled');
if(isset($_POST['jigoshop_skrill_title'])) update_option('jigoshop_skrill_title', jigowatt_clean($_POST['jigoshop_skrill_title'])); else @delete_option('jigoshop_skrill_title');
if(isset($_POST['jigoshop_skrill_email'])) update_option('jigoshop_skrill_email', jigowatt_clean($_POST['jigoshop_skrill_email'])); else @delete_option('jigoshop_skrill_email');
if(isset($_POST['jigoshop_skrill_secret_word'])) update_option('jigoshop_skrill_secret_word', jigowatt_clean($_POST['jigoshop_skrill_secret_word'])); else @delete_option('jigoshop_skrill_secret_word');
if(isset($_POST['jigoshop_skrill_customer_id'])) update_option('jigoshop_skrill_customer_id', jigowatt_clean($_POST['jigoshop_skrill_customer_id'])); else @delete_option('jigoshop_skrill_customer_id');
}
/**
* Generate the skrill button link
**/
public function generate_skrill_form() {
$order_id = $_GET['orderId'];
$order = &new jigoshop_order( $order_id );
$skrill_adr = 'https://www.moneybookers.com/app/payment.pl';
$shipping_name = explode(' ', $order->shipping_method);
$order_total = trim($order->order_total, 0);
if( substr($order_total, -1) == '.' ) $order_total = str_replace('.', '', $order_total);
$skrill_args = array(
'merchant_fields' => 'partner',
'partner' => '21890813',
'pay_to_email' => $this->email,
'recipient_description' => get_bloginfo('name'),
'transaction_id' => $order_id,
'return_url' => get_permalink(get_option('jigoshop_thanks_page_id')),
'return_url_text' => 'Return to Merchant',
'new_window_redirect' => 0,
'rid' => 20521479,
'prepare_only' => 0,
'return_url_target' => 1,
'cancel_url' => trailingslashit(get_bloginfo('wpurl')).'?skrillListener=skrill_cancel',
'cancel_url_target' => 1,
'status_url' => trailingslashit(get_bloginfo('wpurl')).'?skrillListener=skrill_status',
'dynamic_descriptor' => 'Description',
'language' => 'EN',
'hide_login' => 1,
'confirmation_note' => 'Thank you for your custom',
'pay_from_email' => $order->billing_email,
//'title' => 'Mr',
'firstname' => $order->billing_first_name,
'lastname' => $order->billing_last_name,
'address' => $order->billing_address_1,
'address2' => $order->billing_address_2,
'phone_number' => $order->billing_phone,
'postal_code' => $order->billing_postcode,
'city' => $order->billing_city,
'state' => $order->billing_state,
'country' => 'GBR',
'amount' => $order_total,
'currency' => get_option('jigoshop_currency'),
'detail1_description' => 'Order ID',
'detail1_text'=> $order_id
);
// Cart Contents
$item_loop = 0;
if (sizeof($order->items)>0) : foreach ($order->items as $item) :
$_product = &new jigoshop_product($item['id']);
if ($_product->exists() && $item['qty']) :
$item_loop++;
$skrill_args['item_name_'.$item_loop] = $_product->get_title();
$skrill_args['quantity_'.$item_loop] = $item['qty'];
$skrill_args['amount_'.$item_loop] = $_product->get_price_excluding_tax();
endif;
endforeach; endif;
// Shipping Cost
$item_loop++;
$skrill_args['item_name_'.$item_loop] = __('Shipping cost', 'jigoshop');
$skrill_args['quantity_'.$item_loop] = '1';
$skrill_args['amount_'.$item_loop] = number_format($order->order_shipping, 2);
$skrill_args_array = array();
foreach ($skrill_args as $key => $value) {
$skrill_args_array[] = '<input type="hidden" name="'.$key.'" value="'.$value.'" />';
}
// Skirll MD5 concatenation
$skrill_md = get_option('jigoshop_skrill_customer_id') . $skrill_args['transaction_id'] . strtoupper(md5(get_option('jigoshop_skrill_secret_word'))) . $order_total . get_option('jigoshop_currency') . '2';
$skrill_md = md5($skrill_md);
add_post_meta($order_id, '_skrillmd', $skrill_md);
echo '<form name="moneybookers" id="moneybookers_place_form" action="'.$skrill_adr.'" method="POST">' . implode('', $skrill_args_array) . '</form>';
echo '<script type="text/javascript">
//<![CDATA[
var paymentform = document.getElementById(\'moneybookers_place_form\');
window.onload = paymentform.submit();
//]]>
</script>';
exit();
}
/**
* Process the payment and return the result
**/
function process_payment( $order_id ) {
$order = &new jigoshop_order( $order_id );
return array(
'result' => 'success',
'redirect' => add_query_arg('order', $order->id, add_query_arg('key', $order->order_key, get_permalink(get_option('jigoshop_pay_page_id'))))
);
}
/**
* receipt_page
**/
function receipt_skrill( $order ) {
echo '<p>'.__('Thank you for your order, please complete the secure (SSL) form below to pay with Skrill.', 'jigoshop').'</p>';
echo '<iframe class="skrill-loader" width="100%" height="700" id="2" src ="'.home_url('?skrillPayment=1&orderId='.$order).'">';
echo '<p>Your browser does not support iFrames, please contact us to place an order.</p>';
echo '</iframe>';
}
/**
* Check Skrill status report validity
**/
function check_status_report_is_valid() {
// Get Skrill post data array
$params = $_POST;
if(!isset($params['transaction_id'])) return false;
$order_id = $params['transaction_id'];
$_skrillmd = strtoupper(get_post_meta($order_id, '_skrillmd', true));
// Check MD5 signiture
if($params['md5sig'] == $_skrillmd) return true;
return false;
}
/**
* Check for Skrill Status Response
**/
function check_status_response() {
if (isset($_GET['skrillListener']) && $_GET['skrillListener'] == 'skrill_status'):
$_POST = stripslashes_deep($_POST);
if (self::check_status_report_is_valid()) :
do_action("valid-skrill-status-report", $_POST);
endif;
endif;
}
/**
* Successful Payment!
**/
function successful_request( $posted ) {
// Custom holds post ID
if ( !empty($posted['mb_transaction_id']) ) {
$order = new jigoshop_order( (int) $posted['transaction_id'] );
if ($order->status !== 'completed') :
// We are here so lets check status and do actions
switch ($posted['status']) :
case '2' : // Processed
$order->add_order_note( __('Skrill payment completed', 'jigoshop') );
$order->payment_complete();
break;
case '0' : // Pending
case '-2' : // Failed
$order->update_status('on-hold', sprintf(__('Skrill payment failed (%s)', 'jigoshop'), strtolower(sanitize($posted['status'])) ) );
break;
case '-1' : // Cancelled
$order->update_status('cancelled', __('Skrill payment cancelled', 'jigoshop'));
break;
default:
$order->update_status('cancelled', __('Skrill exception', 'jigoshop'));
break;
endswitch;
endif;
exit;
}
}
}
/** Add the gateway to JigoShop **/
function add_skrill_gateway( $methods ) {
$methods[] = 'skrill'; return $methods;
}
add_filter('jigoshop_payment_gateways', 'add_skrill_gateway' );

Some files were not shown because too many files have changed in this diff Show More