پیگیری سفارش در ووکامرس

پیام یزدانیان

کاربر عضو
سلام مجدد
دوستان عزیزی ک این مورد رو اطلاع دادن ..کدها رو درست گذاشتم ظاهرا بعد از تغییر سیستم انجمن خراب شدن..
........
مجددا توضیح میدم :

فایل "class-wc-shortcode-order-tracking.php "موجود در مسیر :

woocommerce\includes\shortcodes

را با کدهای زیر که خودم تغییردادم جایگزین کنید

PHP:
<?php
/**
 * Order Tracking Shortcode
 *
 * Lets a user see the status of an order by entering their order details.
 *
 * @package WooCommerce/Shortcodes/Order_Tracking
 * @version 3.0.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * Shortcode order tracking class.
 */
class WC_Shortcode_Order_Tracking {

    /**
     * Get the shortcode content.
     *
     * @param array $atts Shortcode attributes.
     * @return string
     */
    public static function get( $atts ) {
        return WC_Shortcodes::shortcode_wrapper( array( __CLASS__, 'output' ), $atts );
    }

    /**
     * Output the shortcode.
     *
     * @param array $atts Shortcode attributes.
     */
    public static function output( $atts ) {
        // Check cart class is loaded or abort.
        if ( is_null( WC()->cart ) ) {
            return;
        }

        $atts        = shortcode_atts( array(), $atts, 'woocommerce_order_tracking' );
        $nonce_value = wc_get_var( $_REQUEST['woocommerce-order-tracking-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine.

        if ( isset( $_REQUEST['orderid'] ) && wp_verify_nonce( $nonce_value, 'woocommerce-order_tracking' ) ) { // WPCS: input var ok.

            $order_id    = empty( $_REQUEST['orderid'] ) ? 0 : ltrim( wc_clean( wp_unslash( $_REQUEST['orderid'] ) ), '#' ); // WPCS: input var ok.
            

            if ( ! $order_id ) {
                wc_print_notice( __( 'Please enter a valid order ID', 'woocommerce' ), 'error' );
            }  else {
                $order = wc_get_order( apply_filters( 'woocommerce_shortcode_order_tracking_order_id', $order_id ) );

                if ( $order && $order->get_id() && strtolower( $order->get_id() ) === strtolower( $order_id ) ) {
                    do_action( 'woocommerce_track_order', $order->get_id() );
                    wc_get_template(
                        'order/tracking.php', array(
                            'order' => $order,
                        )
                    );
                    return;
                } else {
                    wc_print_notice( __( 'Sorry, the order could not be found. Please contact us if you are having difficulty finding your order details.', 'woocommerce' ), 'error' );
                }
            }
        }

        wc_get_template( 'order/form-tracking.php' );
    }
}



اینم فایل پیوست شد.
بقیه اش هم ک مشخصه
فقط تو استایل قالب :


این رو اضافه کنید :
CSS:
.track_order .form-row-last {
display:none;
}
 

پیوست‌ها

  • class-wc-shortcode-order-tracking.zip
    1.1 کیلوبایت · بازدیدها: 18
  • Like
واکنش‌ها[ی پسندها]: tack

tack

تازه وارد
اون فایل form-tracking.php درستش اینه :

PHP:
<?php
/**
 * Order tracking form
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/order/form-tracking.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see https://docs.woocommerce.com/document/template-structure/
 * @package WooCommerce/Templates
 * @version 3.6.0
 */

defined( 'ABSPATH' ) || exit;

global $post;
?>

<form action="<?php echo esc_url( get_permalink( $post->ID ) ); ?>" method="post" class="track_order">

    <p><?php esc_html_e( 'To track your order please enter your Order ID in the box below and press the "Track" button. This was given to you on your receipt and in the confirmation email you should have received.', 'woocommerce' ); ?></p>

    <p class="form-row form-row-first"><label for="orderid"><?php esc_html_e( 'Order ID', 'woocommerce' ); ?></label> <input class="input-text" type="text" name="orderid" id="orderid" value="<?php echo isset( $_REQUEST['orderid'] ) ? esc_attr( wp_unslash( $_REQUEST['orderid'] ) ) : ''; ?>" placeholder="<?php esc_attr_e( 'Found in your order confirmation email.', 'woocommerce' ); ?>" /></p><?php // @codingStandardsIgnoreLine ?> 
  <div class="clear"></div>

    <p class="form-row"><button type="submit" class="button" name="track" value="<?php esc_attr_e( 'Track', 'woocommerce' ); ?>"><?php esc_html_e( 'Track', 'woocommerce' ); ?></button></p>
    <?php wp_nonce_field( 'woocommerce-order_tracking', 'woocommerce-order-tracking-nonce' ); ?>

</form>
 
بالا