小编yos*_*ber的帖子

设置特定 WooCommerce 产品类别的购物车商品的最低数量

在 WooCommerce 中,我尝试为特定产品类别的购物车商品设置最低数量。

根据“ WooCommerce 中特定产品类别的最小购物车商品数量”,这是我的代码尝试:

add_action( 'woocommerce_check_cart_items', 'wc_min_item_required_qty' );
function wc_min_item_required_qty() {
    $category      = 'games'; // The targeted product category
    $min_item_qty  = 4; // Minimum Qty required (for each item)
    $display_error = false; // Initializing

    // Loop through cart items
    foreach(WC()->cart->get_cart() as $cart_item ) {
        $item_quantity = $cart_item['quantity']; // Cart item quantity
        $product_id    = $cart_item['product_id']; // The product ID

        // For cart items remaining to "Noten" producct category
        if( has_term( $category, 'product_cat', $product_id ) && $item_quantity < $min_item_qty …
Run Code Online (Sandbox Code Playgroud)

php wordpress cart custom-taxonomy woocommerce

3
推荐指数
1
解决办法
991
查看次数

Laravel:使用更新的迁移将列添加到表

我正在尝试在一个迁移文件中迁移特定行。

例:

之前:

Schema::create('categories', function (Blueprint $table) {
  $table->bigIncrements('id');
  $table->string('category_name');
  $table->integer('parent_id')->nullable();
  $table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)

后:

Schema::create('categories', function (Blueprint $table) {
  $table->bigIncrements('id');
  $table->string('category_name');
  $table->string('img_url'); // ? new column
  $table->integer('parent_id')->nullable();
  $table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)

现在我只想迁移该行: $table->string('img_url');

可能吗?

php migration schema laravel

2
推荐指数
1
解决办法
48
查看次数

从 axios 响应中获取数据(Vuejs)

所以我使用 axios 从 url 获取 api

这是我的代码:

<html>
<head>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="{{asset("/core/vue.js")}}" type="text/javascript"></script>
</head>
<body>
<div id="app">
    @{{ info }}
    <button v-on:click.prevent="GetId($event)" value="1">click me!</button>
</div>

<style>
</style>
<script type="text/javascript" language="JavaScript">
    new Vue({
        el: '#app',
        data: {
                info: null,
                value: null
        },
        methods:{
            GetId:function (event) {
                element = event.currentTarget;
                value = element.getAttribute('value');
                axios
                    .get('/api/GetProduct/'+value)
                    .then(response => (this.info = response))
                    .then(this.value = value)
                    .catch(error => console.log(error))
                }
            },
    })
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

但问题是我得到了一个长数组,我只需要数据从中。

我尝试使用response.$data但在这里不起作用是我得到的响应:

{ "data": { …
Run Code Online (Sandbox Code Playgroud)

laravel vue.js axios

2
推荐指数
1
解决办法
6024
查看次数