按 SKU 对购物车 WooCommerce 中产品列表底部的产品进行排序

2024-06-25

在 WooCommerce 中,我使用一个代码来显示牛排重量选择表单,保存选择数据并在编辑订单和电子邮件通知时在购物车、结账页面上显示此数据。

我的代码还与在将任何产品添加到购物车时自动添加包装的代码相结合。添加包装发生在 SKU 上。

/**
* Display Custom Checkbox Field
*/
function steak_custom_field_add() {
    global $post;

    // Checkbox
    woocommerce_wp_checkbox(
        array(
            'id' => '_steak_checkbox',
            'label' => __('Steak Weight', 'woocommerce' ),
            'description' => __( 'If necessary, enable steak weight selection', 'woocommerce' )
        )
    );
}
add_action('woocommerce_product_options_general_product_data', 'steak_custom_field_add', 10, 0 );

/**
 * Save Custom Checkbox Field
 */
function steak_custom_field_save( $post_id ) {
    $product = wc_get_product( $post_id );

    // Custom Product Checkbox Field
    $steak_checkbox = isset( $_POST['_steak_checkbox'] ) ? 'yes' : 'no';

    // Update product meta
    $product->update_meta_data( '_steak_checkbox', $steak_checkbox );

    // Save
    $product->save();
}
add_action('woocommerce_process_product_meta', 'steak_custom_field_save', 10, 1 );

/**
 * Display Custom Select Box
 */
function display_steak_custom_field() {
    global $post;

    // Get product
    $product = wc_get_product( $post->ID );

    // If is single product page and have the "steak_checkbox" enabled we display the field
    if ( $product->get_meta( '_steak_checkbox' ) === 'yes' ) {

        echo '<div class="roast_select">';

        $select = woocommerce_form_field( 'steak_custom_options', array(
            'type'          => 'select',
            'class'         => array('my-steak-select-box form-row-wide'),
            'label'         => __('Steak Weight'),
            'required'      => false,
            'return'       => false,
            'options'   => array(
                ''      => 'Please select...',
                '300g'  => '300g',
                '400g'  => '400g',
                '500g'  => '500g',
                '600g'  => '600g',
                '700g'  => '700g',
                '800g'  => '800g',
                '900g'  => '900g',
                '1000g'  => '1000g'
            )
        ), '' );
        echo $select;
        echo '</div>';
        ?>
        <script type="text/javascript">
            jQuery(document).ready(function ($) {
                console.log('it works 1');

                var price = <?php echo $product->get_price(); ?>, currency = '<?php echo get_woocommerce_currency_symbol(); ?>';

                $( '[name=steak_custom_options]' ).change(function(){
                    if (!(this.value < 1)) {
                        var dropdown_val = this.value;
                        var remove_g = dropdown_val.replace( 'g', '' );
                        var remove_double_zero = remove_g.replace( '00', '' );

                        var product_total = parseFloat( price * remove_double_zero );

                        // For single product page
                        $( '.entry-summary .woocommerce-Price-amount' ).html( currency + product_total.toFixed(2));

                        // quick-view-custom-price
                        $( '.quick-view-custom-price .woocommerce-Price-amount' ).html( currency + product_total.toFixed(2));
                    }
                });
            });
        </script>
        <?php
    }
}
add_action( 'woocommerce_before_add_to_cart_button', 'display_steak_custom_field', 10, 0 );

/**
 * Add as custom cart item data
 */
function add_custom_steak_cart_item_data( $cart_item_data, $product_id, $variation_id, $quantity ) {
    // Get product
    $product = wc_get_product( $product_id );

    // Get product sku
    $product_sku = $product->get_sku();

    if ( !empty( $_POST['steak_custom_options'] ) && $product_sku != 'lunchbox' ) {
        $cart_item_data['steak_option'] = $_POST['steak_custom_options'];
    }

    return $cart_item_data;
}
add_filter( 'woocommerce_add_cart_item_data', 'add_custom_steak_cart_item_data', 10, 4 );

/**
 * Add custom fields values under cart item name in cart
 */
function steak_custom_field_add_cart( $item_name, $cart_item, $cart_item_key ) {
    if( is_cart() ) {
        if( isset( $cart_item['steak_option'] ) ) {
            $item_name .= '<div class="my-steak-class"><strong>' . __("Steak Weight", "woocommerce") . ':</strong> ' . $cart_item['steak_option'] . '</div>';
        }
    }

    return $item_name;
}
add_filter( 'woocommerce_cart_item_name', 'steak_custom_field_add_cart', 10, 3 );

/**
 * Calculate the number of lunchboxes and package, based on the number of products in cart.
 */
function add_delivery_charge_to_cart( $cart ) {
    if ( is_admin() && ! defined( 'DOING_AJAX' ) )
        return;

    if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 )
        return;

    /********** SETTINGS **********/

    $lunchbox_sku  = 'lunchbox'; // "LunchBox SKU" to be added to cart
    $pakket_sku = 'pakket'; // "Pakket SKU" to be added to cart

    $exclude_categories = array( 'drink', 'bread' ); // Exclude these categories

    /********** END SETTINGS **********/

    // Get product ID by SKU
    $lunchbox_id = wc_get_product_id_by_sku( $lunchbox_sku );
    $pakket_id = wc_get_product_id_by_sku( $pakket_sku );

    $category_qty_total = 0; // Total of category quantity items, Don't edit!!

    /********** LOOP THROUGH CART ITEMS **********/

    foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {
        // Get product id
        $product_id = $cart_item['data']->get_id();

        // Get product quantity
        $product_qty = $cart_item['quantity'];

        // Check if "LunchBox" product is already in cart
        if( $product_id == $lunchbox_id ) {
            $lunchbox_key = $cart_item_key;
            $lunchbox_qty = $product_qty;
        }

        // Check if "Pakket" product is already in cart
        if( $product_id == $pakket_id ) {
            $pakket_key = $cart_item_key;
            $pakket_qty = $product_qty;
        }

        // Check if product belongs to a certain category
        if( has_term( $exclude_categories, 'product_cat', $product_id ) ) {
            $category_qty_total += $product_qty;
        }

        // Check if product, contains steak weight
        if( isset( $cart_item['steak_option'] ) ) {
            // Remove the last 2 zeros (100g becomes 1, 300g becomes 3, 1000g becomes 10, etc...)
            // Remove 'g' from grams
            // convert string to integer
            $chosen_weight = (int) str_replace( '00', '', str_replace('g', '', $cart_item['steak_option']) );

            // Get current price
            $current_price = $cart_item['data']->get_price();

            // Set new price, price is already known per 100g
            $cart_item['data']->set_price( $current_price * $chosen_weight );
        }
    }

    /********** CALCULATE THE TOTALS, SO "LUNCHBOX", "PAKKET" & CATEGORIES ARE NOT USED IN THE TOTALS **********/

    // Get total items in cart, counts number of products & quantity per product
    $total_items_in_cart = $cart->get_cart_contents_count();

    // Total items in cart - category quantity total
    $total_items_in_cart -= $category_qty_total;

    // Lunchbox total = total_items_in_cart & pakket total = total_items_in_cart
    $lunchbox_total = $total_items_in_cart;
    $pakket_total = $total_items_in_cart;

    // Isset lunchbox qty -> lunchbox total - lunchbox qty & pakket total - lunchbox qty
    if ( isset($lunchbox_qty) ) {
        $lunchbox_total -= $lunchbox_qty;
        $pakket_total -= $lunchbox_qty;
    }

    // Isset pakket qty -> lunchbox total - pakket qty & pakket total - pakket qty
    if ( isset($pakket_qty) ) {
        $lunchbox_total -= $pakket_qty;
        $pakket_total = $pakket_total - $pakket_qty;
    }

    /********** APPLY NEW TOTALS TO LUNCHBOX & PAKKET **********/

    // If product "LunchBox" is in cart, we check the quantity to update it if needed
    if ( isset($lunchbox_key) && $lunchbox_qty != $total_items_in_cart ) {
        // Set quantity, lunchbox
        $cart->set_quantity( $lunchbox_key, $lunchbox_total );

    } elseif ( !isset($lunchbox_key) && $total_items_in_cart > 0 ) {
        // Product "LunchBox" is not in cart, we add it
        $cart->add_to_cart( $lunchbox_id, $total_items_in_cart );
    }

    // Total items in cart greater than or equal to 3
    if ( $total_items_in_cart >= 3 ) {
        // Pakket total = pakket_total / 3 = floor(result)
        // Floor = round fractions down, rounding result down
        $pakket_total = floor( $pakket_total / 3 );

        // If product "Pakket" is in cart
        if ( isset($pakket_key) ) {
            // Set quantity, pakket
            $cart->set_quantity( $pakket_key, $pakket_total );

        } elseif ( !isset($pakket_key) ) {
            // Product "Pakket" is not in cart, we add it
            $cart->add_to_cart( $pakket_id, $pakket_total );
        }
    }
}
add_action( 'woocommerce_before_calculate_totals', 'add_delivery_charge_to_cart', 10, 1 );

/**
 * Display custom fields values under item name in checkout
 */
function steak_custom_checkout_cart_item_name( $item_qty, $cart_item, $cart_item_key ) {
    if( isset($cart_item['steak_option']) ) {
        $item_qty .= '<div class="my-steak-class"><strong>' . __("Steak Weight", "woocommerce") . ':</strong> ' . $cart_item['steak_option'] . 'g</div>';
    }
    return $item_qty;
}
add_filter( 'woocommerce_checkout_cart_item_quantity', 'steak_custom_checkout_cart_item_name', 10, 3 );

/**
 * Display custom fields values under item name in checkout
 */
function save_order_item_steak_field( $item, $cart_item_key, $values, $order ) {
    if( isset($values['steak_option']) ) {
        $key = __('Steak Weight', 'woocommerce');
        $value = $values['steak_option'];
        $item->update_meta_data( $key, $value ,$item->get_id());
    }
}
add_action('woocommerce_checkout_create_order_line_item', 'save_order_item_steak_field', 10, 4 );

有一次,用户@7uc1f3r 帮助进行了自定义排序,以便包装始终位于购物车中产品列表的最底部。

function sort_cart_specific_product_at_bottom( $cart ) {    
    // Product id's to to display at tbe bottom of the product list
    $product_ids_last = array( 30, 815 );

    // Set empty arrays
    $products_in_cart = array();
    $products_last = array();
    $cart_contents = array();

    // Loop through cart items
    foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {
        // Get product id
        $product_id = $cart_item['data']->get_id();

        // In_array — checks if a value exists in an array
        if ( in_array( $product_id, $product_ids_last) ) {
            // Add to products last array
            $products_last[ $cart_item_key ] = $product_id;
        } else {
            // Add to products in cart array
            $products_in_cart[ $cart_item_key ] = $product_id;
        }
    }

    // Merges the elements together so that the values of one are appended to the end of the previous one.
    $products_in_cart = array_merge( $products_in_cart, $products_last );

    // Assign sorted items to cart
    foreach ( $products_in_cart as $cart_item_key => $product_id ) {
        $cart_contents[ $cart_item_key ] = $cart->cart_contents[ $cart_item_key ];
    }

    // Cart contents
    $cart->cart_contents = $cart_contents;

}
add_action( 'woocommerce_cart_loaded_from_session', 'sort_cart_specific_product_at_bottom', 10, 1 );

但不幸的是,排序代码有点过时了,因为现在包裹是按 SKU 添加的,而不是按 ID 添加的。因此,排序不起作用。

如果按 SKU 添加包装,如何更改排序代码?

我将很高兴得到您的帮助!


以下代码将根据产品 sku 对产品进行最后排序

相关主题:

  • 按产品 ID 对购物车 WooCommerce 中产品列表底部的产品进行排序 https://stackoverflow.com/questions/60799948/sort-packaging-and-products-in-cart-woocommerce
function sort_cart_specific_product_at_bottom( $cart ) { 
    // Product sku to to display at tbe bottom of the product list
    $product_sku_last = array( 'lunchbox', 'pakket' );

    // Set empty arrays
    $products_in_cart = array();
    $products_last = array();
    $cart_contents = array();

    // Loop through cart items
    foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {
        // Get product sku
        $product_sku = $cart_item['data']->get_sku();

        // Get product id
        $product_id = $cart_item['data']->get_id();

        // In_array — checks if a value exists in an array
        if ( in_array( $product_sku, $product_sku_last ) ) {
            // Add to products last array
            $products_last[ $cart_item_key ] = $product_id;
        } else {
            // Add to products in cart array
            $products_in_cart[ $cart_item_key ] = $product_id;
        }
    }

    // Merges the elements together so that the values of one are appended to the end of the previous one.
    $products_in_cart = array_merge( $products_in_cart, $products_last );

    // Assign sorted items to cart
    foreach ( $products_in_cart as $cart_item_key => $product_id ) {
        $cart_contents[ $cart_item_key ] = $cart->cart_contents[ $cart_item_key ];
    }

    // Cart contents
    $cart->cart_contents = $cart_contents;

}
add_action( 'woocommerce_cart_loaded_from_session', 'sort_cart_specific_product_at_bottom', 10, 1 );

并且此代码可确保基于 sku 的商品无法从购物车中移除

function prevent_cart_item_remove_link( $link, $cart_item_key ) {
    // Product sku that should not be removable
    $product_sku_last = array( 'lunchbox', 'pakket' );

    if( WC()->cart->find_product_in_cart( $cart_item_key ) ) {
        $cart_item = WC()->cart->cart_contents[ $cart_item_key ];

        // Get product sku
        $product_sku = $cart_item['data']->get_sku();

        // In_array — checks if a value exists in an array
        if ( in_array( $product_sku, $product_sku_last ) ) {
            $link = '';
        }
    }

    return $link;
}
add_filter( 'woocommerce_cart_item_remove_link', 'prevent_cart_item_remove_link', 10, 2 );
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

按 SKU 对购物车 WooCommerce 中产品列表底部的产品进行排序 的相关文章

  • bbPress 有 API 吗?

    我正在寻找 bbPress 的 API 我在这里搜索过 但我看到的帖子很旧 那么有没有 bbPress 的 api 如果是 请问如何访问 如果没有 我是否可以通过 Android 应用程序实现用户注册和登录 另外 检查这个存储库 https
  • 基本的php问题。添加 javascript 到 .php 页面

    嗨 我不是 php 开发人员 我以前从未接触过它 但我被要求向网站添加谷歌购物车跟踪代码 当有人完成订单时 将被发送到 finishorder php 当我转到 finishorder php 文件时 它看起来像这样 include dir
  • IOS 向特定用户推送通知?

    是否可以向特定设备发送 iOS 推送通知 我构建了一个论坛类型的应用程序 用户可以创建问题 其他人可以回答它 我需要向提出问题的特定用户发送 iOS 推送通知 通知他们问题已得到解答 这可以通过 PHP 或其他方法来完成吗 是的 您绝对可以
  • 销毁Session但保留flashdata

    我在用坦克验证 http www konyukhov com soft tank auth 用于我的 CI 1 7 3 应用程序中的用户管理 一切工作正常 但我正在尝试设置flash message当用户注销时显示 问题是 this gt
  • Laravel 7 会话在不同域中的 IFRAME 上中断

    我尝试在这里开发一个简单的 Laravel 应用程序 https shopifyapp sjranjan com https shopifyapp sjranjan com 此登录工作正常 现在我将上面的 URL 推送到此页面的 ifram
  • php-fpm 需要在监狱环境中放置哪些系统文件才能在 ubuntu 上正常运行?

    我在 ubuntu 12 04 上使用 php5 fpm 并且为 nginx 托管的每个域都有单独的池和 chroot 位置 不过 我知道有些系统文件需要直接放在jail中 但是我需要哪些呢 我知道 dns 解析当前不起作用 并且我读过一些
  • 为什么在打开的文件上取消链接成功?

    为什么打开的文件被删除了 在 Windows Xamp 上 我收到消息 仍在工作 但在其他 PHP 服务器上 文件被删除 即使它已打开 并且我收到消息 文件已删除 我也可以从 FTP 删除文件 即使第一个脚本仍在工作 UNIX 系统通常允许
  • Google OAuth 2 PHP 调用用户信息

    我正在尝试使用 Google 的 OAuth2 API 在他们的通用文档中 他们提到了一个名为 UserInfo 的调用 http code google com apis accounts docs OAuth2Login html us
  • Monolog - 仅记录特定级别的错误

    我在普通 PHP 应用程序中使用 Monolog 我只想记录特定级别的错误 INFO 和不高于 因为我还有其他处理程序 这是我的代码
  • PHP 中的延迟加载类方法

    我有一堂课 里面有一些相当大的方法 在它的基本和最常见的状态下 大多数功能并不是必需的 所以我想知道是否有一种方法可以延迟加载类的一部分 这些方法需要能够访问私有 受保护的成员 因此如果这些方法是类的本机方法 那将是理想的选择 但是在寻找其
  • 更改二维数组每一行中的键而不丢失值

    我有一个行数组 其中一个 视觉 数据列有两个相似但不同的键 我想替换其中一个键 以便该列在所有行中具有相同的键 我的输入数组 Ttitle gt lilly Price gt 1 75 Number gt 3 Title gt rose P
  • 将我的 JSON 字符串格式化为 PHP 中的
      有序列表

    我正在为一个宠物项目开发一个简单的 CMS 我目前有一个 JSON 字符串 其中包含菜单结构的页面 ID 和父页面 ID 的列表 我现在想将此字符串转换为嵌套或分层列表 有序列表 我尝试过循环查找 但似乎最终得到了过于复杂的子类范围 我正在
  • 在 foreach 循环中使用 next

    我正在使用 foreach 循环数组 在特定情况下 我需要在迭代到达下一个元素 如预测 之前知道下一个元素的值 为此 我计划使用该功能next http www php net manual en function next php 在文档
  • 在 PHP 中使用重命名函数时出错

    尽管文件仍然被移动到正确的目录中 但我不断收到此错误 有人知道我为什么会收到此错误吗 Warning rename Images uploaded 1162504 56863010 jpg Images uploaded Portraits
  • 从套接字读取数据,发送响应并关闭

    我正在开发一个 c 和 php 项目 其中 PHP 脚本打开一个到 c 程序的套接字 c 程序将读取数据 然后发回响应 在 PHP 脚本中我有以下内容 echo Opening Client fp fsockopen 127 0 0 1 1
  • 一系列 unicode 点的正则表达式 PHP

    我正在尝试从字符串中删除所有字符 除了 字母数字字符 美元符号 下划线 代码点之间的 Unicode 字符U 0080 and U FFFF 通过这样做 我得到了前三个条件 preg replace a zA Z d foo 我如何去满足第
  • 为什么在这个数组中 NULL 递减而不是负数?

    我已经尝试过这段代码 a array fill 0 4 NULL a 0 a 1 a 2 a 3 var dump a Result array 4 0 gt int 1 1 gt int 1 2 gt NULL 3 gt NULL 为什么
  • SQLite适合并发读吗?

    在没有锁定的情况下 SQLite 数据库的性能是否能达到每秒 50 次读取左右 我正在尝试确定它是否可以在不会经常 写入 的 PHP 网站上使用 它主要是从一小部分表中读取相同的数据 没问题 并发读 写实际上会被 SQLite 序列化 所以
  • Docker Compose WordPress 卷显示为空

    我正在尝试使用 docker compose 设置一个简单的 WordPress 构建 然而 当我构建它时 卷似乎是空的 这是我的 docker compose yml version 3 services wordpress image
  • simplexml,返回具有相同标签的多个项目

    我将以下 XML 文件加载到 php simplexml 中

随机推荐

  • 管道上的持久 execvp?

    我正在为我的操作系统课程 Posix C 做作业 构建一个迷你 shell 但我不知道如何解决以下问题 例如 我的迷你 shell 必须接受两个命令ls grep a 为此 我创建了一个尺寸为 2 的管道和一个子管道 子进程关闭所有它必须关
  • 使用 RhinoMock 或 Moq 测试方法的内部结构

    我对这个嘲笑的事情很陌生 我有几个问题 如我错了请纠正我 模拟不会初始化真正的方法 即模拟不会实际调用类的构造函数 相反 它会执行类似查看类的签名并创建具有该签名但没有任何方法功能的对象的操作 如果您只需要该类型的对象但不想测试它的内部结构
  • 视频视图可以播放内部存储中存储的视频吗?

    我试图为我的用户提供使用外部或内部存储的能力 我正在显示图像和视频 具有科学性质 当将媒体存储在 SD 卡上时 一切都很好 但是当我在内部存储媒体时 只会显示图像 无论我尝试什么 在尝试加载和显示存储在 applicationcontext
  • 按任何属性对列表进行排序的更好方法

    我的方法接收所有 DataTables 参数 以按单击的列对表进行排序 我从每个页面列表的控制器调用此方法 我正在寻找一种更好的方法来执行此操作 例如适用于所有类型的通用方法 string int decimal double bool n
  • Memoize 基于单个输入选择器而不是所有输入选择器重新选择选择器输出

    我有一个重新选择选择器 它将选定的 id 数组映射到规范化存储中的对象中 const activeObjectsSelector createSelector state gt state activeIds state gt state
  • 如何使用 Windows API 从麦克风录制 wav 声音?

    如何使用 Windows API 从麦克风录制 wav 声音 您可以使用一系列的waveInXXX Windows API 来录制音频 即waveInOpen waveInPrepareHeader waveInAddBuffer wave
  • file_get_contents 的替代方案?

    xml file file get contents SITE PATH cms data php 问题是服务器禁用了 URL 文件访问 我无法启用它 它是一个托管的东西 所以问题是这样的 这data php文件生成 xml 代码 如果不执
  • Windows Azure 虚拟机在扩展时访问网络速度很慢

    我正在我的小型 azure VM 上运行一些启动脚本 cmd bat 其中包括从已安装的 VHD 进行文件传输操作 通常会在大约 3 分钟内完成 复制文件并使用命令行提取 500Mb zip 文件 7z 当我扩展到约 150 个实例时 相同
  • C# 循环下动态添加控件

    我正在开发一个 Windows 应用程序 我想在循环内动态创建一些控件 我正在尝试的代码是 private Label newLabel new Label private int txtBoxStartPosition 100 priva
  • 结构体中的运算符重载

    假设我定义这个结构 struct Point double x y 我怎样才能超载 运算符使得 声明 Point a b c double k 表达方式 c a b yields c x a x b x c y a y b y 和表达 c
  • 使用 knit2wp 更新帖子

    我已经能够使用 knit2wp 成功发布到 WordPress 甚至可以使用图像 即使拥有这样的天赋 我也并非绝对正确 事实上 即使是上面的内容也需要一些工作 我希望稍后能够更新帖子 显然 RWordPress 软件包允许删除帖子 但如果无
  • cron 作业不适用于 xwindow

    我在 crontab 中有以下行 1 xeyes 它不显示任何 xwindow 但相反 1 touch somefile txt 工作正常 尝试在谷歌上搜索但没有得到任何具体答案 如果您运行的命令使用 X 服务器 您必须告诉 cron 在哪
  • “|”是什么意思Django 模板中的符号意味着什么?

    我经常看到这样的事情 something property escape something is an object property is it s string property escape i don t know What do
  • Symfony2 的 mongoDB 返回一个可记录游标而不是我的实体

    我目前使用 DoctrineMongoDbBundle 向我的 mongodb 数据库发出请求 这是我的控制器中的调用 dm this gt get doctrine odm mongodb document manager entitie
  • 为什么 Google 集合中没有 SortedMultiset?

    谷歌收藏 http code google com p google collections 包含Multiset接口和TreeMultiset类 但是我惊讶的发现没有对应的SortedMultiset界面 类似的东西对于离散概率分布建模非
  • bluimp 的 jQuery 文件上传,如何替换而不是重命名

    首先 可以在这里找到 jQuery 插件 https github com blueimp jQuery File Upload https github com blueimp jQuery File Upload 我正在使用 PHP 版
  • 会话未设置,还是session_destroy? [复制]

    这个问题在这里已经有答案了 可能的重复 PHP 中的 session unset 和 session destroy 有什么区别 https stackoverflow com questions 4303311 what is the d
  • 错误 1066:无法打开别名 - Pig 的迭代器

    刚开始养猪 尝试从文件加载数据并转储它 加载似乎正确 没有抛出任何错误 下面是查询 NYSE 使用 LOAD root Desktop Works NYSE 2000 2001 tsv PigStorage AS 交换 chararray
  • 如何让EF全局记录sql查询?

    我该如何 告诉 EF全局记录查询 我正在读这篇博文 EF 日志记录 http blog oneunicorn com 2013 05 08 ef6 sql logging part 1 simple logging 它一般告诉我们如何记录s
  • 按 SKU 对购物车 WooCommerce 中产品列表底部的产品进行排序

    在 WooCommerce 中 我使用一个代码来显示牛排重量选择表单 保存选择数据并在编辑订单和电子邮件通知时在购物车 结账页面上显示此数据 我的代码还与在将任何产品添加到购物车时自动添加包装的代码相结合 添加包装发生在 SKU 上 Dis