Skip to content

Instantly share code, notes, and snippets.

View fdeross's full-sized avatar

Frank DeRossitt fdeross

View GitHub Profile
@digitalchild
digitalchild / functions.php
Created November 19, 2020 04:22
Limit cart and checkout to a single vendor stores products in WC Vendors Marketplace and WC Vendors Pro.
<?php
// Limit checkout to a single vendor store
add_action( 'woocommerce_add_to_cart_validation', 'limit_single_vendor_to_cart', 10, 3 );
function limit_single_vendor_to_cart( $valid, $product_id, $quantity ) {
$vendor_id = get_post_field( 'post_author', $product_id );
// loop through the cart to check each vendor id
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$cart_product_id = $cart_item[ 'product_id' ];
/**
* Register term fields
*/
add_action( 'init', 'register_vendor_custom_fields' );
function register_vendor_custom_fields() {
add_action( WC_PRODUCT_VENDORS_TAXONOMY . '_add_form_fields', 'add_vendor_custom_fields' );
add_action( WC_PRODUCT_VENDORS_TAXONOMY . '_edit_form_fields', 'edit_vendor_custom_fields', 10 );
add_action( 'edited_' . WC_PRODUCT_VENDORS_TAXONOMY, 'save_vendor_custom_fields' );
add_action( 'created_' . WC_PRODUCT_VENDORS_TAXONOMY, 'save_vendor_custom_fields' );
}
@svallory
svallory / Deploying Sharetribe to Heroku.md
Last active August 12, 2023 21:09
Deploying Sharetribe to Heroku

Deploying to Heroku

  1. Deploy the app to heroku following heroku normal instructions (add link to heroku help)

  2. Set heroku environment variables

    Make sure all the options in config.yml are properly set then run:

     bundle exec rake heroku:config