Skip to content

Instantly share code, notes, and snippets.

@BFTrick
Last active November 15, 2024 15:52
Show Gist options
  • Save BFTrick/7137572 to your computer and use it in GitHub Desktop.
Save BFTrick/7137572 to your computer and use it in GitHub Desktop.

Revisions

  1. BFTrick revised this gist Nov 23, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions woocommerce-force-sell-only-one-product.php
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,8 @@ function my_wc_force_sell_add_to_cart_product( $product ){
    }
    add_filter( 'wc_force_sell_add_to_cart_product', 'my_wc_force_sell_add_to_cart_product' );

    // when a synced force sell product is updated always set it to 2
    // when a synced force sell product is updated always set it to 1
    function my_wc_force_sell_update_quantity( $quantity, $product ){
    return 2;
    return 1;
    }
    add_filter( 'wc_force_sell_update_quantity', 'my_wc_force_sell_update_quantity' );
  2. BFTrick revised this gist Nov 23, 2013. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion woocommerce-force-sell-only-one-product.php
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@
    <?php
    // only add one force sell product to the cart no matter how many of the original product are added
    function my_wc_force_sell_add_to_cart_product( $product ){
    $product['quantity'] = 1;
  3. BFTrick revised this gist Oct 24, 2013. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion woocommerce-force-sell-only-one-product.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,13 @@
    <?php
    // only add one force sell product to the cart no matter how many of the original product are added
    function my_wc_force_sell_add_to_cart_product( $product ){
    $product['quantity'] = 1;
    return $product;
    }
    add_filter( 'wc_force_sell_add_to_cart_product', 'my_wc_force_sell_add_to_cart_product' );
    add_filter( 'wc_force_sell_add_to_cart_product', 'my_wc_force_sell_add_to_cart_product' );

    // when a synced force sell product is updated always set it to 2
    function my_wc_force_sell_update_quantity( $quantity, $product ){
    return 2;
    }
    add_filter( 'wc_force_sell_update_quantity', 'my_wc_force_sell_update_quantity' );
  4. BFTrick created this gist Oct 24, 2013.
    6 changes: 6 additions & 0 deletions woocommerce-force-sell-only-one-product.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    <?php
    function my_wc_force_sell_add_to_cart_product( $product ){
    $product['quantity'] = 1;
    return $product;
    }
    add_filter( 'wc_force_sell_add_to_cart_product', 'my_wc_force_sell_add_to_cart_product' );