Skip to content

Instantly share code, notes, and snippets.

View woogist's full-sized avatar

WooCommerce.com Documentation woogist

View GitHub Profile
function woocommerce_template_loop_product_thumbnail() {
echo woocommerce_get_product_thumbnail( 'full' );
}
if ( current_user_can( 'manage_options' ) ) {
var_dump( get_product_vendors( $product->id ) );
}
function wcsdp_get_available_payment_gateways( $available_gateways ) {
global $wp;
if ( class_exists( 'WC_Subscriptions_Cart' ) ) {
if ( WC_Subscriptions_Cart::cart_contains_subscription() || WC_Subscriptions_Cart::cart_contains_subscription_renewal() || ( is_checkout_pay_page() && WC_Subscriptions_Order::order_contains_subscription( $wp->query_vars['order-pay'] ) ) ) {
if ( isset( $available_gateways['paypal'] ) ) {
unset( $available_gateways['paypal'] );
}
// just repeat the same thing for the next payment gateway
@woogist
woogist / gist:20efca4e0ce0af181593
Created June 12, 2015 07:44
Change Sensei single course, lesson and quiz titles.
add_filter('sensei_single_title', 'custom_single_title_prepend');
/**
* Filter the sensei single titles ( singular course, lesson and quiz )
*
* @param $title
* @return string
*/
function custom_single_title_prepend( $title ){
add_filter( 'wcopc_products_query_args', 'wc_opc_custom_query_args' );
function wc_opc_custom_query_args( $args ) {
if ( isset( $args['meta_query'][0]['value'] ) ) {
array_push( $args['meta_query'][0]['value'], 'hidden' );
}
return $args;
}
@woogist
woogist / functions.php
Created June 8, 2015 13:07
WooCommerce Product Vendors: Add extra custom fields to vendor profiles
// Add fields to new vendor form
add_action( 'shop_vendor_add_form_fields', 'custom_add_vendor_fields', 2, 1 );
function custom_add_vendor_fields( $taxonomy ) {
?>
<div class="form-field">
<label for="vendor_website"><?php _e( 'Vendor website' ); ?></label>
<input type="text" name="vendor_data[website]" id="vendor_website" class="vendor_fields" /><br/>
<span class="description"><?php _e( 'The vendor\'s website.' ); ?></span>
</div>
<?php
/**
* Check the cart for specific classes, remove UPS Shipping method if they are present
*
* REMOVE THE TOP <?php if there is no ?> before (or you have an error after adding this)
*
* Add the code to your theme functions.php file
*/
add_filter( 'woocommerce_package_rates', 'unset_ups_shipping_method' , 10, 2 );
function unset_ups_shipping_method( $rates, $package ) {
@woogist
woogist / gist:463380123de1ca534f22
Created June 8, 2015 05:58
Sensei: Allow teachers to grade all quizzes
add_filter('sensei_check_for_activity', 'sensei_allow_teachers_to_grade_all_quizzes', 5 );
function sensei_allow_teachers_to_grade_all_quizzes( $args ){
// remove the limit
remove_filter( 'sensei_check_for_activity' , array( Sensei()->teacher, 'filter_grading_activity_queries') );
// make sure to the return the expected arguments
return $args;
@woogist
woogist / gist:351c62147604dd8825d3
Created June 8, 2015 04:59
Sensei: get all the users who have completed a specific course
/**
* Get the list of users who have completed a specific course:
*/
// Course ID can be found in the URL when you edit the course
$course_id = '2607';
$activity_args = array(
'post_id' => $course_id,
'type' => 'sensei_course_status',
add_filter( 'woocommerce_prevent_admin_access', 'wc_custom_dashboard_access' );
function wc_custom_dashboard_access( $default ) {
if ( current_user_can( 'custom_retailer_capability' ) ) {
$default = false;
}
return $default;
}