Skip to content

Instantly share code, notes, and snippets.

@aaroncampbell
Last active December 15, 2015 03:59
Show Gist options
  • Save aaroncampbell/5198098 to your computer and use it in GitHub Desktop.
Save aaroncampbell/5198098 to your computer and use it in GitHub Desktop.
Sorting Shopp cart by blog_id (product meta data)
<?php
foreach ( ShoppOrder()->Cart->contents as &$item ) {
$item->blog_id = get_post_meta( $item->product, 'blog_id', true );
}
function finecabin_sort_cart( $a, $b ) {
if ( $a->blog_id == $b->blog_id )
return 0;
return ( $a->blog_id < $b->blog_id )? -1 : 1;
}
usort( ShoppOrder()->Cart->contents, 'finecabin_sort_cart' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment