Function to increase price by 20% only if price is less than $20 - price

I'm wondering if someone can help with a function for WP All Import to increase prices only if the price is less than $20. Perhaps my question is how to set up variables? price1(actual price)?
$price1 = "{Cost[1]}";
$price2 = "20"
$price3 = "$price1 + 20%";
function choose_price_to_return ($price1, $price2) {
if ($price1 < $price2) {
return $price3;
} else {
return $price1;
}
}

Related

Prestashop 1.7.6.3 calculates tax in wrong way

In prestashop 1.7.6.3, the tax is calculated in the wrong way.I need to round the unit price after it derived from base price having discount. Now the price and total excluding tax is ok but price and total including tax is not right for that rouding. How can i round that? I tried
in product.php
$specific_price_reduction = 0;
if (($only_reduc || $use_reduc) && $specific_price) {
if ($specific_price['reduction_type'] == 'amount') {
$reduction_amount = $specific_price['reduction'];
if (!$specific_price['id_currency']) {
$reduction_amount = Tools::convertPrice($reduction_amount, $id_currency);
}
$specific_price_reduction = $reduction_amount;
// Adjust taxes if required
if (!$use_tax && $specific_price['reduction_tax']) {
$specific_price_reduction = $product_tax_calculator->removeTaxes($specific_price_reduction);
}
if ($use_tax && !$specific_price['reduction_tax']) {
$specific_price_reduction = $product_tax_calculator->addTaxes($specific_price_reduction);
}
} else {
$specific_price_reduction = $price * $specific_price['reduction'];
}
}
if ($use_reduc) {
$price -= $specific_price_reduction;
}
// Group reduction
if ($use_group_reduction) {
$reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group);
if ($reduction_from_category !== false) {
$group_reduction = $price * (float) $reduction_from_category;
} else { // apply group reduction if there is no group reduction for this category
$group_reduction = (($reduc = Group::getReductionByIdGroup($id_group)) != 0) ? ($price * $reduc / 100) : 0;
}
$price -= $group_reduction;
}
I checked classes/cart.php, classes/cartrule.php and several other files but it also didn't help me.
in your config/config.inc.php line 134, you can change 2 constants about price precision.
define('_PS_PRICE_DISPLAY_PRECISION_', 5);
define('_PS_PRICE_COMPUTE_PRECISION_', 5);
Note:
i put 5 by example

Why is the following code returning 0 yet the variable cash should be updated?

I have made sure that the list aren't null. They have values that prints in logcat yet the cash variable isn't updated.
var cash = 0
val intent = intent
group = intent.getParcelableExtra("group")
viewModel.getBank(group).observe(this, Observer {
for (i in it) {
Log.d("DashBoard", "Bank Amount ${i.bank_amount}")
cash += i.bank_amount!!.toInt()
}
})
viewModel.getMpesa(group).observe(this, Observer {
for (i in it) {
Log.d("DashBoard", "Mpesa Amount ${i.mpesa_amount}")
cash += i.mpesa_amount!!.toInt()
}
})
binding.textViewCash.text = cash.toString()

Max shipping cost

How do I set the maximum shipment amount per 199 in PrestaShop 1.7?
It may be smaller, but it may not exceed 199.
In which file do I look for the variable corresponding to the amount of the shipment?
Override function getPackageShippingCost() from Cart class:
class Cart extends CartCore
{
public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null)
{
$shipping_cost = parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone);
if ($shipping_cost > 199) {
return 199;
}
}
}
Remember to remove class_index.php and clear cache.

Encountering problems with JSFiddle code

I have recently written a piece of code that checks temperature over a period of time for some course work. i wrote the program using different bits of code but cannot find the issue to some of the problems i am encountering.
I was just wondering if anyone can see any obvious errors that i am missing and could help out with some information int he right direction.
Link to the JSFiddle
//Counting the average temperatures in a day
//needs debugged!!!
var temperatures = [];
var total = 0;
function getCity() {
//get the locale to help with the display
city = prompt("Enter your city >> ");
}
function getNumDays() {
number = prompt("How many days in the study? Enter 1 - 10");
while ((number < 1) || (number > 10) ||( isNaN(number) === true)) {
alert ("Invalid input!");
number = prompt ("Enter again, 1 - 10 >> ");}
return number;
}
function getTemps(numDays) {
total = 0;
for (i = 0; i < numDays; i++) {
next = prompt ("Enter the temperature for day " + (i+1));
next = parseint(next);
while (isNaN(next)===true) {
next = 0;
next = prompt ("Error in input! Try again >>");
next = parseInt(next);}
temperatures.push(next);
}
total = total + next;
return temperatures;
}
function calcAverage(total, numDays) {
average = total / numDays;
return average;
}
function showStatistics(city, average, numdays) {
alert ("The average daily temperature for "+ city + " is " + average.toFixed(2) + " measured over " + numDays + " days." );
}
//main program
city = getCity();
numDays = getNumDays();
temperatures = getTemps(numDays);
Average = calcAverage(total, numDays);
showStatistics(city, average, numDays);
function getCity() {
//get the locale to help with the display
city = prompt("Enter your city >> ");
}
//main program
city = getCity();
Looks like you're missing a return statement.
Additionally, the line total = total + next; seems to be out of place: I imagine the total to be the total of the temperatures, not 0 + temperatureOfLastDay.

How do i create a calculated measure that will filter data by days overdue

I have a field in my fact table called days overdue. I would like to create a set that will do the following: If the days due is between 0 - 29, then 0 - 29 days overdue, if between 30 and 59 days old, then '30 - 59 days overdue. How would i create this?
We need to know what kind of array you're using, or linked list, or my favorite for these things, a vector, etc.
If you were using a vector, you would create your own class to be used as a datatype with things like:
Class MyData
{
String name;
int daysPastDue; // how you want to factor this is up to you,
// i suggest looking into Java.util.date or Java.util.calendar
public MyData
{
name = "";
daysPastDue = 0;
}
}
Class DoWork
{
public void myWork() // excuse the indent, forgot to put in the class name
{
vector <MyData> input;
MyData 0To29 [] = new MyData[input.size()];
MyData 33To59 [] = new MyData[input.size()];
MyData item = new MyData();
int 0To29count = 0;
int 30To59count = 0;
for (i = 0; i <= list.size(); i++)
{
item = input.elementAt(i)
if (item.daysPastDue <= 29)
{
0To29[0To29Count] = input;
0To29Count ++;
}
elseif (item.daysPastDue >= 30 && item.daysPastDue <= 59)
{
30To59[30To59Count] = input;
30To59Count ++;
}
}
}
}
then you have your 2 arrays and can output them as you wish. however i would recommend starting at daysPastDue = 100000 and decrement it and check the number through the vector until you have all the items in the vector listed. That way they're all in order from the most past due, to the least and you get the output of exactly how long they've been past due.