Skip to content

Instantly share code, notes, and snippets.

@goliver79
goliver79 / wc-glsasm-add-tracking-button-in-orders.php
Created April 1, 2020 20:19
Woocommerce Plugin GLS - ASM: Add tracking button in "my orders" page
<?php
if ( !class_exists( 'GlsAsm' ) ) {
class GlsAsm{
function activate(){
add_filter ( 'woocommerce_my_account_my_orders_actions', array( $this, 'go_add_shipping_tracking_to_customer_orders_table' ), 10, 2 );
add_action( 'woocommerce_after_account_orders', array( $this, 'action_after_account_orders_js'));
}
function go_add_shipping_tracking_to_customer_orders_table($actions, $order) {
if ( $order->has_status( 'completed' ) ) {
@goliver79
goliver79 / wc-add-vat-message-after-price.php
Created April 1, 2020 20:13
Woocommerce add vat message after price
<?php
if ( !class_exists( 'VATMessage' ) ) {
class VATMessage {
function activate() {
add_filter( 'woocommerce_get_price_html', array( $this, 'vat_message' ) );
}
function vat_message( $price ) {
$vat = ' <span class="vat-info">' . __( '(VAT not included)', 'logopedicum' ) . '</span>';
@goliver79
goliver79 / wc-shipping-big-products.php
Last active April 1, 2020 20:13
Woocommerce disable free shipping in "big products"
<?php
if ( !class_exists( 'wcShippingBigProducts' ) ) {
class wcShippingBigProducts {
// disable free sipping if "big products" in cart
// "big products" has shipping class 'productos-grandes'
function activate() {
add_filter( 'woocommerce_package_rates', array( $this, 'shippingBigProducts' ), 10, 2 );
}
@goliver79
goliver79 / wc-hide-shipments-if-free.php
Last active April 1, 2020 20:14
Woocommerce hide other shipments if free shipment
<?php
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( !class_exists( 'HideShipmentsIfFree' ) ) {
class HideShipmentsIfFree {
function activate() {
add_action( 'woocommerce_package_rates', array( $this, 'hide_shipments_if_free' ), 100 );
@goliver79
goliver79 / function.php
Created September 8, 2015 07:44
[WORDPRESS] Show all posts in a combobox
<form action="<? bloginfo('url'); ?>" method="get">
<select name="page_id" id="page_id">
<?php
global $post;
$args = array( 'numberposts' => -1);
$posts = get_posts($args);
foreach( $posts as $post ) : setup_postdata($post); ?>
<option value="<? echo $post->ID; ?>"><?php the_title(); ?></option>
<?php endforeach; ?>
</select>
@goliver79
goliver79 / MyClass.java
Last active August 29, 2015 14:28
[ANDROID] Log Tag declaration
private final String LOG_TAG = MyClass.class.getSimpleName();
//...
Log.e(LOG_TAG, "Error ", e);
@goliver79
goliver79 / manifest.xml
Created August 23, 2015 16:29
[ANDROID] Lock orientation and fullscreen
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
@goliver79
goliver79 / main.java
Created August 22, 2015 14:12
[ANDROID-JAVA] Check view type
@Override
public void onClick(View v) {
if ( v instanceof Button ){
String btnText = ((Button) v).getText().toString();
}else if ( v instanceof ListView ) {
// ..
} //..
}
@goliver79
goliver79 / main.java
Created August 22, 2015 14:10
[ANDROID-JAVA] Random number
//Create an object of the Random class so we can use it
Random randInt = new Random();
//Generate a random number between 0 and 5
int randNum = randInt.nextInt(6);
@goliver79
goliver79 / functions.php
Created August 9, 2015 09:32
[WORDPRESS] Show all active plugins
<?php
function wpr_active_site_plugins() {
$the_plugs = get_option('active_plugins');
foreach($the_plugs as $key => $value) {
$string = explode('/',$value); // Folder name will be displayed
echo $string[0] ."\n";
}
}
wpr_active_site_plugins();