I made an ecommerce theme and threre register mini-cart.php by <?php echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( '%s &times; %s', $cart_item['quantity'], $product_price ) . '</span>', $cart_item, $cart_item_key ); ?> code but when I add product to cart its show empty,afte page reload shows product numbers

Recommended Answers

All 2 Replies

Could you post the JavaScript/AJAX code that goes together with this? PHP code runs entirely server-side, and thus can only affect the browser-side rendering on a refresh. Any AJAX code has to run browser side, which effectively means JavaScript (or a language which translates into either JavaScript or WebAssembly). It is even in the acronym: AJAX stands for "Asynchronous JavaScript and XML", which was what it is used for (e.g., communicating between the browser and the server so the page could be updated without a refresh).

Looking at this again, I note that you are using the WooCommerce plugin for WordPress. This is relevant information for anyone trying to help, as the solution is going to require some knowledge of WoodCommerce and WordPress itself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.