Creating Coupon code with custom rules in woocommerce - javascript

I need help to creating woocommerce coupon code with custom conditions
for example: coupon code: NEW
if total order value between: 1000 to 10000 apply 5% discount
or
if total order value between 10001 to 20000 apply 10% discount
or
if total order value between 20001 to 30000 apply 15% discount.
I need help to creating woocommerce coupon code with custom conditions
for example: coupon code: NEW
if total order value between: 1000 to 10000 apply 5% discount
or
if total order value between 10001 to 20000 apply 10% discount
or
if total order value between 20001 to 30000 apply 15% discount.

Related

FullCalendar - Half day in dayGridMonth

I have a calendar with FullCalendar that allows me to post my absences.
For some absences, they are only half a day (morning or afternoon), and for others, they can last several days but end at 12:00.
The goal is therefore in the monthly view to display the events without filling a whole cell when it is not necessary:
So I have my list of events that contain extendedProps, letting me know if I have to correct their width to take into account the half-days.
For these, I manage to modify their width, thanks to this function:
eventRender: function (info) {
// HALF DAY
var half = info.event.extendedProps.halfDay;
if (half == true) {
// console.log(info);
var elementStyle = info.el;
jQuery(elementStyle).css('width', 50 + "px");
}
And I have :
So that's good, but I need to improve the function to take into account the total size of the width and perform a calculation that will reduce it. Because here I assign it the value '50' in width.
For example :
An event that lasts 2.5 days: a calculation that determines the width to occupy on the calendar in the monthly view so that it does not take the place of 3 days but 2.5 days. Taking into account of course the size of the screen.
And for an event that lasts only half a day, make sure that it only fills half of a box as in the image, but with a better calculation.
The problem is that I do not find a way to do that. I tell myself that I should already get the width of a cell according to the size of the screen and that I do the math then, but I have trouble
EDIT:
Example: I have an event that lasts just one day. So I give it the option 'allDay' => true.
We see on the picture on the day 'Sat 02/11' that it is directly set for the whole day. It's OK!
Now, if I have an event that should last 2.5 days. It would be necessary that on this sight, during two days, it is marked in the line 'all the day', but that in the last day, it is not in 'all the day' but that one put him well in the schedules . But if I set the option 'allDay' of the event to true, then it will appear in the box 'all day' for 3 days!
And if I take away the option 'allDay', then in the weekly view, it will fill a whole day, as seen in the picture in the day of 'dim 03/11'. And it's really not aesthetic

Math to dynamically shift elements within a div for fit

I’m working on a card game in JS. The player’s cards are dynamically displayed as elements inside a div of a set width. As cards are added to the player’s hand, I’m using right: % and z-index to shift all cards left and have them overlap each other, thereby making room to display more cards within the div (which is set to white-space: nowrap so content inside it won't break to a new line).
I’m using JS to calculate and set the percentage for the cards to shift left, based on each card’s original position and the total number of cards that need to be displayed.
The general plan is working, but I’m having trouble figuring out how to calculate a percentage that will work for any number of cards. Ideally, I'd like the cards to shift left just enough so that no matter how many there are they never extend outside the div but always fill it completely.
I thought the following would work:
function displayHand(cards) {
for(var i = 0; i < cards.length; i++) {
var cardDiv = document.createElement("div");
document.getElementById(“playerHand”).appendChild(cardDiv);
if(cards.length > 7) {
cardDiv.setAttribute("style", "z-index: " + i + "; right: "
+ (i * cards.length) * (0.04815 * cards.length) + "%");
}
}
However, I seem to be getting this formula wrong: (i * cards.length) * (0.04815 * cards.length). (Note that the 0.04815 number came from tinkering and trying to get the percentage right.)
By increasing the 0.04815 number I can make a small number of cards (i.e. 8-12) fit well but a larger number will be shifted much too close together, filling only a small portion of the div. If I decrease the number, 12 cards will overflow the div but a larger number will fit well inside it.
The problem comes from the fact that you don't need the first card to move. Your cards.length factor is too high.
Instead, you need only consider cards.length-1.
For instance, let's say I can fit in two cards exactly. To add a third card, I would need to move the cards left for a total of 1 card width by the time two cards (after the first) have been placed. That is, at 50% and 100%. Adding a fourth card would result in the cards being shifted at 1/3, 2/3 and 3/3. And so on.
So it should simply be a case of moving it by i * (cards.length-1) * (card width here)
OK, I figured it out. The following formula works for any number of elements, shifting them over just enough to make room without ever over- or under-filling the container div: i * (((cards.length - 7) * (0.1428 * 100)) / (cards.length - 1))
Here 7 represents the original number of elements in the container, 0.1428 represents the width of the elements, and -1 represents the first element, furthest to the left, which doesn't move.

Trigger events every time users touch-scroll through 40px

I have touchmove function that checks how many pixels were scrolled by user. It is hooked up to a custom slider I made that has 5 steps with 40 px between each step, hence I want to go to the next step when 40px are scrolled, I tried amountScrolled % 40 == 0 but the issue here is that sometimes numbers are skipped if the user's finger drags quite quickly, therefore I'm not guaranteed to see numbers like 40 or 80 that I expect, so I tried absoluteTouchDistance > 40 || absoluteTouchDistance > 80 || ... , issue here is that after that first condition, it gets executed all the time, whereas I want it to execute next if number was 80 or 120 and so on.
something like this should get you going:
steps = math.floor(absoluteTouchDistance/40);
now you can conveniently check if steps has changed, and react accordingly.

Incremental step value to jQuery Rangeslider Widget

jQuery Mobile Rangeslider Widget provides the step attribute to specify increment value.
Is there any way to customize this step value to increment like 0.1 upto 10 then 10 till 100 and so on
Widget value start from 0.1 , 0.2, 0.3,... until 1, then 2, 3,.. until 10, then 20, 30... until 100, then 200, 300... until 1000,...
Any hacks like this one?
Closest solution that I could found is jQuery Simple Slider

Jquery Counter from 0% to 100% with step function

i have 2 divs, the blue one is set to 365px width (this will actually be the page height so i cant pre determine it)
then the grey one i need to count from 0 - 100%
at the moment it counts from 365 to 0
http://jsfiddle.net/Bill/BNVyq/
Change the width of the css #loading_line to 0 and the width in the animate to 100.
Also see the updated jsfiddle.
=== UPDATE ===
I've updated your jsfiddle.
Change your data calculation to
var data = now / onepercent;
and move it after the onepercent calculation.

Categories