• プラグイン一覧
    - WCEX Item Combo Set
    - WCEX Amazon Pay
    - WCEX Wishlist お気に入りリスト
  • リリース情報
  • お役立ちコラム
  • お問い合わせ
  • サポート
    • よくある質問
      • WCEX Amazon Pay
      • WCEX Wishlist お気に入りリスト
      • wcex-item-combo-set
    • リファレンス
      • WCEX Amazon Pay
      • WCEX Wishlist お気に入りリスト
      • wcex-item-combo-set
新規会員登録
ログイン
新規会員登録
ログイン
カート
  • プラグイン一覧
    • - WCEX Item Combo Set
    • - WCEX Amazon Pay
    • - WCEX Wishlist お気に入りリスト
  • リリース情報
  • お役立ちコラム
  • サポート
    • - よくある質問
      • - WCEX Amazon Pay
      • - WCEX Wishlist お気に入りリスト
      • - wcex-item-combo-set
    • - リファレンス
      • - WCEX Amazon Pay
      • - WCEX Wishlist お気に入りリスト
      • - wcex-item-combo-set
  • お問い合わせ
Aivec APPs > wcex-item-combo-set > クラス > Cart
レファレンス
バージョン
1.0.6
絞り込み:

目次

  • ソース
  • 関数

フック

  • アクション
  • フィルター

ファンクション

    クラス

    Cart

    Cart component for displaying combo-set HTML in the cart

    ソース #ソース

    ファイル: src/Components/Cart/Cart.php

    class Cart
    {
        /**
         * Loads cart CSS
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return void
         */
        public static function loadCss() {
            wp_enqueue_style(
                'wcexics-cart',
                WCEXICS_PLUGIN_URL . '/src/Components/Cart/cart.css',
                [],
                WCEXICS_VERSION
            );
        }
    
        /**
         * Builds HTML for a combo-set cart item
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @param array $rows group items cart
         * @return string
         */
        public static function getComboSetCartDetailsHtml($rows) {
            $groupshtml = '<div class="wcexics combo-set-cart">';
            foreach ($rows as $row) {
                $gitemhtml = '';
                foreach ($row['groupItems'] as $item) {
                    $hookargs = [
                        'item' => $item,
                        'row' => $row,
                        'rows' => $rows,
                    ];
                    $gitemhtml .= '<li>';
                    $gitemhtml .= apply_filters(
                        'wcexics_filter_cart_details_html_item_name',
                        '<div>' . $item['name'] . '</div>',
                        $hookargs
                    );
                    $options = $item['options'];
                    if (is_array($options) && count($options) > 0) {
                        $optstr = '';
                        foreach ($options as $key => $value) {
                            if (!empty($key)) {
                                $key = urldecode($key);
                                if (is_array($value)) {
                                    $c = '';
                                    $optstr .= esc_html($key) . ' : ';
                                    foreach ($value as $v) {
                                        $optstr .= $c . nl2br(esc_html(urldecode($v)));
                                        $c = ', ';
                                    }
                                    $optstr .= "<br />\n";
                                } else {
                                    $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
                                }
                            }
                        }
                        if (!empty($optstr)) {
                            $gitemhtml .= '<div class="combo-set-cart-group-item-options">';
                            $gitemhtml .= '<div class="combo-set-cart-group-item-options__label">';
                            $gitemhtml .= '(' . __('options for items', 'usces') . ')';
                            $gitemhtml .= '</div>';
                            $gitemhtml .= '<div class="combo-set-cart-group-item-options__values">';
                            $gitemhtml .= $optstr;
                            $gitemhtml .= '</div>';
                            $gitemhtml .= '</div>';
                        }
                    }
                    $gitemhtml .= '</li>';
                }
    
                $groupshtml .= '<div class="combo-set-cart__group-label">' . $row['groupLabel'] . '</div>';
                $groupshtml .= '<div class="combo-set-cart__group-item"><ul>' . $gitemhtml . '</ul></div>';
            }
            $groupshtml .= '</div>';
    
            return $groupshtml;
        }
    
        /**
         * Builds a details string for a combo-set cart item
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @param array $rows
         * @param bool  $add_dashes
         * @return string
         */
        public static function getComboSetCartDetailsNoHtml($rows, $add_dashes = true) {
            $details = '';
            foreach ($rows as $row) {
                $rowdetails = '';
                foreach ($row['groupItems'] as $item) {
                    $ddash = $add_dashes ? '--' : '';
                    $tdash = $add_dashes ? '---' : '';
                    $rowdetails .= "{$ddash}" . wp_strip_all_tags($item['name']);
                    $options = $item['options'];
                    if (is_array($options) && count($options) > 0) {
                        $optstr = '';
                        foreach ($options as $key => $value) {
                            if (!empty($key)) {
                                $key = urldecode($key);
                                if (is_array($value)) {
                                    $c = '';
                                    $optstr .= "\r\n\t\t{$tdash} " . esc_html($key) . ' : ';
                                    foreach ($value as $v) {
                                        $optstr .= $c . nl2br(esc_html(urldecode($v)));
                                        $c = ', ';
                                    }
                                } else {
                                    $optstr .= "\r\n\t\t{$tdash} " . esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value)));
                                }
                            }
                        }
                        if (!empty($optstr)) {
                            $rowdetails .= "\r\n\t\t{$tdash} (" . __('options for items', 'usces') . ')';
                            $rowdetails .= $optstr;
                        }
                    }
                }
    
                $details .= "\r\n" . $row['groupLabel'];
                $details .= ' : ';
                $details .= $rowdetails;
            }
    
            return $details;
        }
    
        /**
         * Builds a details string for a combo-set cart item (space separated for CSV)
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @param array $rows
         * @return string
         */
        public static function getComboSetCartDetailsSpaceSeparated($rows) {
            $ext = 'csv';
            $sp = ':';
            $nb = ' ';
            $groups = [];
            foreach ($rows as $row) {
                $itemlist = [];
                foreach ($row['groupItems'] as $item) {
                    $itemlist[] = wp_strip_all_tags($item['name']);
    
                    if (!empty($item['options']) && is_array($item['options'])) {
                        $optstrs = [];
                        foreach ($item['options'] as $key => $value) {
                            $meta_value = maybe_unserialize($value);
                            if (is_array($meta_value)) {
                                $meta_vals = '';
                                foreach ($meta_value as $array_val) {
                                    $meta_vals .= $nb . urldecode($array_val);
                                }
                                $optstrs[] = usces_entity_decode(urldecode($key) . $sp . $meta_vals, $ext);
                            } else {
                                $optstrs[] = usces_entity_decode(urldecode($key) . $sp . urldecode($value), $ext);
                            }
                        }
                        $itemlist[] = join($nb, $optstrs);
                    }
                }
    
                $groups[] = usces_entity_decode(
                    urldecode($row['groupLabel']) . $sp . urldecode(join($nb, $itemlist)),
                    $ext
                );
            }
    
            $details = join($nb, $groups);
            return $details;
        }
    }
    

    ソースを伸ばす ソースを縮める


    関数 #関数

    Top ↑

    • getComboSetCartDetailsHtml — Builds HTML for a combo-set cart item
    • getComboSetCartDetailsNoHtml — Builds a details string for a combo-set cart item
    • getComboSetCartDetailsSpaceSeparated — Builds a details string for a combo-set cart item (space separated for CSV)
    • loadCss — Loads cart CSS

    • 新規会員登録
    • ログイン
      • プラグイン一覧
      • 会社概要
      • リリース情報
      • よくある質問
      • お役立ちコラム
      • お問い合わせ
      • 個人情報保護方針
      • 特定商取引法に基づく表記
      • 情報セキュリティ基本方針
      • 利用規約

    アイベック合同会社は「Welcart」「Amazon Pay」の公式パートナーです。

    ※Amazon、Amazon.co.jp、Amazon Payおよびそれらのロゴは、Amazon.com,inc.またはその関連会社の商標です。

    © 2025 Aivec llc All Rights Reserved.