This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* It will remove the selected quantity count from checkout page table. | |
*/ | |
function remove_quantity_text( $cart_item, $cart_item_key ) { | |
$product_quantity= ''; | |
return $product_quantity; | |
} | |
add_filter ('woocommerce_checkout_cart_item_quantity', 'remove_quantity_text', 10, 2 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* It will add Delete button, Quanitity field on the checkout page Your Order Table. | |
*/ | |
function add_quantity( $product_title, $cart_item, $cart_item_key ) { | |
/* Checkout page check */ | |
if ( is_checkout() ) { | |
/* Get Cart of the user */ | |
$cart = WC()->cart->get_cart(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function( $ ) { | |
$( "form.checkout" ).on( "click", "input.qty", function( e ) { | |
var data = { | |
action: 'update_order_review', | |
security: wc_checkout_params.update_order_review_nonce, | |
post_data: $( 'form.checkout' ).serialize() | |
}; | |
jQuery.post( add_quantity.ajax_url, data, function( response ) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function load_ajax() { | |
if ( !is_user_logged_in() ){ | |
add_action( 'wp_ajax_nopriv_update_order_review', 'update_order_review' ); | |
} else{ | |
add_action( 'wp_ajax_update_order_review', 'update_order_review' ); | |
} | |
} | |
add_action( 'init', 'load_ajax' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function update_order_review() { | |
$values = array(); | |
parse_str($_POST['post_data'], $values); | |
$cart = $values['cart']; | |
foreach ( $cart as $cart_key => $cart_value ){ | |
WC()->cart->set_quantity( $cart_key, $cart_value['qty'], false ); | |
WC()->cart->calculate_totals(); | |
woocommerce_cart_totals(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function add_css(){ | |
if ( is_checkout() ) { | |
wp_enqueue_style( 'checkout_style', plugins_url( '/assets/css/change-quantity-on-checkout.css', __FILE__ ), '', '', false ); | |
} | |
} | |
add_action( 'wp_footer', 'add_css' ), 10 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#content table.shop_table a.remove { | |
color: red; | |
display: block; | |
font-size: 20px; | |
font-weight: 700; | |
height: 20px; | |
line-height: 20px; | |
padding: 0; | |
text-align: center; | |
text-decoration: none; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Save the persistent cart when the cart is updated. | |
*/ | |
public function persistent_cart_update() { | |
update_user_meta( get_current_user_id(), '_woocommerce_persistent_cart', | |
array( 'cart' => WC()->session->get( 'cart' ), | |
) ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the cart data from the PHP session and store it in class variables. | |
*/ | |
public function get_cart_from_session() { | |
// Load cart session data from session | |
foreach ( $this->cart_session_data as $key => $default ) { | |
$this->$key = WC()->session->get( $key, $default ); | |
} | |
$update_cart_session = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Save the persistent cart when the cart is updated. | |
*/ | |
public function persistent_cart_update() { | |
update_user_meta( get_current_user_id(), '_woocommerce_persistent_cart_' . get_current_blog_id(), | |
array( 'cart' => WC()->session->get( 'cart' ), | |
) ); | |
} |
OlderNewer