Skip to content

Instantly share code, notes, and snippets.

/* WC LOGIN REDIRECT */
add_filter('woocommerce_login_redirect', 'wcs_login_redirect');
function wcs_login_redirect( $redirect ) {
$redirect = 'https://www.xxxxxxxxxxx.com/dashboard/';
return $redirect;
}
/* WC REGISTER REDIRECT */
add_filter('woocommerce_registration_redirect', 'wcs_register_redirect');
function wcs_register_redirect( $redirect ) {
$redirect = 'https://www.xxxxxxxxxxxx.com/my-account/';
@bentasm1
bentasm1 / functions.php
Created October 3, 2016 20:05
WC Vendors - Use PayPal to pay vendors, but not for taking customers $$
function wcv_bye_bye_paypalap( $available_gateways ) {
global $woocommerce;
unset( $available_gateways['paypalap'] );
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'wcv_bye_bye_paypalap' );
@bentasm1
bentasm1 / functions.php
Last active November 28, 2022 22:15
WC Vendors - Stripe Gateway & Commissions - Tell admin in user edit if vendor connected to stripe
add_action('_wcv_admin_before_store_commission', 'custom_wcv_admin_before_store_commission');
function custom_wcv_admin_before_store_commission(){
$user_id = $_GET['user_id']; // On the WordPress user edit screen, this will get the user id of the account you are currently editing.
$key = get_user_meta( $user_id, '_stripe_connect_access_key', true );
if ( empty( $key ) ) {
echo '<h2>This vendor is NOT connected to Stripe.</h2>';
} else {
echo '<h2>This vendor is connected to Stripe. Yay!</h2>';
}
}
@bentasm1
bentasm1 / gist:8cd5706b6bc6194e0ea4f5e8f487e32d
Created September 3, 2016 01:07
Warn vendors if they dont have some custom field set
/* This will warn a vendor if some magical meta key isnt set. Change it to the one you need in the code below: */
// Get the users meta key we want to check.
$the_meta_key = get_user_meta( get_current_user_id(), 'CHANGEME', true ); // CHANGE CHANGEME TO THE META KEY NAME YOU WANT TO CHECK.
// DEBUG STUFF. UNCOMMENT TO CHECK STUFF.
// echo '<pre>THE META KEY IS: ' . $the_meta_key . '</pre>';
// Check if meta key is set
if (!isset($the_meta_key)) {
@bentasm1
bentasm1 / gist:764427ca73cbda9d107838f7598f11e7
Created August 11, 2016 01:09
WooCommerce Rotate between 5 payment gateways
function filter_gateways($gateways){
global $woocommerce;
$thewinner = rand(1,5);
if ($thewinner == 1 ) {
unset($gateways['gateway2']);
unset($gateways['gateway3']);
unset($gateways['gateway4']);
unset($gateways['gateway5']);
@bentasm1
bentasm1 / functions.php
Created July 25, 2016 18:01
WC Vendors Pro - Change "Settings" on Pro Dashboard to another name
/* WC Vendors Pro - Change the Settings tab on the Pro Dashboard navigation to say "New Label" (or whatever) instead */
function custom_menu_link( $pages ) {
$pages[ 'settings' ] = array(
'slug' => 'settings',
'label' => __('New Label', 'wcvendors-pro' ),
'actions' => array()
);
return $pages;
}
@bentasm1
bentasm1 / functions.php
Created July 14, 2016 23:32
WC Vendors Pro - Use Vendor Store Icon as Yoast SEO OpenGraph
// Set Vendors Store Icon as Open Graph image on shop page
function my_opengraph_image( $img ) {
if ( WCV_Vendors::is_vendor_page() ) {
$vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
$vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
$store_icon_src = wp_get_attachment_image_src( get_user_meta( $vendor_id, '_wcv_store_icon_id', true ), 'full' );
// see if the array is valid
if ( is_array( $store_icon_src ) ) {
$img = $store_icon_src[0];
@bentasm1
bentasm1 / functions.php
Created June 29, 2016 00:51 — forked from digitalchild/functions.php
Add vendor shipping cost to cart item
<?php
// Add this to your themes function.php
add_filter( 'woocommerce_cart_item_name', 'wcv_shipping_cart_item', 1, 3 );
function wcv_shipping_cart_item( $title = null, $cart_item = null, $cart_item_key = null ) {
$settings = get_option( 'woocommerce_wcv_pro_vendor_shipping_settings' );
$customer_address = array( 'country' => WC()->customer->get_shipping_country(), 'state' => WC()->customer->get_shipping_state() );
$package = array( 'destination' => $customer_address );
@bentasm1
bentasm1 / functions.php
Created June 22, 2016 20:19
WC Vendors Pro Custom Countries List
/* WC Vendors Pro -- Provides a custom list of countries, instead of all of them. The syntax */
/* on this is pretty easy, just make sure you have the correct 2 letter country code */
/* This example will show only UK and USA and ignore all others */
add_filter('wcv_countries_list', 'custom_wcv_countries_list');
function custom_wcv_countries_list(){
$args = array(
'GB' => __( 'United Kingdom (UK)', 'wcvendors-pro' ),
'US' => __( 'United States (US)', 'wcvendors-pro' )
);
return $args;
@bentasm1
bentasm1 / functions.php
Created June 14, 2016 20:35 — forked from digitalchild/functions.php
Custom Taxonomy
<?php
// This code goes in your theme's functions.php
function form_caracteristica( $object_id ) {
WCVendors_Pro_Form_helper::select( array(
'post_id' => $object_id,
'id' => 'wcv_custom_product_caracteristicas',
'class' => 'select2',
'label' => __('Caracteristicas', 'wcvendors-pro'),
'show_option_none' => __('Select a caracteristicas', 'wcvendors-pro'),