Skip to content

Instantly share code, notes, and snippets.

Avatar

Renzo Zamora renzoster

View GitHub Profile
@renzoster
renzoster / wpdb.java
Created Jul 6, 2019
WP-DB port to Java
View wpdb.java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import java.util.regex.Matcher;
@renzoster
renzoster / wc-disable-add-to-cart-message.php
Created Jul 6, 2019
Disable message added to cart on WooCommerce
View wc-disable-add-to-cart-message.php
<?php
add_filter( 'wc_add_to_cart_message_html', '__return_null' );
@renzoster
renzoster / wc-one-product-add-to-cart.php
Created Jul 6, 2019
Woocommerce empty cart before add new product to cart.
View wc-one-product-add-to-cart.php
<?php
/**
* Empty cart. New product will be added. Works with WooCommerce 3.0+
*/
add_filter( 'woocommerce_add_to_cart_validation', 'custom_only_one_in_cart', 99, 2 );
function custom_only_one_in_cart( $passed, $added_product_id ) {
wc_empty_cart();
return $passed;
}
@renzoster
renzoster / wc-redirect-user-add-to-cart.php
Last active Jul 6, 2019
Woocommerce redirect user to checkout after add to cart
View wc-redirect-user-add-to-cart.php
<?php
/**
* Redirect users after add to cart. Works with WooCommerce 3.0+
*/
function custom_add_to_cart_redirect( $url ) {
$url = WC()->cart->get_checkout_url();
return $url;
}
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' );
@renzoster
renzoster / db.php
Created Oct 24, 2018
DB Class like WordPress DB
View db.php
<?php
class db{
protected $con = false;
public function __destruct(){
return null;
}
public function connect($dbhost, $dbname, $dbuser, $dbpass){
You can’t perform that action at this time.