fixed cart calculation

This commit is contained in:
magepeopleteam 2018-12-02 05:39:48 +00:00
parent 41db5d7601
commit 2fbb67d72c
3 changed files with 21 additions and 9 deletions

View File

@ -1,7 +1,7 @@
<?php
function mep_add_custom_fields_text_to_cart_item( $cart_item_data, $product_id, $variation_id ) {
if (get_post_type($product_id) == 'mep_events') {
$tp = get_post_meta($product_id,'_price',true);
$new = array();
$user = array();
@ -182,9 +182,10 @@ if(isset($_POST['mep_event_ticket_type'])){
$cart_item_data['event_tp'] = $tp;
$cart_item_data['line_total'] = $tp;
$cart_item_data['line_subtotal'] = $tp;
$cart_item_data['event_id'] = $product_id;
}else{
$cart_item_data['event_id'] = 'not-event';
}
return $cart_item_data;
}
@ -194,7 +195,8 @@ add_filter( 'woocommerce_add_cart_item_data', 'mep_add_custom_fields_text_to_car
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
function add_custom_price( $cart_object ) {
$eid = $value['event_id'];
if($eid != 'not-event'){
foreach ( $cart_object->cart_contents as $key => $value ) {
$cp = $value['event_tp'];
$value['data']->set_price($cp);
@ -202,6 +204,7 @@ function add_custom_price( $cart_object ) {
}
}
}
@ -209,6 +212,8 @@ function add_custom_price( $cart_object ) {
function mep_display_custom_fields_text_cart( $item_data, $cart_item ) {
$mep_events_extra_prices = $cart_item['event_extra_option'];
$eid = $cart_item['event_id'];
if($eid != 'not-event'){
if($mep_events_extra_prices){
echo "<ul class='event-custom-price'>";
@ -226,6 +231,7 @@ if(array_key_exists('event_ticket_type', $cart_item)){
echo "<li> Ticket: ".$cart_item['event_ticket_type']." x ".$cart_item['event_ticket_qty'].": ".get_woocommerce_currency_symbol().$cart_item['event_ticket_price']."</li>";
}
echo "</ul>";
}
return $item_data;
}
@ -235,6 +241,8 @@ add_filter( 'woocommerce_get_item_data', 'mep_display_custom_fields_text_cart',
function mep_add_custom_fields_text_to_order_items( $item, $cart_item_key, $values, $order ) {
$eid = $values['event_id'];
if($eid != 'not-event'){
$mep_events_extra_prices = $values['event_extra_option'];
$event_user_info = $values['event_user_info'];
$event_ticket_type = $values['event_ticket_type'];
@ -275,7 +283,7 @@ update_post_meta( $product_id, "mep_xtra_$tck_name",$ntesqt);
$item->add_meta_data('_event_user_info',$event_user_info);
}
}
add_action( 'woocommerce_checkout_create_order_line_item', 'mep_add_custom_fields_text_to_order_items', 10, 4 );

View File

@ -246,4 +246,8 @@ You can display the event list on any page by using the ShortCode. Just use this
*Update Release, Custom email sending issue has been fixed. 28 Nov 2018*
*= 2.2.0 =
*Update Release, Fixed no numeric error, and add feature to hide available seat count. 29 Nov 2018*
*Update Release, Fixed no numeric error, and add feature to hide available seat count. 29 Nov 2018*
*= 2.2.1 =
*Update Release, fixed cart wrong calculation issue. 02 Dec 2018*

View File

@ -3,7 +3,7 @@
* Plugin Name: Woocommerce Events Manager
* Plugin URI: http://mage-people.com
* Description: A Complete Event Solution for WordPress by MagePeople..
* Version: 2.2.0
* Version: 2.2.1
* Author: MagePeople Team
* Author URI: http://www.mage-people.com/
* Text Domain: mage-eventpress