我有下一个项目结构
How to get Customer details from Order in WooCommerce?
我想在<?php
// For logged in users only
if ( is_user_logged_in() ) :
$user_id = get_current_user_id(); // The current user ID
// Get the WC_Customer instance Object for the current user
$customer = new WC_Customer( $user_id );
// Get the last WC_Order Object instance from current customer
$last_order = $customer->get_last_order();
$order_id = $last_order->get_id(); // Get the order id
$order_data = $last_order->get_data(); // Get the order unprotected data in an array
$order_status = $last_order->get_status(); // Get the order status
?>
<div class="row last-order">
<div class="col-md-7">
<ul>
<?php foreach ( $last_order->get_items() as $item ) : ?>
<li><?php echo $item->get_name(); ?></li>
<?php endforeach; ?>
</ul>
</div>
<div class="col-md-4 order-status-box">
<h6 class="status"><?php echo esc_html( wc_get_order_status_name( $order_status ) ); ?></h6>
<i class="fas fa-chevron-down icon"></i>
</div>
</div>
<?php endif; ?>
中创建一个信号,但出现错误
无法导入“博客”。检查“ project.blog.apps.BlogConfig.name” 是正确的。
如果我在 __ init __。py 中写blog application
,则会收到错误消息:
没有名为“博客”的模块
settings.py
default_app_config = 'blog.apps.BlogConfig'
apps.py
INSTALLED_APPS = [
#...
# project apps
'project.blog',
#...
]
__ init __。py
class BlogConfig(AppConfig):
name = 'blog'
def ready(self):
import blog.signals