Skip to content

Instantly share code, notes, and snippets.

@mwhiteley16
Last active August 29, 2015 14:03
Show Gist options
  • Save mwhiteley16/9080550bae9a4d61e858 to your computer and use it in GitHub Desktop.
Save mwhiteley16/9080550bae9a4d61e858 to your computer and use it in GitHub Desktop.
Switch to Coupon on SEC Smart Offers Admin Page (Change made to plugin - must retain for updates) - Lines 15-19 updated
public static function column_display( $column_name, $id ) {
global $post;
$item = SEC_Offer::get_instance( $id );
if ( !$item )
return; // return for that temp post
switch ( $column_name ) {
case 'info':
$type = $item->get_type();
$args = array(
'post_type' => SEC_Offer::POST_TYPE,
SEC_Offer::TYPE_TAXONOMY => $type->slug
);
if( has_term( 'coupon-5', 'coupon_tax' ) ) {
echo 'Type: <a class="offer_type_column_link type_deal">Coupon</a>';
} else {
printf( '%1$s: <a href="%2$s" class="offer_type_column_link type_%3$s">%4$s</a>', self::__('Type'), esc_url( add_query_arg( $args, 'edit.php' ) ), $type->slug, $type->name );
}
$merchant = SEC_Merchant::get_merchant_object( $id );
if ( !is_a( $merchant, 'Group_Buying_Merchant' ) ) return;
printf( '<hr/><a href="%1$s">%2$s</a><br/>', get_edit_post_link( $merchant->get_ID() ), get_the_title( $merchant->get_ID() ) );
printf( self::__( '<a href="%1$s" style="color:silver">%1$s</a><br/>' ), $merchant->get_website() );
printf( self::__( '<span style="color:silver">%1$s</span>' ), $merchant->get_contact_phone() );
printf( '<div class="row-actions"><span class="merchant"><a href="%1$s">View</a></span></div>', get_permalink( $merchant->get_ID() ) );
break;
case 'status':
$expiration = ( SEC_Offer::NO_EXPIRATION_DATE == $item->get_expiration_date() ) ? self::__( 'none' ) : date( get_option( 'date_format' ).' @ '.get_option( 'time_format' ), $item->get_expiration_date() );
switch ( $item->get_status() ) {
case 'open':
printf( '<span style="color:green">%1$s</span> <span style="color:silver">(id: %2$s)</span> <br/><span style="color:silver">expires: %3$s</span> ', self::__( 'Active' ), $id, $expiration );
break;
case 'closed':
printf( '<span style="color:#BC0B0B">%1$s</span> <span style="color:silver">(id: %2$s)</span> <br/><span style="color:silver">%3$s</span>', self::__( 'Expired' ), $id, $expiration );
break;
case 'closed':
printf( '<span style="color:orange">%1$s</span> <span style="color:silver">(id: %2$s)</span> <br/><span style="color:silver">expiration: %3$s</span>', self::__( 'Pending' ), $id, $expiration );
break;
case 'closed':
default:
echo '<span style="color:black">'.gb__( 'Unknown' ).'</span>';
break;
}
break;
case 'sold':
printf( self::__( 'Sold: %s' ), $item->get_number_of_purchases() );
printf( self::__( '<br/><span style="color:silver">Current Price: %s</span>' ), gb_get_formatted_money( $item->get_price() ) );
if ( $item->get_remaining_allowed_purchases() > 0 ) {
printf( self::__( '<br/><span style="color:silver">Remaining allowed: %s</span>' ), $item->get_remaining_allowed_purchases() );
}
$remaining = (int) $item->get_remaining_required_purchases();
if ( $remaining ) {
printf( self::__( '<br/><span style="color:silver">Remaining required: %s</span>' ), $remaining );
}
printf( '<div class="row-actions"><span class="payment"><a href="admin.php?page=group-buying/voucher_records&amp;deal_id=%1$s">Vouchers</a> | <span class="payments"><a href="admin.php?page=group-buying/payment_records&amp;deal_id=%1$s">Payments</a> | </span><span class="purchases"><a href="admin.php?page=group-buying/purchase_records&amp;deal_id=%1$s">Orders</a> | </span><span class="gifts"><a href="admin.php?page=group-buying/gift_records&amp;deal_id=%1$s">Gifts</a></span></div>', $id );
break;
default:
break;
}
}
@mwhiteley16
Copy link
Author

plugins/smart-ecart/controllers/offers/Offers.class.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment