Skip to content

Instantly share code, notes, and snippets.

@beamkiller
beamkiller / functions.php
Created February 27, 2023 13:29
Gold-shop.sk - UX Builder Products element Quantity issue
<?php
add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_loop_ajax_add_to_cart', 10, 2 );
/**
* Add qty button and ajax to add to cart
* @link https://stackoverflow.com/questions/48722178/add-a-quantity-field-to-ajax-add-to-cart-button-on-woocommerce-shop-page
*
*/
function quantity_inputs_for_loop_ajax_add_to_cart( $html, $product ) {
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
@beamkiller
beamkiller / Checkout Check.php
Last active September 18, 2019 21:07
Checkout Check
/**
* Process the checkout
**/
add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
function my_custom_checkout_field_process() {
global $woocommerce;
if ( ! (preg_match('/^[+]{0,1}[0-9]{10,14}$/D', $_POST['billing_phone'] ) ) ){
wc_add_notice( "<strong>Telefón</strong> musí obsahovať minimálne 10 čísiel." ,'error' );
@beamkiller
beamkiller / new_gist_file.php
Created April 19, 2017 19:37
ADD Custom Partner Field for MyAccount page and change user role to Partner
/****************************************************************************************************/
/* ADD Custom Partner Field for MyAccount page and change user role to Partner */
/****************************************************************************************************/
function wooc_extra_register_fields() {
?>
<p class="form-row form-row-wide">
<label for="reg_partner"><?php _e( 'Partner', 'woocommerce' ); ?> </label>