Forums / All Other Contributions/Addons / Twitch Wholesale with Twitch Wholesale Attributes

Twitch Wholesale with Twitch Wholesale Attributes

Views: 27,872

Results 1 to 20 of 164
3 Nov 2013, 5:41 AM
#1
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Twitch Wholesale with Twitch Wholesale Attributes

**Twitch Wholesale with Twitch Wholesale Attributes
for ZenCart v1.51 - **Version 13a
October 13.2013

This module will provide you with:

  • guest/retail/wholesale login and independent landing/index pages for each
  • wholesale filters for product pricing, attribute pricing and display purposes
  • base price, list price, core charges (as attributes)
  • wholesale prices that calculate properly with - 'product priced by attribute' and 'included in base price'
  • wholesale filters are available for payment and shipping

How it works?
ZenCart has a flow, start to finish. You start as a guest, then sign up, then log in, shop and exit.

Without changing that flow, this module simply filters the display if you have a '1' beside your name.

  • The 'if customers_wholesale switch absolutely equals 1' statements are the filters.
  • Wholesale variables have _w added to them like product_price and product_price_w.
  • This module does not change how any part of the cart works, it simply mirrors what already does work.

Important Notes:
This module has been coded as a 'price plus' addon, discount pricing/group pricing is not included in the wholesale filters.

  • Yes it is possible to add the filters in.

Visit twitchtoo.com, click the ZenCart link, find this module in the list and view the final output screenshots.

Installing this module...
Twitch Base_Cost - optional
Twitch List_Price - optional
Twitch Wholesale
Twitch Wholesale Attributes

I would recommend installing all of the modules, chances are you'll need/use the other features in the future.

Background
Around 2011 I developed this module for ZenCart 1.39h, it's been working flawlessly ever since. Unfortunately a divorce got in the way of releasing a full version with instructions. So I spent the last 6 weeks rewriting it from scratch for ZenCart 1.51, testing the new version and recording each step along the way.

The resulting module is the baseline split for wholesale/retail that should come in every stock ZenCart 1.51.

See this module it in action!
http://www.twitchparts.com/

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

29 Nov 2013, 11:51 AM
#2
100asa avatar

100asa

Totally Zenned

Join Date:
Oct 2006
Location:
Italy
Posts:
636
Plugin Contributions:
0

Re: Twitch Wholesale with Twitch Wholesale Attributes

Very great works!
One suggestion: if special price is < wholesale price, wholesaler see and buy at special price; if special price is > wholesales price, wholesaler see and buy at whole price!
Or (better) wholesaler can't see special retail prices!
I've just installed your great contrib, and special price is always show, also by wholesaler.

29 Nov 2013, 3:08 PM
#3
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Wholesale with Twitch Wholesale Attributes

Thanks 100asa.

Please clearly define what you are calling the 'special price'.

When installed correctly guests can see the 'retail price', logged in retail customers see the same 'retail price' and if a wholesale customer logs in they will see the 'wholesale price'. The 'list price' will be seen by all customers regardless. The 'base price' is only viewable in admin.

As mentioned, this module has not been coded to filter any 'discount pricing' modules... but it's on the way :)

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

29 Nov 2013, 4:10 PM
#5
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Wholesale with Twitch Wholesale Attributes

Thanks for the screenshot 100asa.

Your example uses ZenCart's default in Admin->Catalog->Specials
It applies a 'special price' to individual products.

Here's the filter you will need to hide the 'special price' entirely from wholesale customers:
**includes/functions/functions_prices.php **
replace line 25 - 31:

    $specials = $db->Execute("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and status='1'");
    if ($specials->RecordCount() > 0) {
//      if ($product->fields['products_priced_by_attribute'] == 1) {
        $special_price = $specials->fields['specials_new_products_price'];
    } else {
      $special_price = false;
    }

with this:

// bof Twitch Wholesale - Hide ZC Special Price from wholesale customer
if ($_SESSION['customers_wholesale']=='1') {
// Do not show wholesale customers the special price on any product
} else {

     $specials = $db->Execute("select specials_new_products_price from " .  TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and  status='1'");
    if ($specials->RecordCount() > 0) {
//      if ($product->fields['products_priced_by_attribute'] == 1) {
        $special_price = $specials->fields['specials_new_products_price'];
    } else {
      $special_price = false;
    }
}
// eof Twitch Wholesale - Hide ZC Special Price from wholesale customer

Here's the before and after image tested on ZenCart v1.51 with Twitch Wholesale + Attributes installed:
Attachment 13426

Guests and Retail Customers will see the 'special price' as usual. There are no changes to the Admin.

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

29 Nov 2013, 4:26 PM
#6
100asa avatar

100asa

Totally Zenned

Join Date:
Oct 2006
Location:
Italy
Posts:
636
Plugin Contributions:
0

Re: Twitch Wholesale with Twitch Wholesale Attributes

Great, great, great: simply great!
Attachment 13427

1 Dec 2013, 5:04 PM
#7
100asa avatar

100asa

Totally Zenned

Join Date:
Oct 2006
Location:
Italy
Posts:
636
Plugin Contributions:
0

Re: Twitch Wholesale with Twitch Wholesale Attributes

a little bugs:
Attachment 13432
as you can see, for wholesale the price in product info page is right; but in the option the price is the retail price!
(euro 3 is wholesale price, and 4.96 is the retail price)

1 Dec 2013, 6:18 PM
#8
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Wholesale with Twitch Wholesale Attributes

Assuming you're populating a stock ZenCart v1.51 - See the attached image for reference...

Attachment 13433

Step 1 - Admin-> Product Page

Step 2 - Live Site -> Product Page

Step 3 - Admin -> Attribute Controller

Notes:

  • The 'Wholesale Price' at the top of the product page - step 1 is not related to the options values by default.

  • Assuming you added option names/values in the manner shown in step 3, you can see the wholesale values are displaying correctly on the live product page - step 2 when the module is properly installed.

Check that you have correctly uploaded includes/functions/functions_prices.php

My guess would be one of the filters is missing... look for 'options_values_price_w' around line 131 (in the query), also line 141-147 and there's another at line 1099-1115.

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

1 Dec 2013, 6:44 PM
#9
100asa avatar

100asa

Totally Zenned

Join Date:
Oct 2006
Location:
Italy
Posts:
636
Plugin Contributions:
0

Re: Twitch Wholesale with Twitch Wholesale Attributes

NOw I've setup my product so show in my admin:
Attachment 13434Attachment 13435
and always show the retail price also with wholesale account
http://www.100asa.it/index.php?main_page=product_info&cPath=130_85_87&products_id=1393
about line 145...

// do not select display only attributes and attributes_price_base_included is true
      $product_att_query = $db->Execute("select options_id, price_prefix, options_values_price, options_values_price_w, attributes_display_only, attributes_price_base_included, round(concat(price_prefix, options_values_price), 5) as value from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and attributes_display_only != '1' and attributes_price_base_included='1'". " order by options_id, value");

and other

/ bof Twitch Wholesale Attributes - this filters the wholesale price for the attribute - display on product_info page
if ($_SESSION['customers_wholesale']=='1') {
            $the_base_price += (($product_att_query->fields['price_prefix'] == '-') ? -1 : 1) * $product_att_query->fields['options_values_price_w'];			
} else {
            $the_base_price += (($product_att_query->fields['price_prefix'] == '-') ? -1 : 1) * $product_att_query->fields['options_values_price'];
}
// eof Twitch Wholesale Attributes

and

// bof Twitch Wholesale Attributes - filter the attributes price for wholesale
if ($_SESSION['customers_wholesale']=='1') {
    // normal attributes price
    if ($pre_selected->fields["price_prefix"] == '-') {
      $attributes_price_final -= $pre_selected->fields["options_values_price_w"];
    } else {
      $attributes_price_final += $pre_selected->fields["options_values_price_w"];
    }
} else {
    // normal attributes price
    if ($pre_selected->fields["price_prefix"] == '-') {
      $attributes_price_final -= $pre_selected->fields["options_values_price"];
    } else {
      $attributes_price_final += $pre_selected->fields["options_values_price"];
    }
}
// eof Twitch Wholesale Attributes
1 Dec 2013, 7:12 PM
#10
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Wholesale with Twitch Wholesale Attributes

I just removed the wholesale filters at line 1099-1115 and immediately recreated the problem you are having see here:
Attachment 13436

add the default code back in (be sure the old code is remmed out - line 1093-1098)

/*  // normal attributes price
    if ($pre_selected->fields["price_prefix"] == '-') {
      $attributes_price_final -= $pre_selected->fields["options_values_price"];
    } else {
      $attributes_price_final += $pre_selected->fields["options_values_price"];
    } */
// bof Twitch Wholesale Attributes - filter the attributes price for wholesale
if ($_SESSION['customers_wholesale']=='1') {
    // normal attributes price
    if ($pre_selected->fields["price_prefix"] == '-') {
      $attributes_price_final -= $pre_selected->fields["options_values_price_w"];
    } else {
      $attributes_price_final += $pre_selected->fields["options_values_price_w"];
    }
} else {
    // normal attributes price
    if ($pre_selected->fields["price_prefix"] == '-') {
      $attributes_price_final -= $pre_selected->fields["options_values_price"];
    } else {
      $attributes_price_final += $pre_selected->fields["options_values_price"];
    }
}
// eof Twitch Wholesale Attributes

and you'll see this:
Attachment 13437

Be sure the files are uploading correctly to your server.

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

1 Dec 2013, 9:44 PM
#11
100asa avatar

100asa

Totally Zenned

Join Date:
Oct 2006
Location:
Italy
Posts:
636
Plugin Contributions:
0

Re: Twitch Wholesale with Twitch Wholesale Attributes

Sorry, I've made much test, and your script works fine!
The problem is mine: I've imported my products and attributes from previous db (previous zencart store). This is the issue. Is there a solutio?

2 Dec 2013, 12:59 AM
#12
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Wholesale with Twitch Wholesale Attributes

Yes I can help, check your PM. I'll post a report once I find a solution to your issue.

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

2 Dec 2013, 1:00 PM
#13
100asa avatar

100asa

Totally Zenned

Join Date:
Oct 2006
Location:
Italy
Posts:
636
Plugin Contributions:
0

Re: Twitch Wholesale with Twitch Wholesale Attributes

SOLVED!
in my db the attributes was not ticked default,gratis,discount, so don't work with your great scripts!
Another question: why into email confirmation see the option as +$...
can I change the $ symbol in euro and delete the +?
Thank you

5 Dec 2013, 12:08 PM
#14
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Wholesale with Twitch Wholesale Attributes

Thanks for the update 100asa, I'm glad it's working.

Although your second question isn't directly related to the topic of this forum, the code you are looking for happens to be in one of the files I've provided in this module.
includes/classes/order.php around line 902...

//          $this->products_ordered_attributes .= "\n\t" . $attributes_values->fields['products_options_name'] . ' ' . zen_decode_specialchars($this->products[$i]['attributes'][$j]['value']);
// bof Twitch Wholesale Attributes - this filters the wholesale attributes price correctly
 if ($_SESSION['customers_wholesale']=='1') {
          $this->products_ordered_attributes .= "\n\t" . $attributes_values->fields['products_options_name'] . ' ' . zen_decode_specialchars($this->products[$i]['attributes'][$j]['value']) . ' (+$' . number_format($attributes_values->fields['options_values_price_w'],2) * $this->products[$i]['qty'] . ')';
// Twitch this sets the output value to two decimal places, adds a $ symbol and multiplies the displayed price of the core charge by the product quantity
} else {
          $this->products_ordered_attributes .= "\n\t" . $attributes_values->fields['products_options_name'] . ' ' . zen_decode_specialchars($this->products[$i]['attributes'][$j]['value']) . ' (+$' . number_format($attributes_values->fields['options_values_price'],2) * $this->products[$i]['qty'] . ')';
// Twitch this sets the output value to two decimal places, adds a $ symbol and multiplies the displayed price of the core charge by the product quantity
}
// eof Twitch Wholesale Attributes

Notice the +$ was added statically, instead of using the global $currency variables. Be sure to change it for both retail and wholesale listed above.

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

5 Dec 2013, 1:37 PM
#15
100asa avatar

100asa

Totally Zenned

Join Date:
Oct 2006
Location:
Italy
Posts:
636
Plugin Contributions:
0

Re: Twitch Wholesale with Twitch Wholesale Attributes

Great! Thank you so much!

11 Dec 2013, 4:10 PM
#16
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Wholesale with Twitch Wholesale Attributes

Minor update to one of the Bonus Features offered in Twitch Wholesale Attributes.

Let's change the general 'Attributes Controller' button into a direct link to the actual product where you can add attributes, or update what's already there in one click.

The Old:
*** Bonus Feature - Admin - Attributes Controller Button ***

Lets add a shortcut button to the attributes_controller on the product listing page, and the product page!
admin/includes/modules/category_product_listing.php

<tr><td> <a href="<?php echo zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, '', 'NONSSL') ?>"><?php echo zen_image_button('button_edit_attribs.gif', IMAGE_EDIT_ATTRIBUTES); ?></a>   </td></tr>

admin/includes/modules/product/collect_info.php
<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_radio_field('products_priced_by_attribute', '1', $is_products_priced_by_attribute) . ' ' . TEXT_PRODUCT_IS_PRICED_BY_ATTRIBUTE . '  ' . zen_draw_radio_field('products_priced_by_attribute', '0', $not_products_priced_by_attribute) . ' ' . TEXT_PRODUCT_NOT_PRICED_BY_ATTRIBUTE . ' ' . ($pInfo->products_priced_by_attribute == 1 ? '<span class="errorText">' . TEXT_PRODUCTS_PRICED_BY_ATTRIBUTES_EDIT . '</span>' : ''); ?>   <a href="<?php echo zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, '', 'NONSSL') ?>"><?php echo zen_image_button('button_edit_attribs.gif', IMAGE_EDIT_ATTRIBUTES); ?></a>  </td>

*** Bonus Feature - Admin - Attributes Controller Button ***

The New:
*** Bonus Feature - Admin - Attributes Controller Button ***

Lets add a shortcut button to the attributes_controller on the product listing page, and the product page!
admin/includes/modules/category_product_listing.php

<tr><td> <a href="<?php echo zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, '', 'NONSSL') ?>"><?php echo zen_image_button('button_edit_attribs.gif', IMAGE_EDIT_ATTRIBUTES); ?></a>   </td></tr>

admin/includes/modules/product/collect_info.php
<td class="main"><?php echo TEXT_PRODUCTS_PRICED_BY_ATTRIBUTES; ?></td>
<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_radio_field('products_priced_by_attribute', '1', $is_products_priced_by_attribute) . ' ' . TEXT_PRODUCT_IS_PRICED_BY_ATTRIBUTE . '  ' . zen_draw_radio_field('products_priced_by_attribute', '0', $not_products_priced_by_attribute) . ' ' . TEXT_PRODUCT_NOT_PRICED_BY_ATTRIBUTE . ' ' . ($pInfo->products_priced_by_attribute == 1 ? '<span class="errorText">' . TEXT_PRODUCTS_PRICED_BY_ATTRIBUTES_EDIT . '</span>' : ''); ?>
 

<?php echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $pInfo->products_id . '&current_category_id=' . $current_category_id) . '">' . ' Edit '. zen_image(DIR_WS_IMAGES . 'icon_attributes.gif', ICON_ATTRIBUTES) . ' Attribute </a>'; ?>
        </td>
      </tr>

*** Bonus Feature - Admin - Attributes Controller Button ***

This feature was NOT added to the original plugin .zip files it was only written into twitch_wholesale_attributes_install_instructions.txt

It will be included in future versions as it's a necessity for anyone trying to manage many products.

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

8 Jan 2014, 1:50 PM
#17
100asa avatar

100asa

Totally Zenned

Join Date:
Oct 2006
Location:
Italy
Posts:
636
Plugin Contributions:
0

Re: Twitch Wholesale with Twitch Wholesale Attributes

How to solve?
Attachment 13647
price for quantity is greater than single whole price

8 Jan 2014, 2:30 PM
#18
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Wholesale with Twitch Wholesale Attributes

As of Jan 8th 2014 - The wholesale filter has yet to be coded to work with quantity discounts.

To do this I'll need to know what combination of prices are you attempting to show here:

1 - Regular Products - Retail Prices @ Quantity Discount

2 - Regular Products with Attributes - Retail Prices @ Quantity Discount - Priced by Attribute

3 - Regular Products - Wholesale Prices @ Quantity Discount

4 - Regular Products with Attributes - Wholesale Prices @ Quantity Discount - Priced by Attribute

5 - Other combination?

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

8 Jan 2014, 3:49 PM
#19
100asa avatar

100asa

Totally Zenned

Join Date:
Oct 2006
Location:
Italy
Posts:
636
Plugin Contributions:
0

Re: Twitch Wholesale with Twitch Wholesale Attributes

For now I've solved add quantity discount in %, and discount is show correctly as for retailt as for wholesale
I think use the 1 and 3 combination.

21 Jan 2014, 2:19 PM
#20
100asa avatar

100asa

Totally Zenned

Join Date:
Oct 2006
Location:
Italy
Posts:
636
Plugin Contributions:
0

Re: Twitch Wholesale with Twitch Wholesale Attributes

Is it possible do not allow quantity discount for whole?
ps: is it possible that twich wholesale addons have modify special end date calendar, so it don't work for me into chrome and firefox browser, but only into IE?