1) How can I change link of “proceed to registration” button of the popup on MER? we want to change the link so we can send the user to our custom page from there he can login or process to checkout as a guest
Is there is any hook/filter to modify “Proceed to Registration” Link?
I checked and there actually is not a filter hook to modify the URLs within the cart modal that pops up. What they could do instead is use the FHEE__EEH_Template__display_template__template_path filter hook to load in a custom template for the cart modal (instead of the default template). The custom template could have your custom URL instead of pointing to the registration page URL.
Your developer needs to install the Debug Bar plugin and its companion Debug Bar Actions & Filters add-on. Then they’ll have a list of all the hooks and filters available from Event Espresso in each request.
Along with the above, if they open up the Event Espresso 4 plugin into their IDE, they can do a search for AHEE_ (action hooks) and FHEE_ (filter hooks).
If none of the above are something they can use and they see a place within the core plugin where they could use a hook, the developer is encouraged to do a pull request.
If none of the above are something they can use and they see a place within the core plugin where they could use a hook, the developer is encouraged to do a pull request.
Can you also asked him that How we apply discount using our points system in existing ee4 registration process?
Is there any hook or filter which we can use to allow discount based on our points system.
I’m sorry but these questions are too vague to give a specific answer. I can point you in the general direction of the Promotions add-on. If they can review the code within the Promotions add-on they’ll see how that add-on applies discounts within the registration process.
Hi Guys, I have more detail. Can we make this thread private because he wants me to share the custom code he has created for my new plugin. Once marked private I can share the code and question with more detail for you.
I am trying to get cart object in ajax request and add discount for rewards points as they did for promotions module.
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class EE4_Points_Public {
//initialize Public class
public function __construct(){
//Add points rule box on checkout page.
add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', array( $this, 'add_points_rewards_form_checkbox' ));
add_action('wp_ajax_submit_points_discount',array($this,'submit_points_discount'));
add_action('wp_ajax_nopriv_submit_points_discount',array($this,'submit_points_discount'));
}
public function submit_points_discount(){
$return_data = array();
// get the EE_Cart object being used for the current transaction
/** @type EE_Cart $cart */
$cart=EE_Registry::instance()->SSN->CART;
//$cart = EE_Registry::instance()->SSN;
//$cart=EE_Registry::instance()->CART;
if ( $cart instanceof EE_Cart ) {
// and make sure the model cache is
$cart->get_grand_total()->get_model()->refresh_entity_map_with(
$cart->get_grand_total()->ID(),
$cart->get_grand_total()
);
// add line item
if ( $this->generate_redeem_points_line_item()) {
// ensure cart totals have been recalculated and saved
$cart->get_grand_total()->recalculate_total_including_taxes();
$cart->get_grand_total()->save_this_and_descendants();
/** @type EE_Registration_Processor $registration_processor */
$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
$registration_processor->update_registration_final_prices(
$cart->get_grand_total()->transaction()
);
$cart->save_cart( false );
$return_data = EED_Promotions::_get_payment_info( $cart );
$return_data['success'] = EED_Promotions::accept_message();
EED_Single_Page_Checkout::update_checkout();
} else {
EE_Error::add_attention( EED_Promotions::decline_message(), __FILE__, __FUNCTION__, __LINE__ );
}
}
else{
EE_Error::add_error(
sprintf(
apply_filters(
'FHEE__EED_Points_Rewards___submit_points__invalid_cart_notice',
__(
'We\'re sorry, Currently we are unable to process redeem points. please contact us for more detail',
'event_espresso'
)
)
),
__FILE__,
__FUNCTION__,
__LINE__
);
}
$this->generate_JSON_response( $return_data );
}
/**
* generate_JSON_response
* allows you to simply echo or print an EE_SPCO_JSON_Response object to produce a JSON encoded string
* ie: $json_response = new EE_SPCO_JSON_Response();
* echo $json_response;
*
* @access public
* @param array $return_data
* @return void
*/
public function generate_JSON_response( $return_data = array() ) {
$JSON_response = array();
// grab notices
$notices = EE_Error::get_notices( false );
// add notices to JSON response, but only if they exist
if ( isset( $notices['attention'] ) ) {
$JSON_response['attention'] = $notices['attention'];
}
if ( isset( $notices['errors'] ) ) {
$JSON_response['errors'] = $notices['errors'];
}
if ( isset( $notices['success'] ) ) {
$JSON_response['success'] = $notices['success'];
}
if ( empty( $JSON_response ) && empty( $return_data ) ) {
$JSON_response['errors'] = sprintf(
__(
'We unable to processed your redeem point request for an unknown reason.',
'event_espresso'
)
);
}
// add return_data array to main JSON response array, IF it contains anything
$JSON_response['return_data'] = $return_data;
// filter final array
$JSON_response = apply_filters( 'FHEE__EED_Points_Rewards__generate_JSON_response__JSON_response', $JSON_response );
// return encoded array
echo json_encode( $JSON_response );
exit();
}
/**
* get_redeemable_points_discount
* searches the cart for any items that this promotion applies to
*
* @since 1.0.0
* @param EE_Line_Item $parent_line_item the line item to create the new promotion line item under
* @param EE_Promotion $promotion the promotion object that the line item is being created for
* @param string $promo_name
* @param bool $affects_tax
* @return \EE_Line_Item
* @throws \EE_Error
*/
public function generate_redeem_points_line_item($promo_name='',$affects_tax = false) {
$get_discount=EE4_Points_Helper::get_points_discount();
$promo_name = ! empty( $promo_name ) ? $promo_name : 'Points Reddeem';
$promo_desc = 'Get $'.$get_discount['discount']." for ".$get_discount['redeem_point'];
// generate promotion line_item
$time=time();
$line_item = EE_Line_Item::new_instance(
array(
'LIN_code' => 'redeem-' . $get_discount['redeem_point'],
'LIN_name' => $promo_name,
'LIN_desc' => $promo_desc,
'LIN_unit_price' => $get_discount['discount'],
'LIN_percent' => 0,
'LIN_is_taxable' => $affects_tax,
'LIN_order' => 99,
// we want promotions to be applied AFTER other line items
'LIN_total' => $get_discount['discount'],
'LIN_quantity' => 1,
// Parent ID (this item goes towards that Line Item's total)
'LIN_type' => 'promotion',
'OBJ_ID' => $time,
// ID of Item purchased
'OBJ_type' => 'Promotion'
// Model Name this Line Item is for
)
);
return $line_item;
}
public function add_points_rewards_form_checkbox($before_payment_options){
if(is_user_logged_in()){
$balance_points=EE4_Points_Helper::balance_points();
if($balance_points > 0){
$get_discount=EE4_Points_Helper::get_points_discount($balance_points);
EE_Registry::instance()->load_helper( 'HTML' );
$points_rewards_html='<div class="redeem_container"><h3>Redeem Points</h3>';
if($get_discount){
$points_rewards_html.='<p class="redeem_me"><input type="checkbox" name="use_points_rewards" id="use_points_rewards" value="1"> Redeem Points. You have <b>'.$balance_points.'</b> points and you will get <b>$'.$get_discount['discount'].'</b> discount.</p>';
}
else
{
$points_rewards_html.='<p class="redeem_me">You have <b>'.$balance_points.'</b> Points. Insufficient Points to Redeem.</p>';
}
$points_rewards_html.="<ul class='redeem_rules'>
<li>Redeem <b>10,000</b> points for <b>$5</b> off events.</li>
<li>Redeem <b>20,000</b> points for <b>$10</b> off events.</li>
<li>Redeem <b>30,000</b> points for <b>$20</b> off events.</li>
<li>Redeem <b>40,000</b> points for <b>$35</b> off events.</li>
</ul><ul class='redeem_rules'>
<li>Redeem <b>50,000</b> points for <b>$45</b> off events.</li>
<li>Redeem <b>60,000</b> points for <b>$60</b> off events.</li>
<li>Redeem <b>70,000</b> points for <b>$85</b> off events.</li>
<li>Redeem <b>80,000</b> points for <b>$120</b> off events.</ul>";
$points_rewards_html.='</div>';
$before_payment_options->add_subsections(
array(
'rewards_points_form' => new EE_Form_Section_Proper(
array(
'layout_strategy' => new EE_No_Layout(),
'subsections' => array(
'rewards_points_content' => new EE_Form_Section_HTML($points_rewards_html),
'rewards_points_header' => new EE_Form_Section_HTML(
EEH_HTML::div( ' ', '', 'clear-float' )
),
),
)
),
)
);
}
}
return $before_payment_options;
}
}
new EE4_Points_Public();
It’s been altered some and looks like the cart is being pulled in incorrectly, but the original code should have worked fine as is so I’m not sure why that was changed and the commented code attempts used?
Adding the code itself doesn’t really give us any more context as we can’t run it (its not the full code) so we still don’t really have enough details, not without reviewing all the code which is generally not something we will do on the forums.
With a quick glance I can see there’s multiple lines when trying to pull the cart:
But looking at the promotions add-on where that method was copied from the code that is actually used in that section is:
$cart = EE_Registry::instance()->SSN->cart();
So that should pull the EE_Cart object for you, not the code that has been added above.
We don’t know your what developer is getting returned currently, what is cart being set to show a problem? null?
What have they tried? What other code is running? When the above code is actually running etc. We really need more details of the problem and in-depth details of what the problem is, the specific code they have tried and what is getting returned from the code they have tried.
In short, we need much more detail to help here but so far it looks like the promotions add-on was copied and then incorrectly modified?
Hi Jarred.
I create dynamic promotion code for point reward discount. and try to apply that discount using promotion submit code function.
But it gives a fatal error.
So can you ask Josh or tony that how we apply dynamically created promo code in the site or how to apply promo code automatically?
If we resolved this then we almost finish points and reward system.
I’m sorry but these questions are too vague to give a specific answer. Does your developer know how to debug his own code? If so, they can start with the stack trace of the fatal error and work from there.
Hi Josh,
Sorry for confusion. Actually, We try to access cart object in our custom ajax function but we get empty value for cart even though cart have events. for avoid this problem.
Here is our code.
add_action('wp_ajax_submit_points_discount',array($this,'submit_points_discount'));
add_action('wp_ajax_nopriv_submit_points_discount',array($this,'submit_points_discount'));
public function submit_points_discount(){
if ( EE_Registry::instance()->CART instanceof EE_Cart ) {
$grand_total = EE_Registry::instance()->CART->get_grand_total();
}
---
---
}
or we also try another way to submit our promo code for points rewards by calling promotion submit code method using their class instance like this way in our ajax function. but its didn’t work and its give empty cart value there as well.
EED_Promotions::instance()->submit_promo_code();
Please can you help us. how we can get cart object in our ajax function.
Hi Josh,
One more questions, I added promotion code in cart. but how can i remove promotion code from cart. Look at following screenshot, i not see any option to remove promocode from cart.
There actually are no options to remove applied promotions from the cart. If you remove the event the applied promotions will automatically be removed with the event.
A developer could maybe do that (it will depend on their skill level). It’s not something we support.
Viewing 26 reply threads
The support post ‘Hook Filter Calling to New Page’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.