Jump to content

Olumide

Members
  • Posts

    126
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Olumide

  1. Instead of relying on the is_wc_endpoint_url function, you can use the is_order_received_page function to check if you are on the order received page.
  2. I adjusted it this way add_action('woocommerce_thankyou', 'upsell_redirect'); function upsell_redirect($order_id) { // Check if not on the 'order-received' page if (!is_order_received_page()) { WC()->session->set('original_order_id', $order_id); $upsell_page_url = home_url('/upsell-1'); wp_redirect($upsell_page_url); exit; } }
  3. Try it this way add_action('woocommerce_thankyou', 'upsell_redirect'); function upsell_redirect($order_id) { // Check if not on the 'order-received' page if (!is_wc_endpoint_url('order-received')) { WC()->session->set('original_order_id', $order_id); $upsell_page_url = home_url('/upsell-1'); wp_redirect($upsell_page_url); exit; } }
  4. You can try checking if the current request is for the 'order-received' endpoint using the is_wc_endpoint_url function with the specific order ID. Here's an updated version of your code: add_action('woocommerce_thankyou', 'upsell_redirect'); function upsell_redirect($order_id) { // Check if the current request is for the 'order-received' endpoint with the specific order ID if (is_wc_endpoint_url('order-received') && get_query_var('order-received') == $order_id) { return; } WC()->session->set('original_order_id', $order_id); $upsell_page_url = home_url('/upsell-1'); wp_redirect($upsell_page_url); exit; }
  5. I have an invoice table whereby if payment is made or recorded, it should update the table by setting the tendered_amount, if the tendered_amount is greater than the total_amount, the result/value should be store in change_balance (e.g. 500 - 300 = 200) and if the tendered_amount is lower than the total_amount, that is debts because the amount expected is not equal to the tendered amount, but if the tendered amount is equal to the total amount, the user has fully paid and the status should change to 'paid', also, if the tendered amount is greater than the total amount, the status will also change to paid because he overpaid. // Calculate change_balance, debts, and update status $change_balance = max(0, $amount_paid - $invoice_data['total_amount']); $debts = max(0, $invoice_data['total_amount'] - $amount_paid); $status = ($debts == 0) ? 'paid' : 'unpaid'; // Update the tendered_amount, change_balance, debts, and status columns $update_query = "UPDATE `invoices` SET `tendered_amount` = '{$amount_paid}', `change_balance` = '{$change_balance}', `debts` = '{$debts}', `status` = '{$status}' WHERE `invoice_code` = '{$invoice_code}'";
  6. Try this .curved-bottom { position: absolute; bottom: 0; left: 0; width: 100%; height: 200px; /* Adjust the height of the curved bottom */ background-color: #000000; /* Set the background color */ clip-path: ellipse(100% 60% at 50% 40%); }
  7. This should help. $category = $_POST['category']; $folder1 = "uploads/categoryA/"; $folder2 = "uploads/categoryB/"; $folder3 = "uploads/categoryC/"; switch ($category) { case 'categoryA': $uploadFolder = $folder1; break; case 'categoryB': $uploadFolder = $folder2; break; case 'categoryC': $uploadFolder = $folder3; break; default: die("Invalid category"); } // it check if the folder exists, if not, it create it if (!file_exists($uploadFolder)) { mkdir($uploadFolder, 0777, true); } $uploadedFile = $_FILES['file']['tmp_name']; $destination = $uploadFolder . $_FILES['file']['name']; if (move_uploaded_file($uploadedFile, $destination)) { echo "File successfully uploaded to $uploadFolder"; } else { echo "Error uploading file"; }
  8. There is a slight error in the second foreach loop where you check for extra SKUs. You are comparing the received count with the expected count, but you should be checking if the received count is greater than the expected count. Try replacing the second foreach statement with this: foreach ($received_counts as $sku => $received_count) { if (!isset($expected_counts[$sku])) { $extra = array_merge($extra, array_fill(0, $received_count, $sku)); } elseif ($received_count > $expected_counts[$sku]) { $extra = array_merge($extra, array_fill(0, $received_count - $expected_counts[$sku], $sku)); } }
  9. Can you try something like: # Redirect /shop/{cat}/{sub-cat}/{product}/ to /shop/{cat}/{product}/ RewriteRule ^shop/([^/]+)/([^/]+)/([^/]+)/$ /shop/$1/$3/ [R=301,L]
  10. It seems like the variable $siteOwnersEmail is used, but its value is not defined in your provided code. You need to set the email address where you want to receive the form submissions. Add the following line at the beginning of your script, before the if($_POST) line: $siteOwnersEmail = 'your-email@example.com'; Replace 'your-email@example.com' with the actual email address where you want to receive the form submissions. Additionally, there's a small error in your code. You're using $Name in your message concatenation, but the variable is actually $name (lowercase). Update the line to: $message .= "Email from: " . $name . "<br />"; After making these changes, your script should work better.
  11. The provided code (connection.txt file) appears to be error-free. However, the success of the code depends on the context and how the functions are used in the rest of your script. NB: It's crucial to keep sensitive information like database login credentials secure.
  12. Please note the modification assumes you have a secure/SecurePDO.php file that contains your PDO connection and appropriate functions. Make sure to adjust this based on your actual implementation.
  13. Here's the modified version of your code for the second attachment which I was unable to download earlier. <?php // Banking Version 2.0.0 31-03-2023 Desmond O'Toole. include("secure/SecureFunctionsBank.php"); include("../secure/SecurePDO.php"); error_reporting(E_ALL); ini_set('display_errors', '1'); // Start the session session_start(); $page = "Bank Login"; Session_Init(); if (!isset($_SESSION["Pk"])) { header('Location: index.php'); exit; } $Pk = $_SESSION["Pk"]; if (KeyCheckX($Pk) == 0) { header('Location: index.php'); exit; } $EndTime = KeyTestX($Pk, 0); $_SESSION["current_page"] = $page; $qBalance = GetBalance(); $Date = $qBalance['EntryDate']; $Value = $qBalance['BalanceValue']; $stamp = strtotime($Date); $StartDate = date('D d-M-Y', $stamp); $stamp = $stamp + (WEEKS * 6) + (DAYS * 1); $EndDataDate = date('D d-M-Y', $stamp); $curValue = $Value; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <title>Bank Home 2</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="imagetoolbar" content="no"> <meta http-equiv="refresh" content="60"> <link rel="stylesheet" href="stylesheets/Library.css" type="text/css"> <link rel="stylesheet" href="stylesheets/LibraryMenu.css" type="text/css"> </head> <body> <div id="PageTitle"> <img src="images/LibraryBanner.jpg" alt=""> </div> <?php include('SideMenu.php'); ?> <div id="PageContent"> <form action="menu.php" method="post"> <span style="color:blue;"><b>Est: 18-July-2015</b></span> <h4><?= "Displayed data up to " . $EndDataDate ?><?= "<br>Log on ends on " . $EndTime ?> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="DeleteOldData.php"><span style="color:blue">Clear old data</span></a> <br> </h4> <div style="width:850px;padding:0px;float:left;"> <!-- ... Rest of your HTML code ... --> <?php $stmt = GetAllData($Date); while ($row = $stmt->fetch()) { // ... Rest of your loop code ... } ?> <!-- ... Rest of your HTML code ... --> </div> <div style="width:670px;height:50px;padding:0px;float:left;"> <input class="MyButton" type="submit" name="direction" value="Main Menu"> <br> </div> </form> </div> </body> </html>
  14. Your code seems to be a mix of old and new PHP practices. The main issue you're facing could be due to the deprecated `mysql` functions. You should switch to using `PDO` consistently throughout your code, as you've started doing in some places. Here's an updated version of your code using `PDO`: <?php define('OTHER', 1); define('SHOPS', 10); define('ONLINE', 11); define('CASH', 12); define('EBAY', 15); define('ARGOS', 16); // ... (other constants and functions) function GetBalance() { $pdo = connectDB(); $stmt = $pdo->query("SELECT * FROM Bank_config"); $row = $stmt->fetch(); return $row; } function GetAllData($StartDate) { $pdo = connectDB(); $sqlAllData = "SELECT * FROM Bank_Data WHERE EntryDate > :StartDate AND EntryDate <= DATE_ADD(:StartDate, INTERVAL 6 WEEK) ORDER BY EntryDate ASC, Output"; if ($_SESSION['CounterValue'] == 'Total') { $sqlAllData = "SELECT * FROM Bank_Data ORDER BY EntryDate ASC, Output"; } if ($_SESSION['CounterValue'] == 'Database') { $sqlAllData = "SELECT * FROM Bank_Data ORDER BY EntryDate ASC, Output"; } $stmt = $pdo->prepare($sqlAllData); $stmt->execute(['StartDate' => $StartDate]); return $stmt; } // ... (other functions) function DeleteOldData() { $pdo = connectDB(); $Date = time(); $Month = date('m', $Date); $Year = date('Y', $Date); $Month -= 1; if ($Month == 0) { $Month = 12; $Year -= 1; } $Date = $Year . "-" . $Month . "-01"; $sqlOldData = "DELETE FROM `Bank_Data` WHERE EntryDate < :Date"; $stmt = $pdo->prepare($sqlOldData); $stmt->execute(['Date' => $Date]); } ?> Please note that you should replace `connectDB()` with your actual database connection function. This code assumes that `connectDB()` returns a valid PDO connection. Update other parts of your code similarly to use PDO consistently.
  15. If you're encountering issues with the code under PHP 8, there might be some compatibility issues. However, let's check a few things: 1. **Check for PDO Extension:** Ensure that the PDO extension is enabled in your PHP configuration. You can do this by checking your `php.ini` file or by creating a PHP file with `phpinfo();` and checking if PDO is listed. 2. **Error Handling:** Check if there are any error messages that might give you more information about what's going wrong. You can add error handling to your PDO code: ```php try { $pdo = connectDB(); $stmt = $pdo->query("SELECT * FROM Bank_config"); $row = $stmt->fetch(); return $row; } catch (PDOException $e) { echo "Error: " . $e->getMessage(); } ``` This will print any errors that occur during the execution of the query. 3. **Function Implementation:** Ensure that the `connectDB()` function is correctly implemented and returns a PDO instance. If there's an issue with this function, it might affect the query execution. 4. **Table and Column Names:** Make sure that the table name (`Bank_config`) and column names in your query match the actual structure of your database. In PHP 8, there might be stricter adherence to correct syntax. 5. **PHP Short Tags:** Ensure that your PHP files are using the full `<?php` tag rather than short tags (`<?`). Although this is less likely to be an issue, it's a good practice for compatibility. 6. **PHP Version Mismatch:** Double-check that your web server is using PHP 8. Sometimes, there might be multiple PHP versions installed, and the web server could be configured to use a different version. If you still face issues, please provide any error messages you receive, and I'll do my best to assist you further.
  16. Do you want to customize the include path for PHP on a shared hosting environment? You can achieve this by modifying the .htaccess file. Here's an example: php_value include_path ".:/your/custom/path" Replace /your/custom/path with the desired path. Keep in mind that not all shared hosting environments allow customizing certain PHP configurations due to security restrictions.
  17. Moving from PHP 5.4.45 to PHP 8 is a significant version upgrade, and it's good that you are considering updating your code accordingly. Here are some points to consider: 1. mysql_query(): The mysql_ functions, including mysql_query(), have been deprecated and removed in later PHP versions. You should replace them with MySQLi or PDO. 2. PDO: While you've updated your code to use PDO, keep in mind that PDO is a database access layer providing a uniform method of access to multiple databases, including MySQL. It should work fine with MySQL 5.7.4-43. It's important to note that updating to PHP 8 and MySQL 5.7 may introduce other compatibility issues or deprecated features in your code. It's recommended to thoroughly test your application in a development environment before making these changes on your live server.
  18. Hey there! I totally get what you mean. It seems like the posts you're seeing are from 2022, and the banner warning about responding to old posts might give the impression that the forum is inactive. However, it's worth noting that the activity on forums can vary across different categories. Some categories may indeed have older posts, while others might have more recent activity. For instance, in the PHP and MySQL categories, you might find more up-to-date discussions
  19. You're welcome! Regarding posts appearing as too old to respond to, it's possible the forum have specific rules or limitations on the age of posts that can be replied to. Additionally, certain threads may be archived after a certain period, making them unavailable for further responses.
  20. The forum is active and they have been solving problems.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.