商品分類


Woocommerce Session 控制方法

2021-10-12 14:17

設定

WC()->session->set($key, $value);

 

取得

WC()->session->get($key);

 

Service

<?php
namespace Plugin\App\Services;

class SessionService
{
    public static function set($key, $value)
    {
        WC()->session->set($key, $value);
        return self::get($key);
    }

    public static function get($key, $def = false)
    {
        $value = WC()->session->get($key);
        return $value ? $value : $def;
    }
}

購物車

購物車無商品
  • NT$ {{ Utils . numberWithCommas(item . product . price) }} x {{ item . qty }} = NT$ {{ Utils . numberWithCommas(item . product . price * item . qty) }}
小計:
NT$ {{ Utils . numberWithCommas(cart . subtotal) }}
總計:
NT$ {{ Utils . numberWithCommas(cart . total) }}
購物車