Skip to content

Instantly share code, notes, and snippets.

@nagygabor
nagygabor / gist:3879b4c937d2fe9dbde993ba2c29d822
Created October 24, 2018 18:44
Ne adjon hozzá többet a cartba
//https://stackoverflow.com/questions/28576667/get-cart-item-name-quantity-all-details-woocommerce
function xnagyg_woocommerce_add_to_cart_validation($passed,$product_id,$quantity) {
//nem megy if (empty( $_GET['add-to-cart-only-once'] )){
// return true; //nincs az url-ben jel, hogy figyeljük
// }
global $woocommerce;
$items = $woocommerce->cart->get_cart();
foreach($items as $item => $values)
{
@nagygabor
nagygabor / gist:7072dd190414f238cd22cf3e363f6903
Created October 24, 2018 18:42
Kosár darabszám változás után automatikus újraszámolás legyen
//Kosár darabszám változás után automatikus újraszámolás legyen
//https://gist.github.com/mikaelz/f41e29c6a99a595602e4
function xnagyg_cart_update_qty_script() {
if (is_cart()) :
?>
<script>
jQuery('div.woocommerce').on('change', '.qty', function(){
jQuery("[name='update_cart']").removeAttr('disabled');
jQuery("[name='update_cart']").trigger("click");
});
@nagygabor
nagygabor / gist:c592cf73618b179dc618c1e3b98d9890
Created October 24, 2018 18:40
xnagyg_thankyouredirect
//Vásárláskor az egyedi oldalra irányítson át, order és key paraméterekbe tenni az információt.
function xnagyg_thankyouredirect($order_id) {
$order_key = wc_clean( $_GET['key'] );
$redirect = get_permalink( 338 ); //This is the Custom Shop Thanks page id //TODO: admin option
$redirect = add_query_arg( array(
'order' => $order_id,
'key' => $order_key,
), $redirect );
@nagygabor
nagygabor / gist:cc45cb2de911ec3efcee4c465257c96b
Created October 24, 2018 18:39
Megrendelés köszönöm oldal generálás shortcode-al
//Usage: [woothankyouform default='Hibás megrendelésszám!']
function xnagyg_woocommerce_thankyou( $atts ) {
extract( shortcode_atts( array(
'default' => '',
), $atts ) );
//Must remove action because of infinite redirect loop. checkout/thankyou.php template would call it again
remove_action('woocommerce_thankyou','xnagyg_thankyouredirect',1);
// Check if the order ID exists.
@nagygabor
nagygabor / xnagyg_redirect_checkout_add_cart
Created October 24, 2018 18:34
xnagyg_redirect_checkout_add_cart
//https://businessbloomer.com/woocommerce-redirect-checkout-add-cart/ alapján
function xnagyg_redirect_checkout_add_cart( $url ) {
//csak ha van add-to-cart az url-ben GET
if ( empty( $_GET['add-to-cart'] ) || ! is_numeric( $_GET['add-to-cart'] ) ) {
return false; //ne irányítson át
}
$url = get_permalink( get_option( 'woocommerce_checkout_page_id' ) ); //Pénztár oldalra menjen
return $url;
}