This file contains 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
// before add to cart, empty the existing cart items | |
add_filter( 'woocommerce_add_to_cart_validation', 'sa53re_custom_woocommerce_add_to_cart_validation' ); | |
function sa53re_custom_woocommerce_add_to_cart_validation( $cart_item_data ) { | |
global $woocommerce; | |
$woocommerce->cart->empty_cart(); | |
// Do nothing with the data and return | |
return true; |
This file contains 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
Only add items in a category group only in to cart - WooCommerce 4 | |
function sa45er_category_group_validation($valid, $product_id, $quantity) { | |
global $woocommerce; | |
if($woocommerce->cart->cart_contents_count == 0){ | |
return $valid; | |
} | |
$target_cat_group = array( | |
array(17,20), // Update your product category |
This file contains 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 | |
/** | |
* Loading text domain | |
*/ | |
function load_woo_mpgs_textdomain() { | |
load_plugin_textdomain( 'woo-mpgs', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' ); | |
} | |
add_action( 'plugins_loaded', 'load_woo_mpgs_textdomain' ); |
This file contains 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
HSTORE in flask app | |
In your model, import requred module | |
from sqlalchemy.dialects.postgresql import HSTORE | |
from sqlalchemy.ext.mutable import MutableDict | |
Then use Hstore in our model class | |
class Submission(db.Model): |
This file contains 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
var paragraphs = ['paragraph 1', 'paragraph 1']; | |
var html = '<p>' + paragraphs.join('</p><p>') + '</p>'; |
This file contains 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
/* | |
* For latest WooCommerce Rest API | |
* Add a referanse field to the Order API response. | |
*/ | |
function prefix_wc_rest_prepare_order_object( $response, $object, $request ) { | |
// Get the value | |
$referanse_meta_field = ( $value = get_post_meta($object->get_id(), '_billing_referanse', true) ) ? $value : ''; | |
$response->data['referanse'] = $referanse_meta_field; |
This file contains 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
Why WordPress not using session in PHP. Reason and the better alternatives. | |
https://pressjitsu.com/blog/wordpress-sessions-performance/ | |
https://techgirlkb.guru/2017/08/wordpress-doesnt-use-php-sessions-neither/ |
This file contains 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
$customer_id = get_current_user_id(); | |
$customer_orders = get_posts( array( | |
'numberposts' => -1, | |
'meta_key' => '_customer_user', | |
'meta_value' => $customer_id, | |
'post_type' => wc_get_order_types(), | |
'post_status' => array_keys( wc_get_order_statuses() ), | |
//'post_status' => array('wc-completed'), | |
) ); |
This file contains 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
1. Install SMTP Plugins | |
https://wordpress.org/plugins/search/SMTP/ | |
2. Configure Plugins | |
* Outgoing Mail (SMTP) Server: smtp.gmail.com | |
* Use Authentication: Yes | |
* Use Secure Connection: Yes (TLS or SSL) | |
* Username: your Gmail account (e.g. [email protected]) |
This file contains 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 | |
/* | |
Template Name: archive | |
*/ | |
get_header(); | |
wp_enqueue_script('magnific'); | |
add_action('wp_footer', 'san_scripts', 21); | |
function san_scripts() { |
NewerOlder