Blog

May 25, 2016

Here a code to send invitations to join to a group. The plugin assumes that your ‘friend’ is logged when click the email link. Add this shortcode to a page [groups_invitations] and you’ll have a form to send the invitations. It is simply a reference example to create customized versions. DOWNLOAD THE PLUGIN

Posted in Blog by eggemplo
May 12, 2016

If you need automatically to apply the coupons of the affiliate who referrer you, you can use this code: add_action( 'woocommerce_before_cart', 'eggemplo_woocommerce_before_cart' ); function eggemplo_woocommerce_before_cart() { global $woocommerce; if ( !class_exists("Affiliates_Service" ) ) { require_once( AFFILIATES_CORE_LIB . '/class-affiliates-service.php' ); } $affiliate_id = Affiliates_Service::get_referrer_id(); if ( $affiliate_id ) { $affiliate = affiliates_get_affiliate( $affiliate_id ); $coupons = Affiliates_Attributes_WordPress::get_coupons_for_affiliate( $affiliate_id ); if ( isset( $coupons ) && ( sizeof( $coupons ) > 0 ) ) { foreach ( $coupons as $coupon ) { $woocommerce->cart->add_discount( $coupon ); } } } }

Posted in Blog by eggemplo
2 November 18, 2015

If you are using Woocommerce Groups Pricing, and you need to display the original and the discounted prices, you can add this code in your theme functions.php file. If you are using Woocommerce 2.5.x

 add_filter( 'woocommerce_get_price_html', 'your_own_price_html', 100, 2 ); function your_own_price_html( $price, $product ){ $result = $price; if ( get_option( "wgp-baseprice", "regular" ) == "sale" ) { $price_key = '_price'; } else { $price_key = '_regular_price'; } if ( $product->product_type == 'variable' ) { $children = $product->get_children(true); $original_prices = array(); $commission = 0; foreach ( $children as $child ) { $original_prices[] = get_post_meta( $child, $price_key, true ); if ( $commission == 0 ) { $commission = WGP_Variations_Admin::get_commission( $product, $child ); } } if ( $commission > 0 ) { $min_price = min( $original_prices ); $max_price = max( $original_prices ); $original_price = $min_price !== $max_price ? sprintf( _x( '%1$s–%2$s', 'Pr

Posted in Blog by eggemplo
November 17, 2015

Contact Form 7 + Affiliates = Power Tool 🙂 Affiliates plugin integrate the option to includo form field data in the referral email, but sometimes we need to add the affiliate’s info in the Contact Form 7 email notification. Here a code that you can use to add affiliate’s information in your emails:

 function addAffiliatesTokens($array) { if (! class_exists ( "Affiliates_Service" )) { include_once (AFFILIATES_CORE_LIB . '/class-affiliates-service.php'); } $affiliate_id = Affiliates_Service::get_referrer_id (); if ($affiliate_id) { if ($affiliate_id !== affiliates_get_direct_id ()) { if ($user_id = affiliates_get_affiliate_user ( $affiliate_id )) { if ($user = get_user_by ( 'id', $user_id )) { $array['body'] = str_replace('[affiliate-id]', $affiliate_id, $array['body']); $array['body'] = str_replace('[affiliate-username]', $user->user_login, $array['body']); } } } } return $array; } add_filter('wpcf7_mail_components', 'addAffiliatesTokens'); 

It adds the tokens [affiliate-id] and [affiliate-username]

Posted in Blog by eggemplo
November 2, 2015

If you are using Tickets for Woocommerce with The Event Calendar to “sell events”, and you want to apply discounts according to the user role (Woocommerce Role Pricing), now this is possible. You need to add this code to your functions.php theme file:

 add_filter( 'tribe_get_event_meta', 'my_tribe_get_event_meta', 10, 4 ); function my_tribe_get_event_meta ( $output, $postID, $meta, $single ) { if ( $meta == "_EventCost" ) { if ( is_array( $output ) ) { $type = get_option( "wrp-method", "rate" ); $result = $output[0]; $user = wp_get_current_user(); $user_roles = $user->roles; $user_role = array_shift($user_roles); $discount = 0; if ( $user_role !== null ) { if ( get_option( "wrp-" . $user_role, "-1" ) !== "-1" ) { $discount = get_option( "wrp-" . $user_role ); } } if ( $discount ) { $method = get_option( "wrp-method", "rate" ); if ( $method == "rate" ) { $discount 

Posted in Blog by eggemplo
2 September 15, 2015

Make your Woocommerce products purchasable according to the user’s role. Now you have available the ‘guest’ pseudo-role, so your product could be purchasable only for registered users.

You need:

Screenshots

Captura de pantalla 2015-09-10 a las 21.19.01 Captura de pantalla 2015-09-10 a las 21.19.22

Posted in Blog, Plugins, Wordpress by eggemplo | Tags: , , , ,
3 September 6, 2015

INSTALLATION

Backup Backup your WordPress installation files and database. Install and activate the Woocommerce Group Pricing plugin Add the new plugin you have received and activate it: Go to Plugins > Add New > Upload and click the Browse… button to select the plugin’s zip file, usually woogrouppricing-x.y.z.zip (x, y and z are the plugin’s current version numbers). After that proceed to activate the plugin. If you have errors, review the plugin’s page located here: http://www.eggemplo.com/plugins/groups2mailchimp for similar problems and the proposed solutions posted in the comments.

SETUP

Requirements This plugin requires:

  • Woocommerce > 2.2.x
  • Group > 1.4.x
  • Setup Woocommerce Group Pricing If you have not done so already, install and activate the plugin. See Installation section. Check the settings on the Woocommerce > Group Pricing submenu and adjust them.

Posted in Blog, Documentation, Wordpress by eggemplo | Tags: , , ,
August 27, 2015

If you are using Groups by @itthinx and you need to filter the feeds, this code can help you:

function my_feed_filter ( $query ) { $include = array(); if ( $query->is_feed ) { $posts = Groups_Post_Access::the_posts(get_posts(array('posts_per_page'=>-1)), $query ); foreach ($posts as $post) { $include[] = $post->ID; } $query->set('post__in', $include); } } add_filter( 'pre_get_posts', 'my_feed_filter' );

Good luck !

Posted in Blog by eggemplo
August 10, 2015

If you are using Groups plugin by @itthinx and you need to set restrictions to posts (or another post type), you can use this code as reference: function restricted_save_post($post_id, $post) { if(!is_object($post) || !isset($post->post_type)) { return; } switch($post->post_type) { // Do different things based on the post type case "post": // add your default capabilities Groups_Post_Access::create( array( 'post_id'=>$post_id, 'capability'=>'Premium' ) ); break; default: // Do other stuff } } add_action('save_post', 'restricted_save_post', 1, 2); This code adds the ‘Premium’ capability to all new posts when they are created. Good luck!

Posted in Blog by eggemplo | Tags: , , ,