cari

Rumah  >  Soal Jawab  >  teks badan

Masukkan ID pesanan daripada halaman ke dalam fungsi wc_get_order().

<p>我想将数据输出更改为表格。</p> <p>这是表格代码:</p> <pre class="brush:php;toolbar:false;"><div class=&quot;filters&quot;> <form> <div class=&quot;filters-row&quot;> <input type=&quot;hidden&quot; class=&quot;product-search wc-product-search&quot; name=&quot;product_id&quot; data-placeholder=&quot;<?php esc_html_e( 'Product:', 'yith-woocommerce-affiliates' ); ?>&quot; value=&quot;<?php echo esc_attr( $product_id ); ?>&quot; data-selected=&quot;<?php echo esc_attr( $product_name ); ?>&quot; /> <input type=&quot;text&quot; class=&quot;datepicker&quot; name=&quot;from&quot; placeholder=&quot;<?php esc_html_e( 'From:', 'yith-woocommerce-affiliates' ); ?>&quot; value=&quot;<?php echo esc_attr( $from ); ?>&quot;/> <input type=&quot;text&quot; class=&quot;datepicker&quot; name=&quot;to&quot; placeholder=&quot;<?php esc_html_e( 'To:', 'yith-woocommerce-affiliates' ); ?>&quot; value=&quot;<?php echo esc_attr( $to ); ?>&quot;/> <label for=&quot;per_page&quot; class=&quot;per-page&quot;> <?php esc_html_e( 'Items per page:', 'yith-woocommerce-affiliates' ); ?> <input max=&quot;100&quot; min=&quot;1&quot; step=&quot;1&quot; type=&quot;number&quot; name=&quot;per_page&quot; value=&quot;<?php echo esc_attr( $per_page ); ?>&quot;/> </label> </div> <div class=&quot;button-row&quot;> <input type=&quot;submit&quot; value=&quot;<?php esc_html_e( 'Filter', 'yith-woocommerce-affiliates' ); ?>&quot;/> <?php if ( $filter_set ) : ?> <a href=&quot;<?php echo esc_url( $dashboard_commissions_link ); ?>&quot;><?php esc_html_e( 'Reset', 'yith-woocommerce-affiliates' ); ?></a> <?php endif; ?> </div> </form> </div> <table class=&quot;shop_table&quot; id=&quot;table&quot;> <thead> <tr> <th class=&quot;column-id&quot;> <a rel=&quot;nofollow&quot; class=&quot;<?php echo ( 'ID' === $ordered ) ? 'ordered to-order-' . esc_attr( strtolower( $to_order ) ) : ''; ?>&quot; href=&quot;<?php echo esc_url( add_query_arg( array( 'orderby' => 'ID', 'order' => $to_order ) ) ); ?>&quot;><?php esc_html_e( '#/ID', 'yith-woocommerce-affiliates' ); ?></a> </th> <th class=&quot;column-date&quot;> <a rel=&quot;nofollow&quot; class=&quot;<?php echo ( 'created_at' === $ordered ) ? 'ordered to-order-' . esc_attr( strtolower( $to_order ) ) : ''; ?>&quot; href=&quot;<?php echo esc_url( add_query_arg( array( 'orderby' => 'created_at', 'order' => $to_order ) ) ); ?>&quot;><?php esc_html_e( 'Date', 'yith-woocommerce-affiliates' ); ?></a> </th> <th class=&quot;column-product&quot;> <a rel=&quot;nofollow&quot; class=&quot;<?php echo ( 'product_name' === $ordered ) ? 'ordered to-order-' . esc_attr( strtolower( $to_order ) ) : ''; ?>&quot; href=&quot;<?php echo esc_url( add_query_arg( array( 'orderby' => 'product_name', 'order' => $to_order ) ) ); ?>&quot;><?php esc_html_e( 'Domain', 'yith-woocommerce-affiliates' ); ?></a> </th> <th class=&quot;column-rate&quot;> <a rel=&quot;nofollow&quot; class=&quot;<?php echo ( 'rate' === $ordered ) ? 'ordered to-order-' . esc_attr( strtolower( $to_order ) ) : ''; ?>&quot; href=&quot;<?php echo esc_url( add_query_arg( array( 'orderby' => 'rate', 'order' => $to_order ) ) ); ?>&quot;><?php esc_html_e( 'Coupon', 'yith-woocommerce-affiliates' ); ?></a> </th> <th class=&quot;column-amount&quot;> <a rel=&quot;nofollow&quot; class=&quot;<?php echo ( 'amount' === $ordered ) ? 'ordered to-order-' . esc_attr( strtolower( $to_order ) ) : ''; ?>&quot; href=&quot;<?php echo esc_url( add_query_arg( array( 'orderby' => 'amount', 'order' => $to_order ) ) ); ?>&quot;><?php esc_html_e( 'Bonus', 'yith-woocommerce-affiliates' ); ?></a> </th> <th class=&quot;column-status&quot;> <a rel=&quot;nofollow&quot; class=&quot;<?php echo ( 'status' === $ordered ) ? 'ordered to-order-' . esc_attr( strtolower( $to_order ) ) : ''; ?>&quot; href=&quot;<?php echo esc_url( add_query_arg( array( 'orderby' => 'status', 'order' => $to_order ) ) ); ?>&quot;><?php esc_html_e( 'Status', 'yith-woocommerce-affiliates' ); ?></a> </th> </tr> </thead> <tbody> <?php if ( ! empty( $commissions ) ) : ?> <?php foreach ( $commissions as $commission ) : ?> <tr> <td class=&quot;column-id&quot;><?php echo esc_html( $commission['ID'] ); ?> <span><?php echo esc_html( $commission['order_id'] ); ?></span></td> <td class=&quot;column-date&quot;><?php echo esc_html( date_i18n( wc_date_format(), strtotime( $commission['created_at'] ) ) ); ?></td> <td class=&quot;column-product&quot;><a target=&quot;_blank&quot; href=&quot;<?php echo esc_url( get_permalink( $commission['product_id'] ) ); ?>&quot;><?php echo do_shortcode( '[xyz-ips snippet=&quot;order&quot;]' ); ?></a> </td> <td class=&quot;column-rate&quot;><?php foreach ( $coupons as $coupon_id => $coupon ) : ?><?php echo esc_html( $coupon['amount'] ); ?> <?php endforeach; ?></td> <td class=&quot;column-amount&quot;><?php echo wc_price( $commission['amount'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></td> <td class=&quot;column-status <?php echo esc_attr( $commission['status'] ); ?>&quot;><a rel=&quot;nofollow&quot; href=&quot;<?php echo esc_url( add_query_arg( 'status', $commission['status'] ) ); ?>&quot;><?php echo esc_html( YITH_WCAF_Commission_Handler()->get_readable_status( $commission['status'] ) ); ?></a></td> </tr> <?php endforeach; ?> <?php else : ?> <tr> <td class=&quot;empty-set&quot; colspan=&quot;6&quot;><?php esc_html_e( 'Sorry! There are no registered commissions yet', 'yith-woocommerce-affiliates' ); ?></td> </tr> <?php endif; ?> </tbody> </table></pre> <p>在此代码行中:</p> <pre class="brush:php;toolbar:false;"><td class=&quot;column-product&quot;><a target=&quot;_blank&quot; href=&quot;<?php echo esc_url( get_permalink( $commission['product_id'] ) ); ?>&quot;><?php echo do_shortcode( '[xyz-ips snippet=&quot;order&quot;]' ); ?></a></td></pre> <p>我已经粘贴了 php 代码的简码。</p> <p>这是短代码中的代码:</p> <pre class="brush:php;toolbar:false;"><?php global $wpdb; // the object WC_Order $order = wc_get_order(2314 ); $data = $order->get_data(); // order data echo $data['billing']['company']; ?></pre> <p>代码成功运行并输出“company”字段。但是有一个问题。我需要 wc_get_order( 2314 ); 行插入一个函数来替换页面中的订单 ID。</p> <p>订单ID通过代码显示在页面上:</p> <pre class="brush:php;toolbar:false;"><td class=&quot;column-id&quot;><?php echo esc_html( $commission['ID'] ); ?> <span><?php echo esc_html( $commission['order_id'] ); ?></span></td></pre> <p>如何输入“wc_get_order(2314);”而不是代码中的“2314” ID <code><?php echo esc_html( $commission['order_id'] ); ?></code></p> <p>表格如下所示: </p>
P粉969253139P粉969253139458 hari yang lalu581

membalas semua(1)saya akan balas

  • P粉563446579

    P粉5634465792023-09-03 00:51:06

    Tambahkan parameter tersuai pada bahagian belakangorderid

    <?php echo do_shortcode( '[xyz-ips snippet="order" orderid="'. $commission['order_id'] . '"]' ); ?>

    Skrip kod pendek anda:

    <?php 
    global $wpdb;
    // the object WC_Order
    $order =  wc_get_order({orderid});
    
    $data = $order->get_data(); // order data
    echo $data['billing']['company'];
    
    ?>

    balas
    0
  • Batalbalas