Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thank you so much for making this plugin available. A couple of suggestions. #2

Closed
johnzhel opened this issue Aug 2, 2016 · 11 comments
Assignees
Milestone

Comments

@johnzhel
Copy link

johnzhel commented Aug 2, 2016

@stuartduff I have been looking for this days and nights. Thank you for creating it! I have a couple of suggestions:

  1. for the last quantity rule, usually it is from **** (a number) To quantity blank (infinity ). Right now, if I leave the "To" quantity "blank" in the back-end, it shows 0 on the front end
  2. It would be great if this can display multiple tables for each variation of the variable product quantity based discounts.

Such as:

Blue+Large Variation
.... Price Table here....

Blue+Small Variation
.... Price Table here....

Green+Large Variation
.... Price Table here....

etc.

Thanks again!

@stuartduff
Copy link
Owner

stuartduff commented Aug 4, 2016

HI Johnzhel,

Great to hear that his helped you out with displaying discounts.

for the last quantity rule, usually it is from **** (a number) To quantity blank (infinity ). Right now, if I leave the "To" quantity "blank" in the back-end, it shows 0 on the front end.

I will take a look and resolve this as the output checks for an integer so only numbers can be entered and displays a 0 if blank.

It would be great if this can display multiple tables for each variation of the variable product quantity based discounts.

It's not something that I would add at the moment with the way the discounts function as when you have more than a single advanced product discount on an individual product it becomes extremely complex to display discounts.

I'm on holiday at the moment and will resolve the 0 issue next week. ;)

@johnzhel
Copy link
Author

johnzhel commented Aug 7, 2016

@stuartduff Thank you for your reply. I had some other issues with the site, so I deleted everything including WordPress (it is a new site). Then I reinstalled WordPress and all the plugins. Now the dynamic pricing table does not show up any more for the new installation. I checked the source code of the product page, the table code was not found in between the "in stock" line and "Add to card" line. In other words, these is not "dynamic-pricing-table" showing up in the page raw html code. Current WordPress is Version 4.5.3, WooCommerce is Version 2.6.4, Woo Dynamic Pricing is Version 2.11.5. I don't remember what were on the last installation that actually had the pricing table working well (which was installed 2 weeks ago).

It seems for the latest installation, the pricing table was not injected into the product page. I checked the dynamic pricing of that product, it did work well (I could see the discount applied in the cart). Now, I need to make the pricing table show up on the product page. Do you know where should I look or check?

Thanks!

@johnzhel
Copy link
Author

I tried a couple of things just to verify if this is caused by other themes/plugins.

  1. Switched to the standard "WooCommerce Storefront Theme ". The pricing table didn't show up.
  2. Turned off all other plugins and only activated 3 plugins. The pricing table didn't show up.

@stuartduff
Copy link
Owner

Hey @johnzhel

Cross testing for you the pricing table is displaying without any issues on my test sites, it could maybe be related to a theme you are using though if it overrides default WooCommerce template files.

Try testing on your site with a free theme like Storefront installed and activated and all other plugins deactivated.

For the issue related to the 0 displaying this is due to validating the output as it must be a number so instead of leaving the field blank add a maximum number like 9999 or similar.

Cheers

@joshuaPSmith
Copy link

I am also have trouble with 0 being inputed on the front end when I leave something blank. Right now I need to be able to set my last rule as a minimum only (ex. 576 - infinity)

@SturmB
Copy link

SturmB commented Aug 23, 2016

I forked @stuartduff's original code made a few slight improvements to it, including having that last 0 replaced with " or more": https://github.com/SturmB/woocommerce-dynamic-pricing-table

It's currently waiting for my pull request to be accepted back into the master branch. (I hope I'm using this terminology correctly; I'm still a Git & Github newb.)

@stuartduff
Copy link
Owner

stuartduff commented Aug 24, 2016

Hey @SturmB, thanks for this, all contributions, thoughts and pull requests are welcomed :)

I will give this a test tomorrow across all pricing scenarios and if all is okay get it merged into master.

@stuartduff
Copy link
Owner

stuartduff commented Aug 24, 2016

Hey @SturmB,

I got to spend some time this evening testing your pull request and your ideas were solid as to how to resolve the issues. I didn't actually merge those though on this occasion and I wanted to explain a little about why as it was nothing you did wrong or similar with your code or pull request ( Great job on that and you only learn by doing ). :D

When researching for the pricing issues with regards to proper decimalisation of the currency amount output I looked to the WooCommerce plugin which has a function titled wc_price() in favor of using PHP's number_format.

With wc_price() it will format the number passed to it in the stores chosen currency format and also add the currency symbol too. This means if the store owner were to change their currency format in WooCommerce that change would also be represented within the discount tables.

For the or more text I also used your idea but wrote the code a little differently by checking for a value less than 1 along with making sure the text was also localized so it can be translated / changed.

For some of the text changes you suggested I rejected these for the moment.

The main reason being is that all the text within the plugin is localized and can be changed by using a plugin like Loco Translate from the admin dashboard of your WordPress site.

Although loco translate contains the word translate it is also used for changing English phrases or words within a theme or plugin into other English words or phrases as an example.

This way you don't edit any plugin files and if I release an update to the plugin in the future you don't lose any changes to the text that you may have made, this also follows the standards of WooCommerce and WordPress with regards to hard coded text.

You can grab v1.0.1 from the releases section and it now looks like this below in the table.

mixed percentage and fixed dynamic pricing woodev

Thanks to everyone for your code contributions and suggestions as they are always really appreciated as collaboration improves everything.

https://github.com/stuartduff/woocommerce-dynamic-pricing-table/releases

cc: @johnzhel @joshuaPSmith

Let me know how this version works out for you all.

Cheers

@stuartduff stuartduff added this to the 1.0.1 milestone Aug 24, 2016
@stuartduff stuartduff self-assigned this Aug 24, 2016
@SturmB
Copy link

SturmB commented Aug 25, 2016

I'm glad you are so much more familiar with WooCommerce & Wordpress in general than I am, @stuartduff! I was sure that there must be some way to have the currency localized better, but was completely unaware of wc_price(). Thanks for taking my suggestions and improving them considerably!

I will say, however, that I think you misunderstood my use of number_format(). I intended the use of that function only for the Quantity column, not the Pricing column. That said, there still might be a better way to have the quantity numbers formatted locally. For the U.S., the integer 12345 would be formatted as 12,345. For Italy, it would be formatted as 12.345. I hope this makes sense.

Also, I'll definitely check out Loco Translate as soon as I have some time. It sounds like a much easier way of having text phrases in the table appear the way you want without having to program in a Settings control panel for the backend of the site.

Again, thank you so much for being awesome and giving us this excellent plugin!

@stuartduff
Copy link
Owner

stuartduff commented Aug 26, 2016

@SturmB I was just happy I could offer a solution to a common request with regards to the Dynamic Pricing plugin and seeing people like yourself using the plugin and contributing ideas is awesome.

I think you're also right with regards to me maybe misunderstanding what you intended using the number_format for. And it's something I'm happy to discuss further.

I intended the use of that function only for the Quantity column, not the Pricing column. That said, there still might be a better way to have the quantity numbers formatted locally. For the U.S., the integer 12345 would be formatted as 12,345. For Italy, it would be formatted as 12.345. I hope this makes sense.

That would make sense now that I have read it back and correctly understood the reasoning as once you get into quantity numbers like 12,000 and above which is not actually something I thought of or tested Doh!, good call :)

Looking at WooCommerce it has a formatting function titled wc_stock_amount() which we can pass the quantity values through and which should work to format those :)

I will get this added and test ;)

@stuartduff
Copy link
Owner

stuartduff commented Aug 26, 2016

After testing this the format of 123567 is actually correct as the default quantity as by defult the wc_stock_amount() and it formats the numbers with an intval.

https://github.com/woothemes/woocommerce/blob/master/includes/wc-core-functions.php#L37

I have added the wc_stock_amount() function to the plugin as it's more inline with the WooCommerce core in case anything changes in the future within the core plugin with regards to quantity formatting.

Them main wc_stock_amount() function in WooCommerce can be altered using the woocommerce_stock_amount filter, with this in mind if anyone did want to change the way quantities are displayed the output could be filtered to change that.

The changes are included in v1.0.2 below.

v1.0.2: https://github.com/stuartduff/woocommerce-dynamic-pricing-table/releases/tag/1.0.2

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants