/** * process_subscription_payment function. * * @param WC_order $order * @param integer $amount (default: 0) * @uses Simplify_BadRequestException * @return bool|WP_Error */ public function process_subscription_payment($order, $amount = 0) { if (0 == $amount) { // Payment complete $order->payment_complete(); return true; } if ($amount * 100 < 50) { return new WP_Error('simplify_error', __('Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce')); } $order_items = $order->get_items(); $order_item = array_shift($order_items); $subscription_name = sprintf(__('%s - Subscription for "%s"', 'woocommerce'), esc_html(get_bloginfo('name', 'display')), $order_item['name']) . ' ' . sprintf(__('(Order #%s)', 'woocommerce'), $order->get_order_number()); $customer_id = get_post_meta($order->id, '_simplify_customer_id', true); if (!$customer_id) { return new WP_Error('simplify_error', __('Customer not found', 'woocommerce')); } try { // Charge the customer $payment = Simplify_Payment::createPayment(array('amount' => $amount * 100, 'customer' => $customer_id, 'description' => trim(substr($subscription_name, 0, 1024)), 'currency' => strtoupper(get_woocommerce_currency()), 'reference' => $order->id, 'card.addressCity' => $order->billing_city, 'card.addressCountry' => $order->billing_country, 'card.addressLine1' => $order->billing_address_1, 'card.addressLine2' => $order->billing_address_2, 'card.addressState' => $order->billing_state, 'card.addressZip' => $order->billing_postcode)); } catch (Exception $e) { $error_message = $e->getMessage(); if ($e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors()) { $error_message = ''; foreach ($e->getFieldErrors() as $error) { $error_message .= ' ' . $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')'; } } $order->add_order_note(sprintf(__('Simplify payment error: %s', 'woocommerce'), $error_message)); return new WP_Error('simplify_payment_declined', $e->getMessage(), array('status' => $e->getCode())); } if ('APPROVED' == $payment->paymentStatus) { // Payment complete $order->payment_complete($payment->id); // Add order note $order->add_order_note(sprintf(__('Simplify payment approved (ID: %s, Auth Code: %s)', 'woocommerce'), $payment->id, $payment->authCode)); return true; } else { $order->add_order_note(__('Simplify payment declined', 'woocommerce')); return new WP_Error('simplify_payment_declined', __('Payment was declined - please try another card.', 'woocommerce')); } }
/** * This function updates the database for the delivery details and adds delivery fields on the Order Received page, * WooCommerce->Orders when an order is placed for WooCommerce version greater than 2.0. */ function prdd_lite_order_item_meta($item_meta, $cart_item) { if (version_compare(WOOCOMMERCE_VERSION, "2.0.0") < 0) { return; } // Add the fields global $wpdb, $woocommerce; foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) { $_product = $values['data']; if (isset($values['prdd_lite_delivery'])) { $delivery = $values['prdd_lite_delivery']; } $quantity = $values['quantity']; $post_id = $this->prdd_lite_get_product_id($values['product_id']); $post_title = $_product->get_title(); $query = "SELECT order_item_id,order_id FROM `" . $wpdb->prefix . "woocommerce_order_items`\n\t\t\t\t\t\tWHERE order_id = %s AND order_item_name = %s"; $results = $wpdb->get_results($wpdb->prepare($query, $item_meta, $post_title)); $order_item_ids[] = $results[0]->order_item_id; $order_id = $results[0]->order_id; $order_obj = new WC_order($order_id); $details = $product_ids = array(); $order_items = $order_obj->get_items(); if (isset($values['prdd_lite_delivery'])) { $prdd_settings = get_post_meta($post_id, '_woo_prdd_lite_enable_delivery_date', true); $details = array(); if (isset($delivery[0]['delivery_date']) && $delivery[0]['delivery_date'] != "") { $name = "Delivery Date"; $date_select = $delivery[0]['delivery_date']; wc_add_order_item_meta($results[0]->order_item_id, $name, sanitize_text_field($date_select, true)); } if (array_key_exists('delivery_hidden_date', $delivery[0]) && $delivery[0]['delivery_hidden_date'] != "") { $date_booking = date('Y-m-d', strtotime($delivery[0]['delivery_hidden_date'])); wc_add_order_item_meta($results[0]->order_item_id, '_prdd_lite_date', sanitize_text_field($date_booking, true)); } } if (version_compare(WOOCOMMERCE_VERSION, "2.5") < 0) { continue; } else { // Code where the Delivery dates are not displayed in the customer new order email from WooCommerce version 2.5 $cache_key = WC_Cache_Helper::get_cache_prefix('orders') . 'item_meta_array_' . $results[0]->order_item_id; $item_meta_array = wp_cache_get($cache_key, 'orders'); if (false !== $item_meta_array) { $metadata = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value, meta_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id = %d AND meta_key IN (%s,%s) ORDER BY meta_id", absint($results[0]->order_item_id), "Delivery Date", '_prdd_lite_date')); foreach ($metadata as $metadata_row) { $item_meta_array[$metadata_row->meta_id] = (object) array('key' => $metadata_row->meta_key, 'value' => $metadata_row->meta_value); } wp_cache_set($cache_key, $item_meta_array, 'orders'); } } } }
/** * process_subscription_payment function. * * @param WC_order $order * @param integer $amount (default: 0) * @return bool|WP_Error */ public function process_subscription_payment($order = '', $amount = 0) { $order_items = $order->get_items(); $order_item = array_shift($order_items); $subscription_name = sprintf(__('%s - Subscription for "%s"', 'woocommerce'), esc_html(get_bloginfo('name')), $order_item['name']) . ' ' . sprintf(__('(Order %s)', 'woocommerce'), $order->get_order_number()); if ($amount * 100 < 50) { return new WP_Error('simplify_error', __('Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce')); } $customer_id = get_post_meta($order->id, '_simplify_customer_id', true); if (!$customer_id) { return new WP_Error('simplify_error', __('Customer not found', 'woocommerce')); } // Charge the customer $payment = Simplify_Payment::createPayment(array('amount' => $amount * 100, 'customer' => $customer_id, 'description' => trim(substr($subscription_name, 0, 1024)), 'currency' => strtoupper(get_woocommerce_currency()), 'reference' => $order->id, 'card.addressCity' => $order->billing_city, 'card.addressCountry' => $order->billing_country, 'card.addressLine1' => $order->billing_address_1, 'card.addressLine2' => $order->billing_address_2, 'card.addressState' => $order->billing_state, 'card.addressZip' => $order->billing_postcode)); if ('APPROVED' == $payment->paymentStatus) { // Payment complete $order->payment_complete($payment->id); // Add order note $order->add_order_note(sprintf(__('Simplify payment approved (ID: %s, Auth Code: %s)', 'woocommerce'), $payment->id, $payment->authCode)); return true; } else { $order->add_order_note(__('Simplify payment declined', 'woocommerce')); return new WP_Error('simplify_payment_declined', __('Payment was declined - please try another card.', 'woocommerce')); } }
function woocommerce_cancel_order($order_id, $order_item_id) { global $wpdb, $post; $array = array(); $order_obj = new WC_order($order_id); $order_items = $order_obj->get_items(); $select_query = "SELECT booking_id FROM `" . $wpdb->prefix . "booking_order_history`\n\t\t\t\tWHERE order_id='" . $order_id . "'"; $results = $wpdb->get_results($select_query); $post_id = woocommerce_get_order_item_meta($order_item_id, "_product_id", true); $booking_settings = get_post_meta($post_id, 'woocommerce_booking_settings', true); $checkin_date = woocommerce_get_order_item_meta($order_item_id, get_option('book.item-meta-date'), true); //print_r($results); $start_date = date("Y-m-d", strtotime($checkin_date)); if (isset($booking_settings['booking_enable_multiple_day']) && $booking_settings['booking_enable_multiple_day'] == 'on') { $checkout_date = woocommerce_get_order_item_meta($order_item_id, strip_tags(get_option('checkout.item-meta-date')), true); $end_date = date("Y-m-d", strtotime($checkout_date)); //echo "<pre>";print_r($results);echo "</pre>";exit; foreach ($results as $k => $v) { $b[] = $v->booking_id; $select_query_post = "SELECT post_id,id FROM `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\tWHERE id='" . $v->booking_id . "' AND start_date='" . $start_date . "' AND end_date ='" . $end_date . "' AND post_id=" . $post_id; $results_post[] = $wpdb->get_results($select_query_post); } } else { if (isset($booking_settings['booking_enable_time']) && $booking_settings['booking_enable_time'] == 'on') { $timeslot = woocommerce_get_order_item_meta($order_item_id, get_option('book.item-meta-time'), true); $time_slot = explode("-", $timeslot); $from_time = date("G:i", strtotime($time_slot[0])); $to_time = date("G:i", strtotime($time_slot[1])); //echo "<pre>";print_r($results);echo "</pre>";exit; foreach ($results as $k => $v) { $b[] = $v->booking_id; $select_query_post = "SELECT post_id,id FROM `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\tWHERE id='" . $v->booking_id . "' AND start_date='" . $start_date . "' AND from_time ='" . $from_time . "' AND to_time ='" . $to_time . "' AND post_id=" . $post_id; $results_post[] = $wpdb->get_results($select_query_post); } } else { foreach ($results as $k => $v) { $b[] = $v->booking_id; $select_query_post = "SELECT post_id,id FROM `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\tWHERE id='" . $v->booking_id . "' AND start_date='" . $start_date . "' AND post_id=" . $post_id; $results_post[] = $wpdb->get_results($select_query_post); } } } foreach ($results_post as $k => $v) { $a[$v[0]->post_id][] = $v[0]->id; } $i = 0; foreach ($order_items as $item_key => $item_value) { $product_id = get_post_meta($item_value['product_id'], '_icl_lang_duplicate_of', true); if ($product_id == '' && $product_id == null) { $post_time = get_post($item_value['product_id']); $id_query = "SELECT ID FROM `" . $wpdb->prefix . "posts` WHERE post_date = '" . $post_time->post_date . "' ORDER BY ID LIMIT 1"; $results_post_id = $wpdb->get_results($id_query); if (isset($results_post_id)) { $product_id = $results_post_id[0]->ID; } else { $product_id = $item_value['product_id']; } //$duplicate_of = $item_value['product_id']; } //$product_id = $item_value['product_id']; if (in_array($product_id, (array) $array)) { } else { $booking_settings = get_post_meta($product_id, 'woocommerce_booking_settings', true); $qty = $item_value['qty']; $result = $a[$product_id]; $e = 0; foreach ($result as $k => $v) { $booking_id = $result[$e]; if ($booking_settings['booking_enable_multiple_day'] == 'on') { $select_data_query = "SELECT start_date,end_date FROM `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\tWHERE id='" . $booking_id . "'"; $results_data = $wpdb->get_results($select_data_query); $j = 0; foreach ($results_data as $k => $v) { $start_date = $results_data[$j]->start_date; $end_date = $results_data[$j]->end_date; $sql_delete_query = "DELETE FROM `" . $wpdb->prefix . "booking_history` WHERE id = '" . $booking_id . "' AND start_date =\t'" . $start_date . "' AND end_date = '" . $end_date . "' "; $wpdb->query($sql_delete_query); $j++; } } else { if ($booking_settings['booking_enable_time'] == 'on') { $type_of_slot = apply_filters('bkap_slot_type', $product_id); if ($type_of_slot == 'multiple') { do_action('bkap_order_status_cancelled', $order_id, $item_value, $booking_id); } else { $select_data_query = "SELECT * FROM `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\t\tWHERE id='" . $booking_id . "'"; $results_data = $wpdb->get_results($select_data_query); $j = 0; foreach ($results_data as $k => $v) { $start_date = $results_data[$j]->start_date; $from_time = $results_data[$j]->from_time; $to_time = $results_data[$j]->to_time; if ($from_time != '' && $to_time != '' || $from_time != '') { if ($to_time != '') { $query = "UPDATE `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\t\t\t\t\tSET available_booking = available_booking + " . $qty . "\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\tid = '" . $booking_id . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\tstart_date = '" . $start_date . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\tfrom_time = '" . $from_time . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\tto_time = '" . $to_time . "'"; } else { $query = "UPDATE `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\t\t\t\t\tSET available_booking = available_booking + " . $qty . "\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\tid = '" . $booking_id . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\tstart_date = '" . $start_date . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\tfrom_time = '" . $from_time . "'"; } $wpdb->query($query); } $j++; } } } else { $select_data_query = "SELECT * FROM `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\tWHERE id='" . $booking_id . "'"; $results_data = $wpdb->get_results($select_data_query); $j = 0; foreach ($results_data as $k => $v) { $start_date = $results_data[$j]->start_date; $from_time = $results_data[$j]->from_time; $to_time = $results_data[$j]->to_time; $query = "UPDATE `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\t\tSET available_booking = available_booking + " . $qty . "\n\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\tid = '" . $booking_id . "' AND\n\t\t\t\t\t\t\t\t\tstart_date = '" . $start_date . "' AND\n\t\t\t\t\t\t\t\t\tfrom_time = '' AND\n\t\t\t\t\t\t\t\t\tto_time = ''"; $wpdb->query($query); } $j++; } } $e++; } } $i++; $array[] = $product_id; } }
function bkap_woocommerce_cancel_order($order_id) { global $wpdb, $post; $array = array(); $order_obj = new WC_order($order_id); $order_items = $order_obj->get_items(); $select_query = "SELECT booking_id FROM `" . $wpdb->prefix . "booking_order_history`\n\t\t\t\t\t\t\t\tWHERE order_id='" . $order_id . "'"; $results = $wpdb->get_results($select_query); foreach ($results as $k => $v) { $b[] = $v->booking_id; $select_query_post = "SELECT post_id,id FROM `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\tWHERE id='" . $v->booking_id . "'"; $results_post[] = $wpdb->get_results($select_query_post); } //exit; if (isset($results_post) && count($results_post) > 0 && $results_post != false) { foreach ($results_post as $k => $v) { if (isset($v[0]->id)) { $a[$v[0]->post_id][] = $v[0]->id; } // $a[$v[0]->post_id][] = $v[0]->id; } } $i = 0; foreach ($order_items as $item_key => $item_value) { $product_id = get_post_meta($item_value['product_id'], '_icl_lang_duplicate_of', true); if ($product_id == '' && $product_id == null) { $post_time = get_post($item_value['product_id']); $id_query = "SELECT ID FROM `" . $wpdb->prefix . "posts` WHERE post_date = '" . $post_time->post_date . "' ORDER BY ID LIMIT 1"; $results_post_id = $wpdb->get_results($id_query); if (isset($results_post_id)) { $product_id = $results_post_id[0]->ID; } else { $product_id = $item_value['product_id']; } //$duplicate_of = $item_value['product_id']; } if (array_key_exists("variation_id", $item_value)) { $variation_id = $item_value['variation_id']; } else { $variation_id = ''; } if (in_array($product_id, (array) $array)) { } else { $booking_settings = get_post_meta($product_id, 'woocommerce_booking_settings', true); $qty = $item_value['qty']; if (isset($a[$product_id])) { $result = $a[$product_id]; } $e = 0; $from_time = ''; $to_time = ''; $date_date = ''; $end_date = ''; if (isset($result) && count($result) > 0 && $result != false) { foreach ($result as $k => $v) { $booking_id = $result[$e]; if (isset($booking_settings['booking_enable_multiple_day']) && $booking_settings['booking_enable_multiple_day'] == 'on') { $select_data_query = "SELECT start_date,end_date FROM `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE id='" . $booking_id . "'"; $results_data = $wpdb->get_results($select_data_query); $j = 0; foreach ($results_data as $k => $v) { $start_date = $results_data[$j]->start_date; $end_date = $results_data[$j]->end_date; $sql_delete_query = "DELETE FROM `" . $wpdb->prefix . "booking_history` WHERE id = '" . $booking_id . "' AND start_date =\t'" . $start_date . "' AND end_date = '" . $end_date . "' "; $wpdb->query($sql_delete_query); $j++; } } else { if (isset($booking_settings['booking_enable_time']) && $booking_settings['booking_enable_time'] == 'on') { $type_of_slot = apply_filters('bkap_slot_type', $product_id); if ($type_of_slot == 'multiple') { do_action('bkap_order_status_cancelled', $order_id, $item_value, $booking_id); } else { $select_data_query = "SELECT * FROM `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE id='" . $booking_id . "'"; $results_data = $wpdb->get_results($select_data_query); $j = 0; foreach ($results_data as $k => $v) { $start_date = $results_data[$j]->start_date; $from_time = $results_data[$j]->from_time; $to_time = $results_data[$j]->to_time; if ($from_time != '' && $to_time != '' || $from_time != '') { if ($to_time != '') { $query = "UPDATE `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tSET available_booking = available_booking + " . $qty . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid = '" . $booking_id . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tstart_date = '" . $start_date . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom_time = '" . $from_time . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tto_time = '" . $to_time . "'"; $select = "SELECT * FROM `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE post_id = '" . $product_id . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tstart_date = '" . $start_date . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom_time = '" . $from_time . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tto_time = '" . $to_time . "'"; $select_results = $wpdb->get_results($select); foreach ($select_results as $k => $v) { $details[$product_id] = $v; } } else { $query = "UPDATE `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tSET available_booking = available_booking + " . $qty . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid = '" . $booking_id . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstart_date = '" . $start_date . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfrom_time = '" . $from_time . "'"; $select = "SELECT * FROM `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE post_id = '" . $product_id . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tstart_date = '" . $start_date . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom_time = '" . $from_time . "'"; $select_results = $wpdb->get_results($select); foreach ($select_results as $k => $v) { $details[$product_id] = $v; } } $wpdb->query($query); } $j++; } } } else { $select_data_query = "SELECT * FROM `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\t\t\t\tWHERE id='" . $booking_id . "'"; $results_data = $wpdb->get_results($select_data_query); $j = 0; foreach ($results_data as $k => $v) { $start_date = $results_data[$j]->start_date; $from_time = $results_data[$j]->from_time; $to_time = $results_data[$j]->to_time; $query = "UPDATE `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\t\t\t\tSET available_booking = available_booking + " . $qty . "\n\t\t\t\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\t\t\tid = '" . $booking_id . "' AND\n\t\t\t\t\t\t\t\t\t\t\tstart_date = '" . $start_date . "' AND\n\t\t\t\t\t\t\t\t\t\t\tfrom_time = '' AND\n\t\t\t\t\t\t\t\t\t\t\tto_time = ''"; $wpdb->query($query); } $j++; } } $e++; } } } $book_global_settings = json_decode(get_option('woocommerce_booking_global_settings')); $label = get_option("book.item-meta-date"); //print_r($item_value); //$date = str_replace("-","/",$item_value[$label]); $hidden_date = date('d-n-Y', strtotime($start_date)); //print_r($hidden_date); if (isset($booking_settings['booking_time_settings'][$hidden_date])) { $lockout_settings = $booking_settings['booking_time_settings'][$hidden_date]; } else { $lockout_settings = array(); } if (count($lockout_settings) > 0) { $week_day = date('l', strtotime($hidden_date)); //print_r($week_day); $weekdays = book_arrays('weekdays'); //print_r($weekdays); $weekday = array_search($week_day, $weekdays); if (isset($booking_settings['booking_time_settings'][$weekday])) { $lockout_settings = $booking_settings['booking_time_settings'][$weekday]; } else { $lockout_settings = array(); } //print_r($lockout_settings); } $from_lockout_time = explode(":", $from_time); if (isset($from_lockout_time[0])) { $from_hours = $from_lockout_time[0]; } else { $from_hours = ''; } if (isset($from_lockout_time[1])) { $from_minute = $from_lockout_time[1]; } else { $from_minute = ''; } if ($to_time != '') { $to_lockout_time = explode(":", $to_time); $to_hours = $to_lockout_time[0]; $to_minute = $to_lockout_time[1]; } else { $to_hours = ''; $to_minute = ''; } if (count($lockout_settings) > 0) { foreach ($lockout_settings as $l_key => $l_value) { if ($l_value['from_slot_hrs'] == $from_hours && $l_value['from_slot_min'] == $from_minute && $l_value['to_slot_hrs'] == $to_hours && $l_value['to_slot_min'] == $to_minute) { if (isset($l_value['global_time_check'])) { $global_timeslot_lockout = $l_value['global_time_check']; } else { $global_timeslot_lockout = ''; } //print_r($global_timeslot_lockout); } } } //print_r($book_global_settings); //print_r($lockout_settings);exit; if ($book_global_settings->booking_global_timeslot == 'on' || $global_timeslot_lockout == 'on') { $args = array('post_type' => 'product', 'posts_per_page' => -1); $product = query_posts($args); foreach ($product as $k => $v) { $product_ids[] = $v->ID; } //print_r($details); //print_r($product_ids);exit; foreach ($product_ids as $k => $v) { $duplicate_of = get_post_meta($v, '_icl_lang_duplicate_of', true); if ($duplicate_of == '' && $duplicate_of == null) { $post_time = get_post($v); $id_query = "SELECT ID FROM `" . $wpdb->prefix . "posts` WHERE post_date = '" . $post_time->post_date . "' ORDER BY ID LIMIT 1"; $results_post_id = $wpdb->get_results($id_query); if (isset($results_post_id)) { $duplicate_of = $results_post_id[0]->ID; } else { $duplicate_of = $v; } //$duplicate_of = $item_value['product_id']; } $booking_settings = get_post_meta($v, 'woocommerce_booking_settings', true); if (isset($booking_settings['booking_enable_time']) && $booking_settings['booking_enable_time'] == 'on') { //echo "ehere";exit; if (count($details) > 0) { if (!array_key_exists($duplicate_of, $details)) { foreach ($details as $key => $val) { //$booking_settings = get_post_meta($duplicate_of, 'woocommerce_booking_settings', true); //echo"<pre>";print_r($booking_settings);echo"</pre>";exit; $start_date = $val->start_date; $from_time = $val->from_time; $to_time = $val->to_time; if ($to_time != "") { $query = "UPDATE `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\t\t\t\t\tSET available_booking = available_booking + " . $qty . "\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE post_id = '" . $duplicate_of . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\tstart_date = '" . $start_date . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\tfrom_time = '" . $from_time . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\tto_time = '" . $to_time . "'"; $wpdb->query($query); //echo $query;exit; } else { $query = "UPDATE `" . $wpdb->prefix . "booking_history`\n\t\t\t\t\t\t\t\t\t\t\t\t\tSET available_booking = available_booking + " . $qty . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE post_id = '" . $duplicate_of . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tstart_date = '" . $start_date . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom_time = '" . $from_time . "'"; //$wpdb->query( $query ); $wpdb->query($query); } } } } } } } $i++; $array[] = $product_id; } }
/** * process_subscription_payment function. * * @param WC_order $order * @param integer $amount (default: 0) * @return bool|WP_Error */ public function process_subscription_payment($order = '', $amount = 0) { $order_items = $order->get_items(); $order_item = array_shift($order_items); $subscription_name = sprintf(__('%s - Subscription for "%s"', 'woocommerce-payment-gateway-boilerplate'), esc_html(get_bloginfo('name')), $order_item['name']) . ' ' . sprintf(__('(Order %s)', 'woocommerce-payment-gateway-boilerplate'), $order->get_order_number()); if ($amount * 100 < 50) { return new WP_Error('simplify_error', __('Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce-payment-gateway-boilerplate')); } if ('APPROVED' == $payment['status']) { // Payment complete $order->payment_complete($payment->id); // Add order note $order->add_order_note(sprintf(__('Gateway name payment approved (ID: %s)', 'woocommerce-payment-gateway-boilerplate'), $payment['id'])); return true; } else { $order->add_order_note(__('Gateway name payment declined', 'woocommerce-payment-gateway-boilerplate')); return new WP_Error('gateway_name_payment_declined', __('Payment was declined - please try again.', 'woocommerce-payment-gateway-boilerplate')); } }
<?php wp_head(); ?> </head> <body <?php body_class(); ?> > <?php if (is_wc_endpoint_url('order-received')) { $order_id = wc_get_order_id_by_order_key($_GET['key']); $order1 = new WC_order($order_id); $order_items = array_values($order1->get_items()); $net_amount = $order_items[0]['line_subtotal']; $tax_amount = $order_items[0]['line_subtotal_tax']; $product_name = $order_items[0]['name']; $product_id = $order_items[0]['product_id']; $belboon = $_SESSION['belboon']; $url_home = home_url(); ?> <img src="https://www1.belboon.de/adtracking/sale/000021772.gif/oc=<?php echo $order_id; ?> &sale=<?php echo $net_amount; ?> &belboon=<?php echo $belboon;