Skip to content

Instantly share code, notes, and snippets.

@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 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'),
@bentasm1
bentasm1 / functions.php
Last active March 9, 2020 06:22
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;
}
@bentasm1
bentasm1 / functions.php
Created June 14, 2016 00:07 — forked from digitalchild/functions.php
Force stock qty to 1 with no backorders
<?php
add_action( 'wcv_save_product_meta', 'wcv_custom_stock_opts' );
function wcv_custom_stock_opts( $post_id ) {
update_post_meta( $post_id, '_manage_stock', 'yes' );
update_post_meta( $post_id, '_backorders', 'no' );
wc_update_product_stock( $post_id, wc_stock_amount( 1 ) );
}
@bentasm1
bentasm1 / functions.php
Last active December 1, 2017 01:23 — forked from digitalchild/functions.php
WC Vendors Pro - Add new tabs to Pro Dashboard Navigation
/* WC Vendors Pro - Add some new page links to the Pro Dashboard */
function new_dashboard_pages( $pages ){
$pages[] = array( 'label' => 'New Link', 'slug' => 'http://mysomelink.com' ); // Add stuff here
return $pages;
}
add_filter( 'wcv_pro_dashboard_urls', 'new_dashboard_pages' );
@bentasm1
bentasm1 / functions.php
Created May 11, 2016 21:50 — forked from digitalchild/functions.php
WC Vendors Pro - Remove shipping panel from single product page
/* WC Vendors Pro - Remove shipping panel from single product page */
remove_action( 'woocommerce_product_tabs', array( $wcvendors_pro->wcvendors_pro_shipping_controller, 'shipping_panel_tab'), 11, 2 );
remove_action( 'woocommerce_product_meta_start', array( $wcvendors_pro->wcvendors_pro_vendor_controller, 'product_ships_from'), 9 );
@bentasm1
bentasm1 / functions.php
Last active April 26, 2016 15:37 — forked from ptrsmk/filter-gateways.php
WC Vendors - Removes paypalap on checkout page if vendor hasnt entered their PayPal email on their Dashboard.
/* WC Vendors - Looks at the cart and, if something in the cart is sold by a vendor who hasn’t saved
* his PayPal account address in his Dashboard>Settings>Payment area, then the PayPal AP gateway included
* with WC Vendors is removed from the list of available gateways at checkout.
* Props to @dvrcthewrld for the code
*/
function ps_filter_gateways($gateways) {
if ( is_checkout_pay_page() ) {
global $wp;
if ( isset( $wp->query_vars['order-pay'] ) ) {
@bentasm1
bentasm1 / functions.php
Created April 16, 2016 02:04 — forked from digitalchild/functions.php
Insert View my store in menu
<?php
// Hijack vendor menu to insert view store link.
function wcv_store_menu_link( $items, $args ) {
if ( WCV_Vendors::is_vendor( get_current_user_id() ) ) {
// Only insert the link in the menu you want based on the menu slug you define below.
// In this example a menu has been created called 'Vendor Menu' that has the menu slug vendor-menu
// This link will be the last link in the vendor menu
@bentasm1
bentasm1 / functions.php
Last active September 3, 2016 04:17 — forked from digitalchild/functions.php
WC Vendors Pro - Add another file uploader to the add/edit product form
/* WC Vendors Pro - Add another file uploader to upload a file with the ID in a meta key */
function custom_wcv_file_uploader( ){
$value = get_user_meta( get_current_user_id(), 'wcv_custom_product_file1', true ); // Must match meta key used in line 8
WCVendors_Pro_Form_Helper::file_uploader( array(
'header_text' => __('File uploader', 'wcvendors-pro' ),
'add_text' => __('Add file', 'wcvendors-pro' ),
'remove_text' => __('Remove file', 'wcvendors-pro' ),
'image_meta_key' => 'wcv_custom_product_file1', // Must match meta key used in line 3
'save_button' => __('Add file', 'wcvendors-pro' ),
'window_title' => __('Select an Image', 'wcvendors-pro' ),
@bentasm1
bentasm1 / functions.php
Created March 16, 2016 05:10 — forked from digitalchild/functions.php
WCV Pro vendor list pagination customisation
<?php
// WC Vendors Pro vendors list uses the same layout as the default woocommerce pagination
// IF your theme is overriding the layout of the pagination links then you can use the following snippets (modified for your theme)
// to make the vendor list pagination links wrap with your theme wrappers and styles.
// Pagination wrapper opening tag
add_filter( 'wcv_pagination_before', 'wcv_pagination_before_wrapper' );
function wcv_pagination_before_wrapper( $html ) {
return '<div class="somethign else">';