cart

Change cart and checkout button links on WooCommerce mini cart widget

孤人 提交于 2019-11-29 14:43:24
On Woocommerce, how can we change the URLs on "View cart" and "Checkout" links on the drop down menu that show up on hover over the shopping cart icon on the the home page? I have the "cart" and "checkout" pages setup but they are not linked to these. I can view these pages directly with urls. http://mysite/cart and http://mysite/checkout It seems that there is a problem somewhere with your theme (or in a plugin), as the minicart button links always point to the right cart and checkout pages. The minicart buttons are hooked in woocommerce_widget_shopping_cart_buttons action hook (in the cart

CodeIgniter IE not storing sessions correctly

只愿长相守 提交于 2019-11-29 12:17:21
I am using the Cart class of CodeIgniter, basically that's just sessions. Now, Safari is handling them perfectly fine and is doing what it is supposed to do. IE, on the other hand, does not store them. So after a while of trying to fix this, I figured to add the sessions to the database. Safari adds one result to the database with all fields filled out. Now IE. It adds around 5 items to the database with the row 'user_data' being empty. This is the method adding the item to the cart; /** * Method to add an item to the shopping cart. * * @access public * @param integer $product_id * @param

WooCommerce - Skip cart page redirecting to checkout page

我与影子孤独终老i 提交于 2019-11-29 12:15:30
Our website is kohsamuitour.net . I have added custom code to skip the cart page on checkout, which works for all sales. This code: function wc_empty_cart_redirect_url() { return 'https://www.kohsamuitour.net/all-tours/'; } add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' ); Now that does the job, but we also have a possibility to check booking availability. That can be found on the pages of private charters, i.e. this one: https://www.kohsamuitour.net/tours/kia-ora-catamaran/ . Here the customer is being redirected to the cart, where I don't want that to happen

Add tax free fees to WooCommerce cart programmatically

老子叫甜甜 提交于 2019-11-29 11:41:28
I try to add fees based on some calculations I do on Woocommerce cart, but I want to exclude it from VAT. This is my code: function woo_add_cart_fee( $cart ) { global $woocommerce; $bookable_total = 0; foreach(WC()->cart->get_cart() as $cart_item_key => $values) { $_product = $values['data']; //doing my stuff to calculate $fee variable WC()->cart->add_fee( 'Fees: ', $fee, false, '' ); //WC()->cart->add_fee( 'Fees: ', $fee, true, '' ); //WC()->cart->add_fee( 'Fees: ', $fee, false, 'zero rate' ); //WC()->cart->add_fee( 'Fees: ', $fee, true, 'zero rate' ); } add_action( 'woocommerce_cart

Cart discount based on cart item count and only for items that are not in sale

柔情痞子 提交于 2019-11-29 11:03:44
In WooCommerce, I would like to give a discount of 10% specifically for those products that are not on sale. If cart item count is 5 or more items and not on sale, then I give a discount of 10%. I use the following code to get a discount based on cart item count restriction here: add_action('woocommerce_cart_calculate_fees' , 'add_custom_fees'); /** * Add custom fee if more than three article * @param WC_Cart $cart */ function add_custom_fees( WC_Cart $cart ){ if( $cart->cart_contents_count < 5 ){ return; } // Calculate the amount to reduce $discount = $cart->subtotal * 0.1; $cart->add_fee(

Apply a discount on the cart content total excluding taxes in WooCommerce

一世执手 提交于 2019-11-29 08:40:46
I need to apply a discount to the cart subtotal before tax is calculated if a user is ordering for the first time. However, tax is calculated per-item in WooCommerce and added to the subtotal afterwards. So I need to apply the discount to the items in the cart before WooCommerce calculates the tax on them. This way the tax is based off of the discounted prices rather than the original prices. Here is what I have: function first_order_add_five_percent_discount($cart_object) { if ( is_user_logged_in() ) { //current user id $currentUser_id = get_current_user_id(); //amount of orders by current

Changing WooCommerce cart item names

北城以北 提交于 2019-11-29 08:20:48
The goal is to change the name of the item as it gets passed to our payment gateway, but leave it as-is for display on our product pages. I've tried this in my functions.php: function change_item_name( $item_name, $item ) { $item_name = 'mydesiredproductname'; return $item_name; } add_filter( 'woocommerce_order_item_name', 'change_item_name', 10, 1 ); But it doesn't seem to be working for me. I feel like I should be passing in an actual item ID or something… I'm a little lost. Any information on what I'm doing wrong here would be greatly appreciated. The woocommerce_order_item_name filter hook

Progressive discount based on cart total in WooCommerce

限于喜欢 提交于 2019-11-29 05:22:10
I'm trying to automatically apply 3 different coupon codes in WooCommerce Cart. Here's my code ! add_action( 'woocommerce_before_cart', 'apply_matched_coupons' ); function apply_matched_coupons() { global $woocommerce; $coupon_code5 = '5percent'; $coupon_code10 = '10percent'; $coupon_code55 = '15percent'; if ( $woocommerce->cart->has_discount( $coupon_code ) ) return; if ( $woocommerce->cart->cart_contents_total >= 50 && $woocommerce->cart->cart_contents_total < 100 && $woocommerce->cart->cart_contents_total != 100 ) { $woocommerce->cart->add_discount( $coupon_code5 ); } elseif ($woocommerce-

WooCommerce Get Order Product Details Before Payment in Plugin

∥☆過路亽.° 提交于 2019-11-29 04:49:55
I need to display order details from cart before payment in plugin. I work on one plugin what connect woocommerce and an payment API and there I need to send array of product details like product ID, name, description, quantity and individual amount. My problem is that I can't find right hook to get all data properly. How can I get this data? Thanks UPDATE Here is update based on anwers for everyone who need it: add_action('woocommerce_checkout_process', 'woocommerce_get_data', 10); function woocommerce_get_data(){ $cart = array(); $items = WC()->cart->get_cart(); foreach($items as $i=>$fetch)

Checking products in cart based on category name woocommerce?

放肆的年华 提交于 2019-11-29 04:49:13
I'm trying to trigger an echo statement if a certain category of product is in my cart, here's my code: <?php //Check to see if user has product in cart global $woocommerce; //flag no book in cart $item_in_cart = false; foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) { $_product = $values['data']; $terms = get_the_terms( $_product->id, 'product_cat' ); foreach ($terms as $term) { $_categoryid = $term->term_id; } if ( $_categoryid == 'name_of_category' ) { //book is in cart! $item_in_cart = true; } } if ($item_in_cart === true) {echo 'YES';} else {echo 'Nope!';} ?> Any