• プラグイン一覧
    - 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 > クラス > FileDownloads
レファレンス
バージョン
1.0.6
絞り込み:

目次

  • ソース
  • 関数

フック

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

ファンクション

    クラス

    FileDownloads

    Methods for handling DLSeller file download operations

    ソース #ソース

    ファイル: src/API/FileDownloads.php

    class FileDownloads
    {
        /**
         * Registers hooks
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return void
         */
        public static function init() {
            add_filter('usces_filter_is_purchased_item', [get_class(), 'filterIsPurchasedForGroupItems'], 10, 5);
            add_filter('usces_filter_cart_item_name', [get_class(), 'makeGroupDataItemsDownloadable'], 10, 2);
        }
    
        /**
         * Sets extra combo-set specific parameters to dlseller download link
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @param string $empty
         * @param int    $post_id
         * @return string
         */
        public function filterGroupItemDownloadUrlParams($empty, $post_id) {
            return "&pid={$post_id}";
        }
    
        /**
         * Makes DLSeller use the combo-set order ID when checking if a group item is purchased
         *
         * This is required to make group 'data' items downloadable from the checkout completion page
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @param bool   $res
         * @param int    $mid
         * @param int    $post_id
         * @param string $sku
         * @param int    $order_id
         * @return bool
         */
        public static function filterIsPurchasedForGroupItems($res, $mid, $post_id, $sku, $order_id) {
            global $wpdb;
    
            if (isset($_SESSION['comboSetIsPurchased'])) {
                return $_SESSION['comboSetIsPurchased'];
            }
    
            if (empty($order_id)) {
                return $res;
            }
    
            $order_table_name = usces_get_tablename('usces_order');
            $query = $wpdb->prepare("SELECT order_status FROM $order_table_name WHERE ID = %d", $order_id);
            $status = $wpdb->get_var($query);
            $cart = usces_get_ordercartdata($order_id);
            $post_id = (int)$post_id;
            $founditem = false;
            foreach ($cart as $cart_row) {
                $sels = unserialize($cart_row['cart_serial']);
                if (!empty($sels['comboSetId']) && isset($sels['comboSetItems'])) {
                    $cscart = wcexics_api_get_combo_set_ordercartdata($order_id);
                    foreach ($cscart as $cscart_row) {
                        $sku_code = urldecode($cscart_row['sku']);
                        if (!empty($sku)) {
                            if ((int)$cscart_row['post_id'] === $post_id && $sku_code === $sku) {
                                $founditem = true;
                                break 2;
                            }
                        } else {
                            if ((int)$cscart_row['post_id'] === $post_id) {
                                $founditem = true;
                                break 2;
                            }
                        }
                    }
                }
            }
    
            if ($founditem) {
                if (false === strpos($status, 'noreceipt') && false === strpos($status, 'pending')) {
                    $res = true;
                } elseif (false !== strpos($status, 'noreceipt') || false !== strpos($status, 'pending')) {
                    $res = 'noreceipt';
                }
            }
    
            return $res;
        }
    
        /**
         * Adds download button for 'data' group items on checkout completion page
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @param string $html
         * @param array  $args
         * @return string
         */
        public static function makeGroupDataItemsDownloadable($html, $args) {
            global $usces;
    
            if (!WelcartUtils::isOrderCompletionPage()) {
                return $html;
            }
    
            $sels = unserialize($args['cart_row']['serial']);
            // combo-set ID not set, continue
            if (empty($sels['comboSetId'])) {
                return $html;
            }
            // combo-set group items not set, continue
            if (!isset($sels['comboSetItems'])) {
                return $html;
            }
    
            $realcart = $_SESSION['usces_cart'];
            $_SESSION['usces_cart'] = $sels['comboSetItems'];
            $gitemscart = $usces->cart->get_cart();
            $_SESSION['usces_cart'] = $realcart;
    
            $datacart = [];
            foreach ($gitemscart as $i => $data) {
                $usces_item = $usces->get_item($data['post_id']);
                if ($usces_item['item_division'] === 'data') {
                    $datacart[] = $data;
                }
            }
    
            if (!empty($datacart)) {
                $member = $usces->get_member();
                $_SESSION['comboSetIsPurchased'] = $usces->is_purchased_item($member['ID'], $args['cart_row']['post_id']);
                $fd = new FileDownloads();
                add_filter('dlseller_filter_download_para', [$fd, 'filterGroupItemDownloadUrlParams'], 10, 2);
                $html .= '<div class="avc-v3 flex column-nowrap mt-1rem">';
                $html .= dlseller_completion_info($datacart, 'return');
                $html .= '</div>';
                remove_filter('dlseller_filter_download_para', [$fd, 'filterGroupItemDownloadUrlParams'], 10);
                unset($_SESSION['comboSetIsPurchased']);
            }
    
            return $html;
        }
    }
    

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


    関数 #関数

    Top ↑

    • filterGroupItemDownloadUrlParams — Sets extra combo-set specific parameters to dlseller download link
    • filterIsPurchasedForGroupItems — Makes DLSeller use the combo-set order ID when checking if a group item is purchased
    • init — Registers hooks
    • makeGroupDataItemsDownloadable — Adds download button for 'data' group items on checkout completion page

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

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

    ※Amazon、Amazon.co.jp、Amazon Payおよびそれらのロゴは、Amazon.com,inc.またはその関連会社の商標です。
    ※LINE Pay、およびLINE Pay 提携サービスのロゴは、法律上保護を受ける商標です。

    © 2025 Aivec llc All Rights Reserved.