2015-05-01 5 views
5

मैं अपनी WordPress साइट के लिए प्लगइन woocommerce का उपयोग कर रहा हूं, और उस अनुभाग की आवश्यकता है जहां सदस्य अपना ऑर्डर इतिहास देख सकें। क्या Woocommerce में कोई शॉर्टकोड या पृष्ठ है जो किसी सदस्य का ऑर्डर इतिहास दिखाता है?, क्या सभी ऑर्डर देखने के लिए कोई शोर्ट/पेज है?

उत्तर

12

मेरा खाता शोर्ट:

[woocommerce_my_account order_count="-1"] 

Shows the ‘my account’ section where the customer can view past orders and update their information. You can specify the number or order to show, it’s set by default to 15 (use -1 to display all orders.)

संदर्भ: Woocommerce Shortcodes


अद्यतन

आप केवल आदेश की जरूरत है हो, तो मैं नहीं जानता कि alread y एक शोर्ट, लेकिन मैं उदाहरण के रूप में एक लेने woocommerce_my_account बनाया:

function shortcode_my_orders($atts) { 
    extract(shortcode_atts(array(
     'order_count' => -1 
    ), $atts)); 

    ob_start(); 
    wc_get_template('myaccount/my-orders.php', array(
     'current_user' => get_user_by('id', get_current_user_id()), 
     'order_count' => $order_count 
    )); 
    return ob_get_clean(); 
} 
add_shortcode('my_orders', 'shortcode_my_orders'); 

अपने functions.php फाइल करने के लिए इस जोड़ें और फिर [my_orders order_counts=10] की तरह उपयोग (order_counts वैकल्पिक है, अगर यह याद आ रही सभी आदेशों को सूचीबद्ध करता है)।

+0

वास्तव में यह सिर्फ मुझे मेरे खाते पृष्ठ, जहां उपयोगकर्ता अपनी शिपिंग पतों को देख सकते हैं और स्वागत संदेश जब मेरा खाता पृष्ठ में करने के लिए भेजा। – dave

+0

महान धन्यवाद आदमी। मैं उस एप की कोशिश करूंगा। – dave

+0

ठीक है मैंने उस उपरोक्त कोड को रूट/wp-include/functions.php में रखने की कोशिश की लेकिन मुझे "घातक त्रुटि: सी में परिभाषित फ़ंक्शन add_shortcode() में कॉल करें: \ xampp \ htdocs \ localpressjuicery \ wp- \ functions शामिल हैं। php " – dave

0

मैं निकालने के बारे में पढ़ रहा था और स्पष्ट रूप से इसकी वर्डप्रेस द्वारा अनुशंसित नहीं है। मैं इस soloution पाया, उम्मीद है कि इस मदद करता है:

function shortcode_my_orders($atts) { 
$args= shortcode_atts( 
array(
    'order_count' => -1 
    ), 
$atts 
); 
$order_count = esc_attr($args['order_count']); 


ob_start(); 
wc_get_template('myaccount/my-orders.php', array(
    'current_user' => get_user_by('id', get_current_user_id()), 
    'order_count' => $order_count 
)); 
return ob_get_clean(); 

}

+0

हाय मैं नाम कैसे शामिल कर सकता हूं? – winresh24

संबंधित मुद्दे