Skip to content

Instantly share code, notes, and snippets.

@Giannisduke
Giannisduke / gist:62c504151d8eb51c47af73fdfc2ef932
Created July 25, 2016 23:46 — forked from psahalot/gist:2e2df59635ed2bdc5a08
Empty WooCommerce cart before adding new product
add_filter( 'woocommerce_add_cart_item_data', 'ps_empty_cart', 10, 3);
function ps_empty_cart( $cart_item_data, $product_id, $variation_id ) {
global $woocommerce;
$woocommerce->cart->empty_cart();
// Do nothing with the data and return
return $cart_item_data;
}
<?
/*
Wordpress + WooCommerce
Add product directly to cart and take user to Checkout page
Instructions:
- add all php code within comment block below to active Wordpress theme file: functions.php
- use URL structure: http://your-site.com/?add-to-cart=37 WHERE 37 is the ID of your WooCommerce Product
*/
@Giannisduke
Giannisduke / remove-billing.php
Created July 26, 2016 06:37 — forked from jgalea/remove-billing.php
Remove billing details from WooCommerce checkout.
<?php
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_first_name']);
unset($fields['billing']['billing_last_name']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
@Giannisduke
Giannisduke / example_upload_form.php
Created November 8, 2016 11:50 — forked from wyrfel/example_upload_form.php
WP custom post type creation form with customized file upload facility
<?php
global $user_identity;
//$user_submissions = get_posts();
if ($user = wp_get_current_user()) {
$author = array('id' => $user->ID);
} else {
$commenter = wp_get_current_commenter();
$author = array(
'author' => $commenter['comment_author'],
@Giannisduke
Giannisduke / bp-custom.php
Created December 14, 2016 05:21
Buddypress - Change text from the activity for custom post types
add_filter( 'bp_blogs_record_post_post_types', 'inspired_record_more_types' );
function inspired_record_more_types( $types ) {
$types[] = 'projects';
$types[] = 'sfwd-courses';
$types[] = 'uig_image';
return $types;
}
add_filter('bp_blogs_activity_new_post_action', 'record_cpt_activity_action', 1, 3);
function record_cpt_activity_action( $activity_action, $post, $post_permalink ) {
@Giannisduke
Giannisduke / scripts.js
Created December 29, 2016 13:00 — forked from itsonlyjames/scripts.js
Isotope layout/responsive with facetwp sorting plugin
// initially fire isotope layout
var $grid = $('.grid').isotope({
itemSelector: '.grid-item',
transitionDuration: 0,
masonry: {
columnWidth: 100
}
});
// runs isotope reload on facetwp change
facetwp_is_main_query
facetwp_ajax_response
facetwp_load_assets
facetwp_load_css
facetwp_query_args
facetwp_facet_html
facetwp_render_output
facetwp_pre_filtered_post_ids
facetwp_filtered_post_ids
facetwp_template_html
add_filter('woocommerce_checkout_fields', 'addBootstrapToCheckoutFields' );
function addBootstrapToCheckoutFields($fields) {
foreach ($fields as &$fieldset) {
foreach ($fieldset as &$field) {
// if you want to add the form-group class around the label and the input
$field['class'][] = 'form-group';
// add form-control to the actual input
$field['input_class'][] = 'form-control';
@Giannisduke
Giannisduke / 1nginx.conf
Created August 29, 2017 13:00 — forked from josephbolus/1nginx.conf
Wordpress Nginx Config
# ---------------------------------------
# Main Module
# ---------------------------------------
user nginx;
# This number should be, at maximum, the number of CPU cores on your system.
worker_processes 2;
pid /var/run/nginx.pid;
# Only log critical errors
@Giannisduke
Giannisduke / Custom Post Slider
Created October 25, 2017 08:50 — forked from jdcauley/Custom Post Slider
Wordpress Bootstrap Carousel using a custom Post
<div id="myCarousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
<li data-target="#myCarousel" data-slide-to="4"></li>
</ol>
<div class="carousel-inner">
<?php query_posts('post_type=features&showposts=1'); ?>