Skip to content

Instantly share code, notes, and snippets.

View DanielSantoro's full-sized avatar

Danny Santoro DanielSantoro

View GitHub Profile
@DanielSantoro
DanielSantoro / ajaxify-cart.php
Last active November 22, 2022 13:34
AJAX Update Cart thats added to Template File Manually (
// Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php).
// Used in conjunction with https://gist.github.com/DanielSantoro/1d0dc206e242239624eb71b2636ab148
// Compatible with WooCommerce 3.0+. Thanks to Alex for assisting with an update!
function woocommerce_header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
?>
@DanielSantoro
DanielSantoro / codesnippet.php
Last active December 22, 2017 17:12
Show Number of items in Cart and Subtotal (insert into template)
// Use in conjunction with https://gist.github.com/DanielSantoro/948c5000850c4695f30db8542f8bc966
<a class="cart-customlocation" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf ( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
@DanielSantoro
DanielSantoro / array.php
Created December 21, 2016 14:56
Advanced Notifications Array
<?php
// For formatting, this is just a segment of the file found in
// `woocommerce-shipment-tracking/includes/class-wc-shipment-tracking.php` Line 68 - 163
/**
* Get shiping providers.
*
* @return array
*/
public function get_providers() {
@DanielSantoro
DanielSantoro / functions.php
Created December 20, 2016 14:51
Ajax Variation Limit
<?php // Do not include this line - only for formatting purposes
add_filter( 'woocommerce_ajax_variation_threshold', function() { return 50; } );
@DanielSantoro
DanielSantoro / functions.php
Last active December 20, 2016 14:09
Auto Complete Virtual Orders
<?php // Do not copy this line - start at Line 3
// Auto-Complete Virtual Orders
add_filter( 'woocommerce_payment_complete_order_status', 'bryce_autocomplete_virtual_orders', 10, 2 );
function bryce_autocomplete_virtual_orders( $order_status, $order_id ) {
$order = wc_get_order( $order_id );
if ('processing' == $order_status && ('on-hold' == $order->status || 'pending' == $order->status || 'failed' == $order->status)) {
$virtual_order = '';
@DanielSantoro
DanielSantoro / code.php
Created December 9, 2016 14:42
WC Order Delivery Date Switch
<?php // Do not copy this line into your code unless you're making a custom plugin for this purpose specifically.
public function init() {
$this->date_format = _x( 'd-m-Y', 'date format for php', 'woocommerce-order-delivery' );
$this->date_format_js = _x( 'dd-mm-yyyy', 'date format for js', 'woocommerce-order-delivery' );
@DanielSantoro
DanielSantoro / class-wc-validation.php
Created December 7, 2016 17:00
Postcode Validation
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Contains Validation functions
*
* @class WC_Validation
@DanielSantoro
DanielSantoro / functions.php
Created December 4, 2016 18:58
Add Tracking Pixel to Thank You Page
<?php
/**
* Add Tracking Code to the Thank You Page - http://danielsantoro.com/add-facebook-tracking-pixel-woocommerce-checkout/
*/
function ds_checkout_analytics( $order_id ) {
$order = new WC_Order( $order_id );
$currency = $order->get_order_currency();
$total = $order->get_total();
$date = $order->order_date;
?>
@DanielSantoro
DanielSantoro / form-shipping.php
Created November 30, 2016 18:20
Shipping Form
<?php
/**
* Checkout shipping information form
*
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-shipping.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@DanielSantoro
DanielSantoro / text.html
Created November 22, 2016 19:01
Sample Landing Page with Multiple Products
<iframe src="https://www.youtube.com/embed/BEMlvjJ9uxo?rel=0" width="640" height="360" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
WHAT UP?!
Are you ready for the best idea ever? Do you have money? Do you want even more money? Well guess what? We've got a great idea for you?
<strong>FIGHT MILK!</strong>
The first alcoholic dairy-based protein drink for bodyguards, by bodyguards.
<blockquote>I drink it every morning so I can fight, like a crow!</blockquote>