Skip to content

Instantly share code, notes, and snippets.

View fervous's full-sized avatar

Anna fervous

View GitHub Profile
@fervous
fervous / product-edit.php
Last active January 11, 2017 00:39 — forked from digitalchild/product-edit.php
WC Vendors Pro Replace text areas with wp editor on product edit form
/* Modify the product-edit.php template.. replace the lines between Product Title and ending with the DIV after Product Categories with THIS CODE. */
<div class="wcv-product-basic wcv-product">
<!-- Product Title -->
<?php WCVendors_Pro_Product_Form::title( $object_id, $product_title ); ?>
<!-- Product Description Editor -->
<label>Product Description</label>
<?php
$editor_args = array(
'editor_height' => 300,
'media_buttons' => false,
@fervous
fervous / functions.php
Created October 25, 2016 16:03 — forked from digitalchild/functions.php
Remove required
<?php
/* WC Vendors Pro - Make Description Required */
function wcv_product_description_required( $args ) {
$args[ 'custom_attributes' ] = array(
'data-rules' => 'required', // Change 'required' to '' to make it not required (just remove the word required but keep the single quotes)
'data-error' => __( 'This field is required.', 'wcvendors-pro' )
);
return $args;
}
@fervous
fervous / gist:0461b03980a285da7cabdcde3158129e
Created October 18, 2016 22:58 — forked from digitalchild/gist:5ff5bf34571a4adef995
Add a WC Vendors Tab to the Buddy Press profile
<?php
// This snippet will add an extra tab to the buddy press user profile that can call any shortcode defined in WC Vendors.
// This code should be inserted into your bp-custom.php file.
function my_bp_nav_adder() {
if (class_exists('WC_Vendors')) {
$wcv_profile_id = bp_displayed_user_id();
$wcv_profile_info = get_userdata( bp_displayed_user_id() );
@fervous
fervous / functions.php
Created October 18, 2016 22:35 — forked from bentasm1/functions.php
WC Vendors Pro -- Require a minimum, and a maximum price for vendors when adding/editing a product
/* WC Vendors Pro -- Require a minimum, and a maximum price for vendors when adding/editing a product */
add_filter( 'wcv_product_price', 'price_min_max' );
function price_min_max( $args ){
$args[ 'custom_attributes' ] = array(
'data-rules' => 'decimal|range[1,20]',
'data-error' => __( 'Price should be a number and between $1 and $20', 'wcvendors-pro' )
);
return $args;
}
@fervous
fervous / archive-product.php
Created October 13, 2016 14:56 — forked from bentasm1/archive-product.php
For archive-product.php and specific vendor info
<?php
/* This goes somewhere in your archive-product.php template. This will check if the URL they are on is a vendor store,
* and if it is, do something, if it isn't, do something else. Writhing the somethings is up to you. :)
*/
$vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
$vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
if ( $vendor_id ) {
// Do something
} elseif {
@fervous
fervous / functions.php
Created October 1, 2016 14:39 — forked from digitalchild/functions.php
Remove product tabs
<?php
// Add this to your themes functions.php
// Remove product tabs on the product-edit form.
add_filter( 'wcv_product_meta_tabs', 'remove_product_tabs' );
function remove_product_tabs( $tabs ){
unset( $tabs['general'] );
unset( $tabs['attributes' ] );
@fervous
fervous / functions.php
Created September 27, 2016 03:48 — forked from digitalchild/functions.php
Google Analytics Code for Vendors
<?php
// Place this code in your themes functions.php
// Add google analytics code to vendor pages for tracking
function wcv_shop_name_google_analytics() {
if ( is_singular( 'product') ){
$product = get_queried_object();
if ( WCV_Vendors::is_vendor_product_page( $product->post_author ) ) {
@fervous
fervous / functions.php
Created September 24, 2016 21:52 — forked from digitalchild/functions.php
Update shipping method label if cost is 0
<?php
// Restore the (Free) label on the cart and checkout pages
add_filter( 'woocommerce_cart_shipping_method_full_label' , 'add_free_shipping_label', 10, 2 );
function add_free_shipping_label( $label, $method ){
if ( $method->cost == 0 ){
$label = $method->label . ' ' . __( '(Free)', 'onesocial' );
}
@fervous
fervous / functions.php
Last active October 22, 2016 04:09 — forked from digitalchild/functions.php
Change WC Vendors Pro Dashboard navigation labels
// Put this code in your theme or child theme functions.php
// Rename the main dashboard tab labels
function change_dashboard_labels( $dashboard_urls ){
// Products
if ( array_key_exists('product', $dashboard_urls ) ) $dashboard_urls[ 'product' ][ 'label' ] = 'Mah Products';
// Orders
if ( array_key_exists('order', $dashboard_urls ) )$dashboard_urls[ 'order' ][ 'label' ] = 'Mah Orders';
// Settings
if ( array_key_exists('settings', $dashboard_urls ) )$dashboard_urls[ 'settings' ][ 'label' ] = 'Mah Settings';
@fervous
fervous / functions.php
Created September 24, 2016 21:49 — forked from digitalchild/functions.php
WC Vendors Add Billing phone to orders table
<?php
// Add billing phone to orders table
function add_billing_phone( $order_rows ){
foreach ( $order_rows as $key => $row ) {
$_order = new WC_Order( $row->ID );
$row->customer = $_order->get_formatted_shipping_address() .'<br />'. $_order->billing_email .'<br />' . $_order->billing_phone;
}