我正在构建一个表单供用户使用wp_insert_post和通过我的网站前端创建产品update_post_meta.
尝试设置产品类别和标签时出现问题.在这方面,Woocommerce似乎没有使用标准的Wordpress分类法.有人对此有经验吗?Woocommerce似乎product_tags在某些地方使用.有没有像Wordpress一样创建它们的功能?
下面是我正在做的事情的片段.谢谢!
$post = array(
'ID' => '',
'post_content' => $_POST['post_content'],
'post_title' => $_POST['post_title'],
'post_status' => 'draft',
'post_type' => 'product',
'post_author' => $user_id,
);
$newListing = wp_insert_post($post, $wp_error);
//SET META
update_post_meta($newListing, '_stock_status', 'instock', true);
update_post_meta($newListing, '_visibility', 'visible', true);
update_post_meta($newListing, '_price', $_POST['_regular_price'], true);
//SET CATEGORIES - **NOT WORKING**
wp_set_post_categories($newListing, $categories);
//SET THE TAGS **NOT WORKING**
wp_set_post_tags($newListing, $tags, true);
Run Code Online (Sandbox Code Playgroud) 我有一个包含可扩展行的 vuetify 数据表。我与演示的唯一真正区别是,我希望该item.name列能够像 V 形图标一样打开/关闭可扩展行。当我在该列的 v 槽上放置一个@click处理程序时,我收到错误Error in v-on handler: "TypeError: expand is not a function"。这是我需要自定义的唯一列,因此我不想<tr>手动构建整个 v 槽。下面是缩小的代码示例。谢谢。
<v-data-table
:headers="headers"
:items="products"
item-key="productCode"
show-expand
:expanded.sync="expanded"
>
<template v-slot:item.name="{ item, expand, isExpanded }" >
<h4 class="my-2" @click="expand(!isExpanded)">{{ item.name }} located in {{ item.depot | camelToWords }}</h4>
</template>
<template v-slot:expanded-item="{ headers, item }">
<ProductDetailExpandedRow :currentProduct="item" :headers="headers"/>
</template>
</v-data-table>
<script>
export default {
data() {
return {
headers: [
{
text: 'Name',
value: 'name', …Run Code Online (Sandbox Code Playgroud) categories ×1
html ×1
javascript ×1
php ×1
tags ×1
v-slot ×1
vue.js ×1
vuetify.js ×1
woocommerce ×1
wordpress ×1