Skip to content

Instantly share code, notes, and snippets.

View zstepek's full-sized avatar

Zach Stepek zstepek

View GitHub Profile
@zstepek
zstepek / mindsize-product-description-et-builder.php
Created April 12, 2016 21:12
Add this code to your functions.php file to enable Divi Builder on CPTs
/********This function is used to display the pagebuilder option on the CPTs**********/
add_filter('et_builder_post_types', 'mndsz_divi_admin_display_pagebuilder');
function mndsz_divi_admin_display_pagebuilder($mndsz_post_types)
{
$mndsz_get_custom_post_types = get_post_types(array('public' => true, '_builtin' => false));
$new_post_types = array_merge($mndsz_post_types, $mndsz_get_custom_post_types);
return $new_post_types;
}
@zstepek
zstepek / change_user_role_after_purchase.php
Created May 5, 2015 17:05
Change user role after purchase is successful. Need to expand this example to include conditional processing based on products purchased.
add_action('woocommerce_thankyou', 'mindsize_change_role_on_successful_purchase');
function mindsize_change_role_on_successful_purchase($order_id ) {
$order = new WC_Order( $order_id );
$user_id = $order->user_id;
$wp_user_object = new WP_User($user_id);
if($wp_user_object->roles[0] != "administrator"){ // Do not change admin role
wp_update_user( array( 'ID' => $wp_user_object->ID, 'role' => "wholesale" ) );
}
}
@zstepek
zstepek / mightyswarm_wc_remove_product_meta.php
Last active May 7, 2024 14:42
Remove product meta (SKU, tags, etc) from WooCommerce single product pages.
/* Remove product meta */
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
@zstepek
zstepek / mindsize_wc_free_shipping_by_role.php
Last active August 29, 2015 14:19
Conditionally add free shipping to users based on their user role.
<?php
// Add free shipping for users in subscriber or administrator roles.
function mindsize_wc_conditional_free_shipping( $rates, $package ) {
get_currentuserinfo();
global $current_user;
if ($current_user->ID) {
$user_roles = $current_user->roles;
@zstepek
zstepek / mindsize_wc_product_button_text.php
Last active August 29, 2015 14:19
Change the text for the product buttons (Add To Cart, etc) on product archives and individual pages
<?php
function mindsize_wc_product_button_text() {
global $product;
$product_type = $product->product_type;
switch ( $product_type ) {
case 'external':
return __( 'EXTERNAL PRODUCT TEXT', 'woocommerce' );
@zstepek
zstepek / mindsize_gf_shop_manager.php
Last active August 29, 2015 14:19
Add the ability to view Gravity Forms entries to the Shop Manager role in WooCommerce
<?php
// Add gravity forms support for shop managers.
function mindsize_gravity_forms_shop_manager_role(){
$role = get_role('shop_manager');
// remove full access in case it was added previously
$role->remove_cap('gform_full_access');
$role->add_cap('gravityforms_view_entries');
$role->add_cap('gravityforms_edit_entries');
}