margin-left: 0 !important;;
}
}
+.ribbon {
+ position:absolute;
+ z-index: 2;
+ padding:0;
+ margin:0;
+ text-align:center;
+ white-space:nowrap;
+ overflow:hidden;
+ transform-origin:0 100%;
+ box-shadow:0 1px 6px 0 rgba(0,0,0,.12),0 1px 6px 0 rgba(0,0,0,.12);
+ background-color:#ffeb3b;
+ color:rgba(0,0,0,0.9);
+ height:30px;
+ width:200px;
+ top:-30px;
+ transform:rotateZ(45deg);
+ padding-left:30px;
+ padding-right:30px;
+ line-height:30px;
+ right:-58.57864376269px;
+ -webkit-transform:rotateZ(45deg);
+ -moz-transform:rotateZ(45deg);
+ -o-transform:rotateZ(45deg);
+}
+.ribbon:hover {
+ cursor: pointer;
+ color:rgba(0,0,0,0.9);
+}
*
* *** Also note that parameters will be in the context of the main front controller constructor. ***
*/
+function glmMemberHasActiveCoupon( $memberId ) {
+ global $wpdb, $config;
+ $id = filter_var( $memberId, FILTER_VALIDATE_INT );
+ if ( !$id ) {
+ return false;
+ }
+ $sql = "
+ SELECT count(id)
+ FROM " . GLM_MEMBERS_COUPONS_PLUGIN_DB_PREFIX . "coupons
+ WHERE current_date BETWEEN start_date AND end_date AND status = 10
+ AND ref_dest = %d";
+ return $wpdb->get_var( $wpdb->prepare( $sql, $memberId ) );
+}
// Add content to member detail page - Get it from the existing coupon shortcode
add_filter('glm-member-db-front-members-detail-descriptionAfter',
- function($content, $id) {
+ function( $content, $id ) {
global $config;
if ( $config['settings']['detail_show_coupons'] ) {
- $eventData = do_shortcode('[glm-members-coupons-list member='.$id.' template="member-detail"]');
- $content .= $eventData;
+ $coupon_count = glmMemberHasActiveCoupon( $id );
+ if ( $coupon_count ) {
+ $eventData = do_shortcode('[glm-members-coupons-list member='.$id.' template="member-detail"]');
+ $content .= $eventData;
+ }
+ }
+ return $content;
+ },
+ 10,
+ 2
+);
+add_filter('glm-member-db-front-members-list-memberTop',
+ function ( $content, $id ) {
+ global $wpdb, $config;
+ $memberId = filter_var( $id, FILTER_VALIDATE_INT);
+ if ( $memberId && $config['settings']['detail_show_coupons'] ) {
+ $coupon_count = glmMemberHasActiveCoupon( $id );
+ if ( $coupon_count ) {
+ // Get the member slug so we can build the member detail url
+ $sql = "
+ SELECT member_slug
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX. "members
+ WHERE id = %d";
+ $memberSlug = $wpdb->get_var( $wpdb->prepare( $sql, $memberId ) );
+ $url = get_bloginfo('url') . '/member-detail/' . $memberSlug . '/?expanded=coupons';
+ $content = '<a class="ribbon" href="' . $url . '">Savings Coupon</a>';
+ }
}
return $content;
},