Skip to content

Instantly share code, notes, and snippets.

View monecchi's full-sized avatar

Adriano Monecchi monecchi

View GitHub Profile
@monecchi
monecchi / formspree.html
Created November 23, 2015 10:52 — forked from manfromanotherland/formspree.html
JS: Ajax send forms using the most excellent Formspree » http://formspree.io #snippet
<form id="contact-form" action="//formspree.io/your@email.com" method="post">
<input type="text" name="Name" placeholder="Name" required>
<input type="email" name="Email" placeholder="Email" required>
<textarea name="Message" cols="30" rows="6" placeholder="Message" required></textarea>
<!-- CONFIG -->
<input class="is-hidden" type="text" name="_gotcha">
<input type="hidden" name="_subject" value="Subject">
<input type="hidden" name="_cc" value="email@cc.com">
<!-- /CONFIG -->
<input class="submit" type="submit" value="Send">
@monecchi
monecchi / fix_homebrew.rb
Created December 16, 2015 12:41 — forked from rpavlik/fix_homebrew.rb
Fix permissions on /usr/local for Homebrew
#!/usr/bin/ruby
#
# This script fixes /usr/local only.
#
# 6th January 2010:
# Modified the script to just fix, rather than install. - rpavlik
#
# 30th March 2010:
# Added a check to make sure user is in the staff group. This was a problem
# for me, and I think it was due to me migrating my account over several
@monecchi
monecchi / Add Custom CSS to Anchors links in WordPress
Created March 8, 2016 17:30 — forked from tahirtaous/Add Custom CSS to Anchors links in WordPress
How to Add Custom CSS Class Directly to Menu Item (Anchors) Links in WordPress Theme
// Redirect customers to another page with your personal thoughts and thank you message instead of woocommerce default thank you page.
add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' );
function wc_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( 'http://www.yoururl.com/your-page/' );
exit;
}
}
@monecchi
monecchi / functions.php
Created April 1, 2016 05:37 — forked from claudiosanches/functions.php
WooCommerce - Add Order Again button to My Orders actions
<?php
/**
* Add order again button in my orders actions.
*
* @param array $actions
* @param WC_Order $order
* @return array
*/
function cs_add_order_again_to_my_orders_actions( $actions, $order ) {
if ( $order->has_status( 'completed' ) ) {
@monecchi
monecchi / functions.php
Created April 1, 2016 05:57 — forked from kloon/functions.php
WooCommerce add shipping method to emails
<?php
// Place the following code in your theme's functions.php file to add the shipping method to all emails
add_action( 'woocommerce_email_after_order_table', 'wc_add_shipping_method_to_emails', 15, 2 );
function wc_add_shipping_method_to_emails( $order, $is_admin_email ) {
echo '<p><strong>Shipping Method:</strong> ' . $order->get_shipping_method() . '</p>';
}
// Place the following code in your theme's functions.php file to add the shipping methid to admin emails only
add_action( 'woocommerce_email_after_order_table', 'wc_add_shipping_method_to_admin_emails', 15, 2 );
function wc_add_shipping_method_to_admin_emails( $order, $is_admin_email ) {
@monecchi
monecchi / gist:785bba4bdc5588f9454403be067644a5
Created April 1, 2016 06:19 — forked from mikejolley/gist:1547491
WooCommerce - A filter to add a tracking (or any other field for that matter) to order emails to customers.
/* To use:
1. Add this snippet to your theme's functions.php file
2. Change the meta key names in the snippet
3. Create a custom field in the order post - e.g. key = "Tracking Code" value = abcdefg
4. When next updating the status, or during any other event which emails the user, they will see this field in their email
*/
add_filter('woocommerce_email_order_meta_keys', 'my_custom_order_meta_keys');
function my_custom_order_meta_keys( $keys ) {
$keys[] = 'Tracking Code'; // This will look for a custom field called 'Tracking Code' and add it to emails
@monecchi
monecchi / gist:e601af119317e20242ee7af7aa616c37
Created April 1, 2016 21:05 — forked from webaware/gist:6260468
WooCommerce purchase page add-to-cart with quantity and AJAX, without customising any templates. See blog post for details: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
<?php
/**
* start the customisation
*/
function custom_woo_before_shop_link() {
add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 2);
add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop');
}
add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link');
@monecchi
monecchi / woocommerce-updated-email-order-items-table.php
Created April 3, 2016 16:07 — forked from bekarice/woocommerce-updated-email-order-items-table.php
WooCommerce Order Emails: Add product images to the order email (WooCommerce 2.5+)
<?php // only copy this line if needed
/**
* Adds product images to the WooCommerce order emails table
* Uses WooCommerce 2.5 or newer
*
* @param string $output the buffered email order items content
* @param \WC_Order $order
* @return $output the updated output
*/
function sww_add_images_woocommerce_emails( $output, $order ) {
@monecchi
monecchi / functions.php
Created April 7, 2016 15:30 — forked from claudiosanches/functions.php
WooCommerce - Change product loop add to cart button
<?php
function custom_woocommerce_loop_add_to_cart_link( $html, $product ) {
return '<a href="' . get_permalink( $product->id ) . '" class="button">' . __( 'Texto do botão' ) . '</a>';
}
add_filter( 'woocommerce_loop_add_to_cart_link', 'custom_woocommerce_loop_add_to_cart_link', 10, 2 );