update cart page

This commit is contained in:
magepeopleteam 2018-12-02 05:45:21 +00:00
parent 2fbb67d72c
commit b12de90ea6
1 changed files with 7 additions and 16 deletions

View File

@ -1,8 +1,7 @@
<?php <?php
function mep_add_custom_fields_text_to_cart_item( $cart_item_data, $product_id, $variation_id ) { 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); $tp = get_post_meta($product_id,'_price',true);
$new = array(); $new = array();
$user = array(); $user = array();
@ -182,10 +181,9 @@ if(isset($_POST['mep_event_ticket_type'])){
$cart_item_data['event_tp'] = $tp; $cart_item_data['event_tp'] = $tp;
$cart_item_data['line_total'] = $tp; $cart_item_data['line_total'] = $tp;
$cart_item_data['line_subtotal'] = $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; return $cart_item_data;
} }
@ -195,8 +193,7 @@ add_filter( 'woocommerce_add_cart_item_data', 'mep_add_custom_fields_text_to_car
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' ); add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
function add_custom_price( $cart_object ) { function add_custom_price( $cart_object ) {
$eid = $value['event_id'];
if($eid != 'not-event'){
foreach ( $cart_object->cart_contents as $key => $value ) { foreach ( $cart_object->cart_contents as $key => $value ) {
$cp = $value['event_tp']; $cp = $value['event_tp'];
$value['data']->set_price($cp); $value['data']->set_price($cp);
@ -204,7 +201,6 @@ if($eid != 'not-event'){
} }
} }
}
@ -212,8 +208,6 @@ if($eid != 'not-event'){
function mep_display_custom_fields_text_cart( $item_data, $cart_item ) { function mep_display_custom_fields_text_cart( $item_data, $cart_item ) {
$mep_events_extra_prices = $cart_item['event_extra_option']; $mep_events_extra_prices = $cart_item['event_extra_option'];
$eid = $cart_item['event_id'];
if($eid != 'not-event'){
if($mep_events_extra_prices){ if($mep_events_extra_prices){
echo "<ul class='event-custom-price'>"; echo "<ul class='event-custom-price'>";
@ -231,7 +225,6 @@ 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 "<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>"; echo "</ul>";
}
return $item_data; return $item_data;
} }
@ -241,8 +234,6 @@ 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 ) { 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']; $mep_events_extra_prices = $values['event_extra_option'];
$event_user_info = $values['event_user_info']; $event_user_info = $values['event_user_info'];
$event_ticket_type = $values['event_ticket_type']; $event_ticket_type = $values['event_ticket_type'];
@ -283,7 +274,7 @@ update_post_meta( $product_id, "mep_xtra_$tck_name",$ntesqt);
$item->add_meta_data('_event_user_info',$event_user_info); $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 ); add_action( 'woocommerce_checkout_create_order_line_item', 'mep_add_custom_fields_text_to_order_items', 10, 4 );