我正在编写一个批处理过程,以从名为tbl_bankimport的mysql表中导入一些订单:
<section>
<h1>Pick subtests you need in accordion list</h1>
<div class="accordion">
{#each cats_tests as ct, ctidx }
<div class="wrapper">
<h2 class="ct-heading">
<label>
<input bind:group='selected' value={ ctidx } type=checkbox />
<span>{ ctidx }: { ct.name }</span>
</label>
</h2>
{#if selected[ctidx] }
{#each ct.subtests as sub, subidx }
<div transition:fade>
<h3 class="subtest-heading">
<label for="ct-{ctidx}-sub-{subidx}">
<input id="ct-{ctidx}-sub-{subidx}" type="checkbox" />
<span>{ subidx }: { sub.name }</span>
</label>
</h3>
</div>
{/each}
{/if}
</div>
{/each}
</div>
</section>
<script>
import { fade } from 'svelte-transitions'
export default {
transitions: { fade},
oncreate() {
},
data() {
return {
cats_tests: [
{
name: 'Cat A - Test 1',
subtests: [
{ name: 'subtest-s'},
{ name: 'subtest-t'},
{ name: 'subtest-u'}
]
}, {
name: 'Cat A - Test 2',
subtests: [
{ name: 'subtest-v'},
{ name: 'subtest-w'},
{ name: 'subtest-x'} ,
{ name: 'subtest-y'}
]
}, {
name: 'Cat B - Test 3',
subtests: [
{ name: 'subtest-z'}
]
}
]
}
}
}
</script>
<style>
h2.ct-heading {
background-color: #d1e1f1;
}
h3.subtest-heading {
padding-left: 15%;
}
</style>
在我的测试文件中,我有47条记录,当我运行该记录时,我在屏幕上得到了47条订单回显。但是我最终在woocommerce中获得了94条记录!
如果我清除订单,则替换为:
$bankrecs = $wpdb->get_results("Select * from tbl_bankimport");
foreach ($bankrecs as $bankrec) {
$order = wc_create_order(array(['customer_id' => $bankrec->user_id]));
echo "Order " . $order->id . "created </br>";
}
使用
$order = wc_create_order(array(['customer_id' => $bankrec->user_id]));
然后重新运行,我输入了47条记录。
迷惑和神秘!
答案 0 :(得分:0)
从数据数组中排除customer_id并添加它,如下所示:
update_post_meta($ order-> id,'_customer_user',bankrecs-> user_id);
似乎是解决方案。