change look of CheckBox

本文提供了一篇关于如何自定义复选框外观的详细教程,包括使用HTML、CSS和JavaScript实现个性化设计。

http://www.anddev.org/novice-tutorials-f8/tutorial-change-look-of-checkbox-t4553.html#p17044

 

<php> $affected_tooling = is_array($list['affected_tooling']) ? $list['affected_tooling'] : explode(',', $list['affected_tooling']); </php> <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>Internal Engineering Change Notice (ECN) Requests</title> <style> .container { margin: auto; border: 1px solid #ccc; padding: 20px 20px 0px 20px; font-family: Arial, sans-serif; } h2 { text-align: center; } .header { display: flex; /* justify-content: space-between; */ align-items: center; margin-bottom: 20px; } .header-info { font-size: 14px; } .form-group { display: flex; margin-bottom: 15px; } /* 容器样式 */ .form-row { justify-content: space-between; /* 让子元素分布在两侧 */ display: flex; gap: 5px; /* 列之间的间距 */ margin-bottom: 15px; } .form-row .form-group { display: flex; } label { display: inline-block; width: 300px; font-weight: normal; } input[type="text"], input[type="date"], input[type="time"] { width: 200px; padding: 5px; } .checkbox-group { display: flex; align-items: center; } /* 控制复选框组内部间距 */ .checkbox-group label { margin-right: 5px; /* 每个复选框之间的间距 */ width: 60px; } .checkbox-group label { font-weight: normal; margin-right: 5px; } .section { margin-top: 20px; padding-top: 10px; border-top: 1px solid #ccc; } .footer { margin-top: 30px; display: flex; justify-content: space-between; font-size: 12px; color: #555; } .col { display: flex; align-items: center; white-space: nowrap; } .col input[type="text"] { padding: 2px; box-sizing: border-box; } .col label { white-space: nowrap; margin-right: 1px; } .approval-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; font-weight: normal; } .approval-table th, .approval-table td { padding: 10px; border: 1px solid #ccc; vertical-align: top; } .approval-table th { background-color: #f5f5f5; text-align: left; } .checkbox-container { display: flex; flex-wrap: wrap; gap: 15px; } .checkbox-row { display: flex; align-items: center; gap: 10px; flex: 0 0 48%; /* 控制每行两个选项 */ } .checkbox-row.full-width { flex: 0 0 100%; /* Others 行占满整行 */ } .checkbox-row input[type="text"] { flex: 1; padding: 5px; width: 200px; } .checkbox-row label { font-weight: normal; white-space: nowrap; } .footer-page-break { /*分页,兼容旧浏览器*/ page-break-after: always; } .center-text { display: flex; justify-content: center; /* 水平居中 */ align-items: center; /* 垂直居中 */ } label span { font-weight: normal; text-decoration: underline; } </style> </head> <body> <div> <div class="center-text"> <div style="width:980px;text-align:left;"> <div class="container" layoutH="56"> <div class="header" style="display: flex; justify-content: space-between; align-items: center;"> <img src="__PUBLIC__/Images/logo.gif" alt="Logo" style="height: 50px;"> <strong>TCN No:{$list.tcn_no} </strong> </div> <div class="header" style="justify-content: center;"> <h2>Tooling Change Notice (TCN)</h2> </div> <div class="form-group"> <!-- 第一列:Requested by --> <div class="col"> <label>Requested by #:<span>{$list.requested_by}</span></label> </div> <!-- 第二列:单选 --> <div class="col checkbox-group" style="justify-content: flex-start; padding-left: 5px;"> <label> <input type="radio" name="requested_department" id="ME" value="ME" <if condition="$list.requested_department eq 'ME'">checked</if>/> <label for="ME" style="margin-left: 1px;">ME</label> </label> <label> <input type="radio" name="requested_department" id="PE" value="PE" <if condition="$list.requested_department eq 'PE'">checked</if>/> <label for="PE" style="margin-left: 1px;">PE</label> </label> <label> <input type="radio" name="requested_department" id="QA" value="QA" <if condition="$list.requested_department eq 'QA'">checked</if> /> <label for="QA" style="margin-left: 1px;">QA</label> </label> <label> <input type="radio" name="requested_department" id="PMC" value="PMC" <if condition="$list.requested_department eq 'PMC'">checked</if> /> <label for="PMC" style="margin-left: 1px;">PMC</label> </label> </div> </div> <!-- 下一行:Date --> <div style="margin-top: 15px;"> <label>Issue Date (MM/DD/YYYY):<span>{$list.issue_date}</span></label> </div> <div class="section"> <h4>Part A: General Project and Change Information (Fill by Requestor):</h4> <div class="form-row"> <label>PNG Part No.:<span>{$list.png_part_no}</span></label> <label style="margin-left: 10px;">Customer:<span>{$list.customer}</span></label> <div class="form-group"> <label>W/O:<span>{$list.wo}</span></label> </div> </div> </div> <div class="section"> <h4>Part B: Change Description (Fill by Requestor):</h4> <div class="form-group"> <label>Purpose:</label> <div class="col"> <label> <input type="radio" name="purpose_option" id="Tooling Update" value="Tooling Update" <if condition="$list.purpose_option eq 'Tooling Update'">checked</if> /> <label for="Tooling Update" style="margin-left: 1px;width: 100px;">Tooling Update</label> </label> <label> <input type="radio" name="purpose_option" id="Test tooling" value="Test tooling" <if condition="$list.purpose_option eq 'Test tooling'">checked</if>/> <label for="Test tooling" style="margin-left: 1px;">Test tooling</label> </label> <label> <input type="radio" name="purpose_option" id="Rework tooling" value="Rework tooling" <if condition="$list.purpose_option eq 'Rework tooling'">checked</if> /> <label for="Rework tooling" style="margin-left: 1px;">Rework tooling</label> </label> </div> </div> <div class="form-group"> <label>Reason of change:</label> <textarea name="reason_of_change" id="reason_of_change" rows="3" cols="82" lookupGroup="LookupCCEmail" look_name="LookupCCEmail.orgName">{$list.reason_of_change}</textarea> </div> <div class="form-group"> <label>Tooling change description:</label> <textarea name="tooling_change_description" id="tooling_change_description" rows="3" cols="82" lookupGroup="LookupCCEmail" look_name="LookupCCEmail.orgName">{$list.tooling_change_description}</textarea> </div> <div class="form-group" style="display: block;"> <label style="width: 300px;">Remarks / Affected process:</label> <h5>Affected tooling:</h5> <div class="checkbox-container"> <!-- 每行两个复选框 --> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="inner_ldi" value="inner_ldi" <if condition="in_array('inner_ldi', $affected_tooling)"> checked="checked"</if>> <label for="inner_ldi">Inner LDI program</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="inner_aoi" value="inner_aoi" <if condition="in_array('inner_aoi', $affected_tooling)" >checked</if>> <label for="inner_aoi">Inner layer AOI</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="pluritec" value="pluritec" <if condition="in_array('pluritec', $affected_tooling)" >checked</if>> <label for="pluritec">Pluritec program</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="conformal_mask" value="conformal_mask" <if condition="in_array('conformal_mask', $affected_tooling)">checked</if>> <label for="conformal_mask">Conformal mask LDI program</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="drill" value="drill" <if condition="in_array('drill', $affected_tooling)" >checked</if>> <label for="drill">Drill program</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="hole_laser" value="hole_laser" <if condition="in_array('hole_laser', $affected_tooling)" >checked</if>> <label for="hole_laser">Hole / Laser AOI & Hole counter program</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="buttonplate" value="buttonplate" <if condition="in_array('buttonplate', $affected_tooling)" >checked</if>> <label for="buttonplate">Buttonplate / Copper fill LDI program</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="outer_ldi" value="outer_ldi" <if condition="in_array('outer_ldi', $affected_tooling)" >checked</if>> <label for="outer_ldi">Outer LDI program</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="outer_aoi" value="outer_aoi" <if condition="in_array('outer_aoi', $affected_tooling)" >checked</if>> <label for="outer_aoi">Outer layer AOI</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="solder_mask_di" value="solder_mask_di" <if condition="in_array('solder_mask_di', $affected_tooling)">checked</if>> <label for="solder_mask_di">Solder mask DI program</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="solder_mask_avi" value="solder_mask_avi" <if condition="in_array('solder_mask_avi', $affected_tooling)">checked</if>> <label for="solder_mask_avi">Solder mask AVI</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="solder_stencil" value="solder_stencil" <if condition="in_array('solder_stencil', $affected_tooling)">checked</if>> <label for="solder_stencil">Solder mask stencil / printing jig</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="via_filling" value="via_filling" <if condition="in_array('via_filling', $affected_tooling)" >checked</if>> <label for="via_filling">Via filling tool</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="inkjet" value="inkjet" <if condition="in_array('inkjet', $affected_tooling)" >checked</if>> <label for="inkjet">Inkjet</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="laser_mark" value="laser_mark" <if condition="in_array('laser_mark', $affected_tooling)" >checked</if>> <label for="laser_mark">Laser mark</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="routing" value="routing" <if condition="in_array('routing', $affected_tooling)" >checked</if>> <label for="routing">Routing program</label> </div> <div class="checkbox-row"> <input name="affected_tooling[]" type="checkbox" id="etest" value="etest" <if condition="in_array('etest', $affected_tooling)" >checked</if>> <label for="etest">E-Test program / Fixture</label> </div> <!-- Others 行 --> <div class="checkbox-row full-width"> <input name="affected_tooling[]" type="checkbox" id="others_checkbox" value="others_checkbox" <if condition="in_array('others_checkbox', $affected_tooling)">checked</if>> <label for="others_checkbox">Others<span style="margin-left: 10px;">{$list.others_input}</span></label> </div> </div> </div> </div> <div class="section"> <h4>Part C: Running change schedule: (Follow PMC schedule)</h4> <div class="col"> <input type="checkbox" id="running_change_date_option" name="running_change_date_option" <if condition="$list.running_change_date_option" >checked</if>> <label style="width: 400px;margin-left: 10px;" for="running_change_wo_option">Running Change Effective Date & Time:<span>{$list.running_change_date}</span></label> </div> <div class="col"> <input type="checkbox" id="running_change_wo_option" name="running_change_wo_option" <if condition="$list.running_change_wo_option" >checked</if>> <label style="width: 400px;margin-left: 10px;" for="running_change_wo_option">Running Change Effective W/O:<span>{$list.running_change_wo}</span></label> </div> </div> <div class="section"> <h4>Part D: Approval</h4> <table class="approval-table"> <tr> <td>P.E</td> <td>M.E</td> <td>QA</td> </tr> <tr> <td>Date (MM/DD/YYYY):<br> <input type="date" name="pe_approve_date" value="{$list.pe_approve_date}"> <input type="time" name="pe_approve_time" value="{$list.pe_approve_time}"> </td> <td>Date (MM/DD/YYYY):<br> <input type="date" name="me_approve_date" value="{$list.me_approve_date}"> <input type="time" name="me_approve_time" value="{$list.me_approve_time}"> </td> <td>Date (MM/DD/YYYY):<br> <input type="date" name="qa_approve_date" value="{$list.qa_approve_date}"> <input type="time" name="qa_approve_time" value="{$list.qa_approve_time}"> </td> </tr> </table> <div class="footer" style="margin-top: 1px;">Remark:Tooling update only need PE manager approval</div> </div> <div class="footer"> <div>Form No. PEF-005</div> <div>Version: A/2</div> <div>Effective Date: 09/09/2024</div> </div> <div class="footer-page-break"></div> <div class="header" style="display: flex; justify-content: space-between; align-items: center;"> <img src="__PUBLIC__/Images/logo.gif" alt="Logo" style="height: 50px;"> <strong>TCN No: {$list.tcn_no_2} </div> <div class="header" style="justify-content: center;"> <h2>Tooling Change Notice (TCN)</h2> </div> <div class="footer"> <div>Form No. PEF-020</div> <div>Version: A/2</div> <div>Effective Date: 10/28/2024</div> </div> <div class="footer-page-break"></div> <div class="header" style="display: flex; justify-content: space-between; align-items: center;"> <img src="__PUBLIC__/Images/logo.gif" alt="Logo" style="height: 50px;"> <strong>TCN No: ______________ </div> <div class="header" style="justify-content: center;"> <h2>Tooling Change Notice (TCN)</h2> </div> <table class="approval-table"> <thead> <tr> <th>Affected Tooling</th> <th>Recall Tooling PIC</th> <th>Date</th> <th>PIC Signature</th> <th>Confirmed By PE</th> <th>PE Signature</th> <th>Prod.Signature</th> <th>Remarks</th> </tr> </thead> <tbody> <tr> <td>Inner LDI</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Inner AOI</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Pluritec</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Conf. mask LDI</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Drill program</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Hole / Laser AOI and Hole counter</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Buttonplate / Copper fill LDI</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Outer LDI</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Outer AOI</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Solder mask</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>DI</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>SM AVI</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>SM Stencil/Jig</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>RVF Tool</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Inkjet</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Laser mark</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Routing</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>E-test</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Others</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> <div class="footer"> <div>Form No. PEF-020</div> <div>Version: A/2</div> <div>Effective Date: 10/28/2024</div> </div> </div> </div> </div> <div class="formBar"> <ul> <li><div class="button"> <div class="buttonContent"><button type="button" onclick="navTab.closeCurrentTab()">关闭</button></div></div></li> <li><div class="buttonActive"><div class="buttonContent"><button type="button" onclick="print()">{$Think.lang.print}</button></div></div></li> </ul> </div> </div> </body> </html> <script language="javascript" type="text/javascript" src="__PUBLIC__/dwz/js/autosize.min.js"></script> <script language="JavaScript"> function print(){ //$("div#myPrintArea").printArea(); window.open('__URL__/printtable/id/{$list.id}'); } $(document).ready(function () { // 禁止所有 radio 按钮被点击修改 $('input[type="radio"]').each(function () { $(this).data('waschecked', $(this).is(':checked')); // 保存原始状态 $(this).on('click', function (e) { e.preventDefault(); // 阻止默认行为 return false; }); }); }); </script> 以上html页面怎么在浏览器打印的时候,左右两边内容显示不全
07-29
AI Overview Implementing selective checkout with checkboxes on a cart page typically involves allowing users to select specific items in their cart for purchase, rather than requiring them to purchase all items. This functionality is not a standard feature in most e-commerce platforms and usually requires custom development or the use of specialized plugins/apps. General Approach: Modify the Cart Template: Add a checkbox next to each item in the cart. Ensure the checkbox is linked to the specific product or line item. Handle User Selections: Use JavaScript to detect changes in checkbox states (checked/unchecked). When a checkbox is selected or deselected, update the cart's subtotal and potentially the items that will be included in the checkout process. Adjust the Checkout Process: When the user proceeds to checkout, ensure that only the items corresponding to the selected checkboxes are passed to the order. This may involve modifying the platform's core checkout logic or using hooks/filters provided by the platform. Platform-Specific Considerations: WooCommerce (WordPress): Requires custom code in functions.php or a custom plugin to add checkboxes, manage selections, and modify the checkout process. You might use AJAX to update the cart dynamically as selections are made. Shopify: Involves modifying theme files (e.g., cart-template.liquid, theme.js) to add checkboxes and JavaScript to handle the logic. This often requires familiarity with Liquid (Shopify's templating language) and JavaScript. Other Platforms: The specific implementation will vary based on the platform's architecture and extensibility options. It may involve similar approaches of template modification and custom code. Important Notes: Complexity: Implementing selective checkout can be complex and may require advanced coding skills. User Experience: Carefully consider the user experience implications of selective checkout to ensure it is intuitive and does not cause confusion. Testing: Thoroughly test the functionality to ensure that selected items are correctly processed and that no loopholes exist (e.g., refreshing the page causing issues with selected items). I want to achieve this selective checkbox function in my cart page. Im using woocommerce and woodmart theme. Please advice on what to do
07-30
It says There has been a critical error on this website. Please review my code cart.php: <?php /** * The template for displaying the cart page. * * This file has been modified to support selective checkout with checkboxes. * * @package woodmart */ defined( 'ABSPATH' ) || exit; do_action( 'woocommerce_before_cart' ); ?> <form class="woocommerce-cart-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post"> <?php do_action( 'woocommerce_before_cart_table' ); ?> <table class="shop_table shop_table_responsive cart woocommerce-cart-form__contents" cellspacing="0"> <thead> <tr> <th class="product-select"><input type="checkbox" id="select-all-items"> Select All</th> <th class="product-name"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th> <th class="product-price"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th> <th class="product-quantity"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th> <th class="product-subtotal"><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th> <th class="product-remove"> </th> </tr> </thead> <tbody> <?php do_action( 'woocommerce_before_cart_contents' ); ?> <?php foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) { $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key ); ?> <tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>"> <td class="product-select" data-title="<?php esc_attr_e( 'Select', 'woocommerce' ); ?>"> <label> <input type="checkbox" name="selected_items[]" value="<?php echo esc_attr( $cart_item_key ); ?>" checked> </label> functions.php: // Add checkbox to each cart item add_filter('woocommerce_cart_item_name', 'add_checkbox_to_cart_item', 10, 3); function add_checkbox_to_cart_item($item_name, $cart_item, $cart_item_key) { $checked = WC()->session->__isset('selected_items') && in_array($cart_item_key, WC()->session->get('selected_items')) ? 'checked' : 'checked'; $checkbox = '<label><input type="checkbox" name="selected_items[]" value="' . esc_attr($cart_item_key) . '" ' . $checked . '> ' . $item_name . '</label>'; return $checkbox; } // Handle AJAX request to update selected items add_action('wp_ajax_update_selected_cart_items', 'handle_update_selected_cart_items'); add_action('wp_ajax_nopriv_update_selected_cart_items', 'handle_update_selected_cart_items'); function handle_update_selected_cart_items() { if (isset($_POST['selected_items']) && is_array($_POST['selected_items'])) { $selected_items = array_map('sanitize_text_field', $_POST['selected_items']); WC()->session->set('selected_items', $selected_items); foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) { if (!in_array($cart_item_key, $selected_items)) { WC()->cart->set_quantity($cart_item_key, 0); } else { WC()->cart->set_quantity($cart_item_key, $cart_item['quantity']); } } wp_send_json_success(); } wp_send_json_error(); } // Only include selected items in order add_filter('woocommerce_add_to_order_from_cart_item', 'filter_items_during_checkout', 10, 3); function filter_items_during_checkout($bool, $cart_item_key, $order) { $selected_items = WC()->session->get('selected_items', []); if (!in_array($cart_item_key, $selected_items)) { return false; } return $bool; } // Reset session after checkout add_action('woocommerce_thankyou', 'reset_selected_items_session'); function reset_selected_items_session($order_id) { WC()->session->__unset('selected_items'); } js/custom-cart.js jQuery(document).ready(function($) { // Add "Select All" checkbox dynamically to cart (only if not already present) if ($('#select-all-items').length === 0) { $('.woocommerce-cart-form__contents').before( '<div class="select-all-wrapper" style="margin: 15px 0;">' + ' <label><input type="checkbox" id="select-all-items"> Select All</label>' + '</div>' ); } // Handle checkbox changes for individual items $(document).on('change', 'input[name="selected_items[]"]', function() { updateSelectedItemsAndSyncCart(); }); // Handle "Select All" checkbox change $(document).on('change', '#select-all-items', function() { var isChecked = $(this).is(':checked'); $('input[name="selected_items[]"]').prop('checked', isChecked); updateSelectedItemsAndSyncCart(); }); // Function to collect selected items and send AJAX request function updateSelectedItemsAndSyncCart() { let selectedItems = []; // Collect selected item keys $('input[name="selected_items[]"]:checked').each(function() { selectedItems.push($(this).val()); }); // Send AJAX request to update cart $.ajax({ url: wc_cart_params.ajax_url, type: 'POST', data: { action: 'update_selected_cart_items', selected_items: selectedItems }, success: function(response) { if (response) { // Refresh cart fragments and update checkout $('body').trigger('wc_fragment_refresh'); $('body').trigger('update_checkout'); // Update "Select All" checkbox state const allCheckboxes = $('input[name="selected_items[]"]'); const checkedCheckboxes = allCheckboxes.filter(':checked'); $('#select-all-items').prop('checked', allCheckboxes.length === checkedCheckboxes.length); } } }); } }); whats wrong?
07-30
Currently You are now a website builder. These are the code in my cart.php & functions.php. Currently, i am very satisfied with my layout. However, I want to achieve cart like Shopee / Taobao / Lazada, that allow my customer to 1) Do selective checkout, where only selected items are sent to checkout page, and after order created, only these items will be removed from cart. On the other side, non-selected items are retained inside cart, until customer remove them manually through 清除購物車 / 移除選中商品 or customer check out them. Only remove when order is created. If customer go back from checkout page or payment page, or anything, as long as order is not created, dont remove them. Currently im using restore cart way to achieve this, but everything from cart is removed currently after order created. theres some mistake that stop me from achieving this. I turned on feature where customer can see how many items are inside cart through the cart icon at header. At the same time, i dont want my customer to notice that their cart is cleared and recovered before (the amount of items in cart icon will show 0 when havent recover and the number of items after recover). I dont want them to notice the change, therefore, we have to recover it fast until customer did not notice them. Please be considerate regarding customer that use PC because they might access my website through another tab, at there, they can see the amount of items in cart icon. Therefore, i want it to always show the correct amount, only remove when the order is created and maintain if the order is not created. I dont want them to notice how it works (recovering) 2) All these 全选 刪除選中的商品 清空購物車 输入优惠券代码 应用优惠券 已选商品: 0 件,共计: RM0.00 结算 works perfectly fine, please remain them. Maintaining all the layout and achieved functions. Please check which part stopped me from achieving the selective checkout (maintain non-selected items inside cart, only remove selected to checkout items when order created, and dont let customer nmotice the change in their cart. I want them to no matter access from where, either new tab, other device etc, they will see the correct items in their cart) For now, If i cancel the payment halfway, i am logged out when back from payment page, and when i check from other tab, non-selected items are removed from cart, only selected items are still inside cart. Also, when i login back after payment page, it redirects me to pay-only page. Please refer how taobao cart works, and review which part is stopping me from achieve taobao cart, give me the part of code to be changed and the new code to replaced with the current one, as i have no coding basic
最新发布
08-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值