देता है मैं WooCommerce के साथ एक ऑनलाइन दुकान बना रहा हूं और मैं एक फ़ंक्शन जोड़ रहा हूं जो absract-wc-payment-gateway.php
में मेरे डेटाबेस में बोनस प्वाइंट अपडेट करेगा।WooCommerce - get_order() काम नहीं करता है और यह शून्य
यहाँ मैं क्या कर रहा हूँ है:
- सबसे पहले, चेकआउट पृष्ठ पर, उपयोगकर्ताओं
place order
बटन पर क्लिक करें और फिर विधिget-total()
के साथ उपयोगकर्ताओं को बोनस अंक और शून्य से बोनस अंक मिल जाएगा, और उसके बाद डेटाबेस में अद्यतन करें और धन्यवाद पृष्ठ पर जाएं।
- फिर, का शुक्रिया पेज डेटाबेस से उपयोगकर्ता की बोनस अंक मिल जाएगा। और मैं 2000 के लिए बोनस अंक मान सेट तो इस मामले में, बोनस अंक ($ 50.00) कुल अंकों शून्य से
यहाँ मेरी कोड है होना चाहिए।
global $woocommerce;
$order = new WC_Order($order_id);
$total = $order->get_total();
$bonusPoint -= (int)$total; //minus total price and calculate the latest bonus point
$updateSql = "UPDATE userdata02 SET bonusPoint ='" .$bonusPoint. "' WHERE userID = 2147483647";
mysqli_query($link, $updateSql);// update to an int column
if(mysqli_query($link, $updateSql)) {
echo "Record updated successfully";
} else {
echo "Error update record: <>" . mysqli_error($link);
}
कॉल विधि जब उपयोगकर्ता जगह बटन क्लिक करता है: जब उपयोगकर्ता जगह आदेश बटन क्लिक करता है यह भाग गया हो जाएगा
public function get_return_url($order = null) {
if ($order) {
//$message = "wrong answer";
//echo "<script type='text/javascript'>alert('$message');</script>";
$return_url = $order->get_checkout_order_received_url();
} else {
$return_url = wc_get_endpoint_url('order-received', '', wc_get_page_permalink('checkout'));
}
if (is_ssl() || get_option('woocommerce_force_ssl_checkout') == 'yes') {
$return_url = str_replace('http:', 'https:', $return_url);
}
self::reducePoints(); //Call reducePoints();
return apply_filters('woocommerce_get_return_url', $return_url, $order);
}
स्रोत कोड: abstract-WC-Payment-Gateway.php
से reducePoints()
लाइनों 89 get_total()
काम नहीं करता है और यह शून्य लौटाता है।
मैं क्या गलत कर रहा हूं?
क्या आपने त्रुटि लॉग जांच की है कि यह आंतरिक त्रुटि क्यों हो रही है? –