cart

Change the cart item quantity for specific products in woocommerce

天大地大妈咪最大 提交于 2019-12-13 12:29:59
问题 Can I change WooCommerce quantity in some specific product? I have tried: global $woocommerce; $items = $woocommerce->cart->get_cart(); foreach($items as $item => $values) { $_product = $values['data']->post; echo "<b>".$_product->post_title.'</b> <br> Quantity: '.$values['quantity'].'<br>'; $price = get_post_meta($values['product_id'] , '_price', true); echo " Price: ".$price."<br>"; } How to get specific product Id in cart? 回答1: To change quantities, see after that code. Here your revisited

Apply coupon discount via GET method in URL even if cart is empty in WooCommerce

时间秒杀一切 提交于 2019-12-13 11:34:32
问题 I have a plugin that sends an advocates referral coupon code to e-mails that they enter. When the audience receives this email I'd like to create a flow where they can click on 'SHOP NOW' in the e-mail and the coupon will be automatically added. As of now, for the link under the 'SHOP NOW' button I've entered the following: websitename.biz/cart__trashed?code=DISCOUNTCODE To handle $code I've put this in my functions.php file: add_action('woocommerce_before_cart', 'discount'); function

I need help getting the grand total of a simple php cart using sessions [closed]

家住魔仙堡 提交于 2019-12-13 10:58:52
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . Hi all I have a shopping cart which is made up of 2 PHP files. order.php and products.php. All of the configuration is set in the order file and it doesn't use a MYSQL database as im using sessions. Im trying to

Google's Simple Shopping Cart [closed]

两盒软妹~` 提交于 2019-12-13 10:11:06
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 years ago . Here is the simple shopping cart I was looking for: http://code.google.com/p/jscart/wiki/Example. Thank you everyone for your help. All the notes led me to rethink and ponder ... hmm, I wonder if someone out there has already done something similar ... 回答1: It's because of your "currentStateOpened"

How to show total price of items in Woocommerce Cart Widget?

﹥>﹥吖頭↗ 提交于 2019-12-13 04:32:44
问题 Currently my Woocommerce cart widget look like this (witout total price of items): img1 Coffee 2 x $5 ------------------- img2 Biscuit 1 x $10 ------------------- img3 Cheese 3 x $10 ------------------- Subtotal: $50 I want to change it to (with total price of quantity items): img1 Coffee 2 x $5 $10 --------------------------- img2 Biscuit 1 x $10 $10 --------------------------- img3 Cheese 3 x $10 $30 --------------------------- Subtotal: $50 As you can see the second example of Cart Widget

Magento - Remove Item from Cart by Sku

好久不见. 提交于 2019-12-13 04:30:55
问题 i try to remove a product from Cart by Sku - is it possible? I tried the following Code in cartcontroller.php but without success .... I know it should work by ID but by Sku would be easier for me. $session = Mage::getSingleton('checkout/session'); $quote = $session->getQuote(); $cart = Mage::getModel('checkout/cart'); $cartItems = $cart->getItems(); foreach($cartItems as $item) { if ($item->getSku() == promo){ $quote->removeItem($item->getId())->save(); } } Mage::getSingleton('checkout

PHP how to identify user items in cart for rest api

自古美人都是妖i 提交于 2019-12-13 03:56:46
问题 I'm creating a token based rest api in php for e-commerce application. Scenario : Any visitor can add items to cart without logging in. These items are stored in the mysql database, cart table, with user_id value which defaults to 1. // As user is not logged in. Problem : After the user logs in, i am able to fetch the userid after decoding the token generated for the user, but want to know, how can i identify which items in cart table belongs to which user so as to update the actual userid

Hide specific shipping method for specific products in Woocommerce

ぐ巨炮叔叔 提交于 2019-12-13 01:42:50
问题 I have a few products in my WooCommerce store that are to heavy (more than 20kg) to be shipped by a certain shipping method. I would like to hide 'shipping_method_0_flat_rate2' for all cart items which contain a product that is heavier than 20kg. I tried to adjust the snippet below, but it is not complete and working: add_filter( 'woocommerce_package_rates', 'hide_shipping_based_on_tag' , 10, 1 ); function check_cart_for_share() { // specify the product id's you want to hide $product_ID =

Show Message in Woocommerce Cart only for specific product variation Attribute

核能气质少年 提交于 2019-12-13 00:37:31
问题 I am adding a custom message to the Cart page, but so that it only appears if an added product has a custom variation atribute selected. After researching I came up to: add_action( 'woocommerce_after_cart', 'wnd_after_cart' ); function wnd_after_cart() { if($attribute_slug == 'no_review'){ echo '<div class="wnd_after_cart"><h4>There will be no item manual review</h4><br /> </div>'; } } But its not working. Does anyone know what am I doing wrong? add_action( 'woocommerce_after_cart', 'wnd

WooCommerce shipping cost based on cart item count

余生长醉 提交于 2019-12-12 23:19:33
问题 I want to count shipping cost based on number of products add on cart like, If I purchase one mobile then it will count shipping cost as 2.5 and after more than two or two mobile I purchased then shipping cost will be 5.0 <?php $qty(1) * 2.5 = 2.5 $qty(2) * 2.5 = 5.0 $qty(3) * 2.5 = 5.0 ?> So is there any idea or suggestion how to count the shipping cost based on number of products ? 回答1: Updated: As your question is a bit unclear, you could just need to add [qty]*2.5 in the Flat rate