Create an account or log in an already existing one and permanently add the game on your account. Alternatively you can redeem it from the Epic Launcher on the game's giveaway page.
We are welcoming everyone to join our discord server (link below). We are more active there on finding giveaways, small or large.
Review: Stories Untold – A Chilling Horror That Toys With ’80s Nostalgia
Stories Untold is a chilling collection of four interconnected vignettes that make up a twisted little journey exploring the true nature of nostalgia and the very fabric of memories we all hold so dear. It examines how we remember and reconfigure things from our pasts and how digging down into what we, on the surface, may have always assumed to be real, comforting and familiar can reveal all sorts of forgotten traumas and unexpected surprises.
These four short, sharp shocks are bolstered by their delivery through the ingenious lo-fi UI aesthetic provided by developer No Code. It’s an aesthetic fans of Alien: Isolation will immediately recognise – lead writer and director John McKellan’s work injected that horror masterpiece with a real sense of time and place – and here it draws us in completely as we inch forward towards a startling denouement that ties the whole thing together.
The House Abandon, the first part of Stories Untold, was originally released as a standalone prototype but garnered such praise from fans of interactive horror that the team at No Code decided to go ahead and create this fully formed adventure around it. Things start out simply enough. In the comfort of your very own childhood bedroom, you begin your journey here by playing an old text adventure game, sat at your desk banging out instructions on the keyboard of your ZX Spectrum.
As you play this strange game – which mirrors exactly the environment in which you’re currently sat – you slowly begin to realise that what’s happening within it as you play is somehow affecting things in the real world. Something is not quite right, and what was, just moments ago, a warm and familiar environment slowly becomes infused with a creeping dread. There is something at work here; a darkness, a secret at the centre of everything you thought you knew.
Moving into chapter two, The Lab Conduct, your familiar childhood surroundings are gone now; you find yourself stationed in front of a wall of complicated X-Ray equipment. There’s a detailed manual that shows you how each element of this technology works and you must follow instructions carefully in order to successfully complete a series of experiments on what appears to be a human heart.
Again, it’s the extraordinary detail, both aesthetically and in how you’re expected to interact with all this stuff, that draws you in. Switching on a camera, setting an old TV to various viewing modes, powering up a rather long drill and tuning your Amp and Signal Generator until everything is successfully tweaked in order for these delicate procedures to go ahead. It feels like a painstaking and complex process – referring to instructions, mastering and understanding what each bit of kit does – and it fully and very cleverly envelopes you in the narrative, driving home each and every shock with superb force as a result.
Later on, you’ll get to grips with an old Microfiche reader, twisting and turning pages, zooming in and out as you focus on bits and pieces of text. There’s a great big retro radio receiver you’ll use to scan the airwaves for coded messages and then translate them, inputting codes, following the guidelines of mysterious glossaries like some half-mad amnesiac detective, each successful step forward drawing that ever-present unknown, that sense of danger you first felt in your childhood bedroom getting even closer.
Stories Untold is steeped in 1980s pop culture; this is a heady mix of familiar old things, especially for players of a certain vintage. The screeches from your ZX Spectrum as it loads up a game, that old wooden-panelled tv set, the wonderfully ’80s theme tune. There are little bits of The Thing in here, 2001: A Space Odyssey, The Twilight Zone and even the more recent Stanger Things TV show – itself built entirely on the same sense of ’80s nostalgia from which this game creates its core. However, it’s the ruining, not celebrating, of that very nostalgia which plays such a big part in proceedings here – injecting dearly held memories with an almost otherworldly malevolence – and that’s where this game finds most of its power to unsettle.
For an experience that takes all of three hours to complete, Stories Untold certainly packs a wallop; perhaps not the all-out horror you may be expecting, but an emotional and unsettling one that will stay with you well after you put the final pieces of its puzzle together. The final chapter manages to pull everything together in a satisfying and pretty brutal way – we were actually recoiling from our screen, not wanting to take the next step at points – and we genuinely hope we get to see more of this sort of thing from No Code in the future.
In terms of this Switch port, both in docked and portable everything runs perfectly smoothly and we didn’t encounter any bugs on our playthrough of the game. We did feel like the text was a little small in places in handheld mode, although this is somewhat mitigated by a “lean in” function that gets you closer to the various screens and monitors you’re presented with in-game. We also found tuning the radio receiver in chapter three quite difficult to be exact about until we realised we could fine-tune it with some buttons on the radio itself.
Conclusion
Stories Untold is a chilling adventure that manages to draw us right into its world through the ingenious use of its UI and perfectly realised lo-fi aesthetic. Through the walls of old technology and complicated machinery, it creates a uniquely strong bond between player and narrative, giving you a real sense of place within its world as it slowly corrupts and twists from the comfortingly familiar to something else entirely. It’s one of the best interactive horror stories we’ve ever played and a perfect fit for enjoying alone in the dark on Switch.
Sega Hosting Puyo Day Live Stream Next Month, Will Share “24 Pieces Of News”
Over the past few years, Sega has released quite a lot of Puyo Puyo games on the Nintendo Switch. We got Puyo Puyo Tetris in 2017 and Puyo Puyo Champions was localised last year. The Sega AGES version of the original was also made available here in the west in 2019 and earlier this month Puyo Puyo Tsu arrived in Japan.
If you still need more Puyo Puyo in your life, then you should consider tuning into Sega’s ‘Puyo Day 2020 Livestream’ next month on 4th February (8:00 pm JST) over on YouTube or the Japanese video streaming service NicoNico Live. Sega will reportedly be sharing “24 pieces of news” during the broadcast – including updates on each Puyo Puyo title – and there’ll also be various events such as a segment featuring the top Puyo Puyo Champions players.
For some added context, “2-4” reads as “Pu-Yo” in Japanese, which matches the date of Puyo Day (February 4) and also explains why exactly 24 news items will be shared during the event (thanks, Siliconera). Of course, this could only mean one thing – Puyo Puyo for Smash! No, not really, but that’s what some enthusiastic fans are now thinking. After all, if tetrominos are in consideration, a Puyo Puyo representative should also be in with a chance.
Will you be keeping tabs on this broadcast? Tell us down in the comments.
PS5 Games, Price, Release Date, Specs, Controller, And More
It's finally 2020, which means Sony's next-generation console, the PlayStation 5, is fast approaching its launch sometime during this year's holiday season. Throughout 2019, Sony began to reveal some of the first details about their next-gen plans with PS5, and we only expect that to continue in the months ahead.
First, we know that the console's official name. Unsurprisingly, the console is indeed called the PlayStation 5--and we also know what the logo looks like. During 2019, it was revealed that the PS5 will also have PS4 backwards compatibility and SSD storage, and it will support PSVR. The company has also outlined some green, energy-efficient initiatives it is planning for the next generation.
If Sony follows the outline for how the PS4 was properly unveiled, we can expect it to host a special PlayStation Meeting event. There have been some speculation that such an event could take place in February 2020, but Sony has not made any official announcements as of this time. If that does indeed happen, that could be when we learn about things like a price and launch game lineup. However, when Sony plans to roll out new info, it won't be at the venue you might expect. Just like last year's E3, Sony will also skip E3 2020, citing their own announce plans.
Below you can find all the details known about Sony's upcoming console. It's likely we'll hear more details--big or small--in the coming months, so be sure to bookmark this page and check back often as more gets confirmed.
This is surely the question on everybody's lips: when will the PS5 come out? Sony, as you'd expect, is tight-lipped on the matter, but it has confirmed a "holiday 2020" release window for the PlayStation 5. The company has been no more specific than that--Microsoft has also provided the same vague window--but historically, November has been a frequent
PS5 Price
Again, Sony has not stated how much its new console will cost, but it did say that the PS5's price will be attractive to gamers. "I believe that we will be able to release it at an SRP [suggested retail price] that will be appealing to gamers in light of its advanced feature set," said Mark Cerny, the lead architect of the PS4 who's currently working on its successor.
Of course, you wouldn't expect Sony to say anything different, but one gets the feeling the company has learned from the PS3's exorbitant price tag--and the console's subsequent struggles--and the PS4's more reasonable cost and subsequent successes.
Will PS5 Be Backwards Compatible With PS4 games?
Cerny also confirmed the PS5 will be backwards compatible with PS4 games, as the two consoles are built upon similar internal architectures. This will be welcome news for those who were disappointed by the PS4's lack of backwards compatibility with PS3, PS2, and PS1 games.
SIE president Jim Ryan told GameSpot sister site CNET backwards compatibility and cross-gen are important for the PS5 to help players have a seamless transition.
"Whether it's backwards compatibility or the possibility of cross-generational play, we'll be able to transition that community to next-gen," he said. "It won't be a binary choice about whether you have to be either on PlayStation 4 or next-gen to continue your friendship."
In yet more welcome news, PS4 games will even run faster than they do on your current console, in part because the PS5 will contain a solid state drive, as opposed to hard drives that current consoles ship with. Cerny has demonstrated a load screen from Insomniac's Spider-Man taking less than a second on a PS5 development kit, compared with 15 seconds on a PS4 Pro.
Sony showed off the faster loading times during an investor presentation in May. You can see the video below, which was captured by Wall Street Journal reporter Takashi Mochizuki.
Sony's official video comparing performance of PS4 Pro vs next-gen PlayStation pic.twitter.com/2eUROxKFLq
This is where Sony has been surprisingly forthright with new information. The company has confirmed the PlayStation 5 will contain an AMD chip that has a CPU based on the third-generation Ryzen. It'll have eight cores of the seven-nanometer Zen 2 microchip. The console will also support 8K gameplay, but this will of course be dependent upon TVs catching up.
Graphics will be driven by a custom version of Radeon's Navi line. This graphics chip will support ray-racing, something which is starting to become popular in movies and video games. Although it is traditionally thought of as a lighting technique, Cerny says this technique could also improve game audio. In fact, PS5 will fully support 3D audio.
The aforementioned SSD is a big detail too, as it means games will load faster and be able to handle more objects on-screen at once than current HDD-driven consoles. Characters and cameras could move faster through game worlds, as environments could be loaded in much faster than they are at present.
As one final detail, we know the PS5 will not go the route of the Xbox One S All-Digital Edition, which doesn't include a disc drive. Instead, the PS5 will include a disc drive, so rest assured you'll still be able to buy and play physical games. PS5 discs will have a capacity of 100 GB, and the console will also support 4K Blu-Rays.
Sony has also confirmed that the PS5 is capable of supporting 4K visuals at 120Hz for those who have TVs that can support that. 120Hz is a refresh rate around double the rate of standard TVs.
PS5 Controller
Sony has opened up on its vision for the PlayStation 5's controller by saying: "One of our goals with the next generation is to deepen the feeling of immersion when you play games, and we had the opportunity with our new controller to reimagine how the sense of touch can add to that immersion.
"To that end, there are two key innovations with the PlayStation 5's new controller. First, we're adopting haptic feedback to replace the 'rumble' technology found in controllers since the 5th generation of consoles. With haptics, you truly feel a broader range of feedback, so crashing into a wall in a race car feels much different than making a tackle on the football field. You can even get a sense for a variety of textures when running through fields of grass or plodding through mud.
"The second innovation is something we call adaptive triggers, which have been incorporated into the trigger buttons (L2/R2). Developers can program the resistance of the triggers so that you feel the tactile sensation of drawing a bow and arrow or accelerating an off-road vehicle through rocky terrain. In combination with the haptics, this can produce a powerful experience that better simulates various actions. Game creators have started to receive early versions of the new controller, and we can't wait to see where their imagination goes with these new features at their disposal."
In addition to the above comments from Sony Interactive Entertainment president Jim Ryan, Sony has also separately confirmed to Wired that the controller "doesn't have a name yet," but contains an improved speaker, USB-C connectivity, and a larger-capacity battery.
Will PS5 Support PSVR?
The current PSVR will indeed be supported by PS5, as will the PlayStation Move controllers. "I won't go into the details of our VR strategy," Cerny has stated, "beyond saying that VR is very important to us and that the current PSVR headset is compatible with the new console." The system architect stopped short of saying whether a new PSVR device will ever come out, however.
The Logo
It was believed that Sony's briefing at CES 2020 could bring with it some PlayStation 5 news, but that only barely turned out to be the case. Sony's Jim Ryan appeared on stage to share some impressive stats regarding the PS4 and to reveal the PlayStation 5 logo, which you can see below. It's hardly surprising, maintaining the same style used for recent generations. Beyond that, Sony had nothing new to discuss about PS5 during the tech-focused event.
Energy Efficiency
Though Sony has been generally quiet about the PS5 since its announcement, it came forward to reveal just slightly more information in conjunction with the announcement of a United Nations initiative. The Playing for the Planet alliance aims to make the video game industry more environmentally friendly. To that end, Sony announced that the next generation of its hardware will use dramatically less power when placed into suspend/sleep mode. Just one million PS5 users turning on the energy-efficient feature would save enough electricity to power 1,000 US homes. The company is also conducting a carbon footprint assessment and looking into more energy-efficient data centers.
PS5 Games
We don't yet know many confirmed games coming to PS5. It's reasonable to presume annual titles like FIFA and Call of Duty would make the jump to PS5, though their developers haven't stated anything concrete.
Currently, the only confirmed PS5 game is Godfall, a loot-based melee action-RPG. It's scheduled for late 2020, which more than likely makes it a PS5 launch game. However, time will tell!
The other game possibly confirmed to be playable on PS5 is the Final Fantasy VII remake, after Square Enix's president and CEO Yosuke Matsuda said: "I believe that our teams have made it so that the game will support both the next generation and the current generation of consoles. I believe it is being developed so that it is going to be playable on both, so I'm not really concerned about that and I believe that the fans are also going to be able to enjoy it on both, including the next-generation of consoles."
However, it's not clear whether Matsuda was referring to a dedicated PS5 edition of the game, or if he was simply referring to the PS4 version being playable on PS5 via backward compatibility. If it's the latter, then we can technically count every PS4 game as playable on PS5.
PlayStation 5's new user interface will allow you to see more details about friends' games without opening the applications themselves. "Even though it will be fairly fast to boot games," says Cerny, "We don't want the player to have to boot the game, see what's up, boot the game, see what's up. Multiplayer game servers will provide the console with the set of joinable activities in real time. Single-player games will provide information like what missions you could do and what rewards you might receive for completing them—and all of those choices will be visible in the UI. As a player you just jump right into whatever you like."
Do you want to replace all occurrences of a pattern in a string? You’re in the right place! This article is all about the re.sub(pattern, string) method of Python’s re library.
Let’s answer the following question:
How Does re.sub() Work in Python?
The re.sub(pattern, repl, string, count=0, flags=0) method returns a new string where all occurrences of the pattern in the old string are replaced by repl.
Here’s a minimal example:
>>> import re
>>> text = 'C++ is the best language. C++ rocks!'
>>> re.sub('C\+\+', 'Python', text) 'Python is the best language. Python rocks!'
>>>
The text contains two occurrences of the string ‘C++’. You use the re.sub() method to search all of those occurrences. Your goal is to replace all those with the new string ‘Python’ (Python is the best language after all).
Note that you must escape the ‘+’ symbol in ‘C++’ as otherwise it would mean the at-least-oneregex.
You can also see that the sub() method replaces all matched patterns in the string—not only the first one.
But there’s more! Let’s have a look at the formal definition of the sub() method.
Specification
re.sub(pattern, repl, string, count=0, flags=0)
The method has four arguments—two of which are optional.
pattern: the regular expression pattern to search for strings you want to replace.
repl: the replacement string or function. If it’s a function, it needs to take one argument (the match object) which is passed for each occurrence of the pattern. The return value of the replacement function is a string that replaces the matching substring.
string: the text you want to replace.
count (optional argument): the maximum number of replacements you want to perform. Per default, you use count=0 which reads as replace all occurrences of the pattern.
flags (optional argument): a more advanced modifier that allows you to customize the behavior of the method. Per default, you don’t use any flags. Want to know how to use those flags? Check out this detailed article on the Finxter blog.
The initial three arguments are required. The remaining two arguments are optional.
You’ll learn about those arguments in more detail later.
Return Value:
A new string where count occurrences of the first substrings that match the pattern are replaced with the string value defined in the repl argument.
Regex Sub Minimal Example
Let’s study some more examples—from simple to more complex.
The easiest use is with only three arguments: the pattern ‘sing’, the replacement string ‘program’, and the string you want to modify (text in our example).
>>> import re
>>> text = 'Learn to sing because singing is fun.'
>>> re.sub('sing', 'program', text) 'Learn to program because programing is fun.'
Just ignore the grammar mistake for now. You get the point: we don’t sing, we program.
But what if you want to actually fix this grammar mistake? After all, it’s programming, not programing. In this case, we need to substitute ‘sing’ with ‘program’ in some cases and ‘sing’ with ‘programm’ in other cases.
You see where this leads us: the sub argument must be a function! So let’s try this:
import re def sub(matched): if matched.group(0)=='singing': return 'programming' else: return 'program' text = 'Learn to sing because singing is fun.'
print(re.sub('sing(ing)?', sub, text))
# Learn to program because programming is fun.
In this example, you first define a substitution function sub. The function takes the matched object as an input and returns a string. If it matches the longer form ‘singing’, it returns ‘programming’. Else it matches the shorter form ‘sing’, so it returns the shorter replacement string ‘program’ instead.
How to Use the count Argument of the Regex Sub Method?
What if you don’t want to substitute all occurrences of a pattern but only a limited number of them? Just use the count argument! Here’s an example:
>>> import re
>>> s = 'xxxxxxhelloxxxxxworld!xxxx'
>>> re.sub('x+', '', s, count=2) 'helloworld!xxxx'
>>> re.sub('x+', '', s, count=3) 'helloworld!'
In the first substitution operation, you replace only two occurrences of the pattern ‘x+’. In the second, you replace all three.
You can also use positional arguments to save some characters:
>>> re.sub('x+', '', s, 3) 'helloworld!'
But as many coders don’t know about the count argument, you probably should use the keyword argument for readability.
How to Use the Optional Flag Argument?
As you’ve seen in the specification, the re.sub() method comes with an optional fourth flag argument:
Flags allow you to control the regular expression engine. Because regular expressions are so powerful, they are a useful way of switching on and off certain features (for example, whether to ignore capitalization when matching your regex).
Syntax
Meaning
re.ASCII
If you don’t use this flag, the special Python regex symbols w, W, b, B, d, D, s and S will match Unicode characters. If you use this flag, those special symbols will match only ASCII characters — as the name suggests.
re.A
Same as re.ASCII
re.DEBUG
If you use this flag, Python will print some useful information to the shell that helps you debugging your regex.
re.IGNORECASE
If you use this flag, the regex engine will perform case-insensitive matching. So if you’re searching for [A-Z], it will also match [a-z].
re.I
Same as re.IGNORECASE
re.LOCALE
Don’t use this flag — ever. It’s depreciated—the idea was to perform case-insensitive matching depending on your current locale. But it isn’t reliable.
re.L
Same as re.LOCALE
re.MULTILINE
This flag switches on the following feature: the start-of-the-string regex ‘^’ matches at the beginning of each line (rather than only at the beginning of the string). The same holds for the end-of-the-string regex ‘$’ that now matches also at the end of each line in a multi-line string.
re.M
Same as re.MULTILINE
re.DOTALL
Without using this flag, the dot regex ‘.’ matches all characters except the newline character ‘n’. Switch on this flag to really match all characters including the newline character.
re.S
Same as re.DOTALL
re.VERBOSE
To improve the readability of complicated regular expressions, you may want to allow comments and (multi-line) formatting of the regex itself. This is possible with this flag: all whitespace characters and lines that start with the character ‘#’ are ignored in the regex.
re.X
Same as re.VERBOSE
Here’s how you’d use it in a minimal example:
>>> import re
>>> s = 'xxxiiixxXxxxiiixXXX'
>>> re.sub('x+', '', s) 'iiiXiiiXXX'
>>> re.sub('x+', '', s, flags=re.I) 'iiiiii'
In the second substitution operation, you ignore the capitalization by using the flag re.I which is short for re.IGNORECASE. That’s why it substitutes even the uppercase ‘X’ characters that now match the regex ‘x+’, too.
What’s the Difference Between Regex Sub and String Replace?
Why? Because you can replace all occurrences of a regex pattern rather than only all occurrences of a string in another string.
So with re.sub() you can do everything you can do with string.replace() but some things more!
Here’s an example:
>>> 'Python is python is PYTHON'.replace('python', 'fun') 'Python is fun is PYTHON'
>>> re.sub('(Python)|(python)|(PYTHON)', 'fun', 'Python is python is PYTHON') 'fun is fun is fun'
The string.replace() method only replaces the lowercase word ‘python’ while the re.sub() method replaces all occurrences of uppercase or lowercase variants.
Note, you can accomplish the same thing even easier with the flags argument.
>>> re.sub('python', 'fun', 'Python is python is PYTHON', flags=re.I) 'fun is fun is fun'
How to Remove Regex Pattern in Python?
Nothing simpler than that. Just use the empty string as a replacement string:
>>> re.sub('p', '', 'Python is python is PYTHON', flags=re.I) 'ython is ython is YTHON'
You replace all occurrences of the pattern 'p' with the empty string ''. In other words, you remove all occurrences of 'p'. As you use the flags=re.I argument, you ignore capitalization.
Related Re Methods
There are five important regular expression methods which you should master:
The re.findall(pattern, string) method returns a list of string matches. Read more in our blog tutorial.
The re.search(pattern, string) method returns a match object of the first match. Read more in our blog tutorial.
The re.match(pattern, string) method returns a match object if the regex matches at the beginning of the string. Read more in our blog tutorial.
The re.fullmatch(pattern, string) method returns a match object if the regex matches the whole string. Read more in our blog tutorial.
The re.compile(pattern) method prepares the regular expression pattern—and returns a regex object which you can use multiple times in your code. Read more in our blog tutorial.
The re.split(pattern, string) method returns a list of strings by matching all occurrences of the pattern in the string and dividing the string along those. Read more in our blog tutorial.
These five methods are 80% of what you need to know to get started with Python’s regular expression functionality.
Where to Go From Here?
You’ve learned the re.sub(pattern, repl, string, count=0, flags=0) method returns a new string where all occurrences of the pattern in the old string are replaced by repl.
Learning Python is hard. But if you cheat, it isn’t as hard as it has to be:
Shopify Like Shopping Cart with Sticky Checkout using PHP
Last modified on December 3rd, 2019 by Vincy.
Do you know online consumers in the US spent $517 billion last year? Which is a 15% increase from the previous year? eCommerce is an old domain, but still, it disrupts the tech world.
These days, the live shopping cart software have a remarkable business scope. They are increasing in the number day by day. There is a significant market today to sell products in an online store.
PHP is the main technology that runs the majority of the shopping cart software on the Internet. Developing a full-fledged PHP shopping cart software is not as easy as it looks.
In this article, we are going to see how to create a featured sticky shopping cart script in PHP. In Shopify like the eCommerce platform, it gives sticky shopping cart checkout as a feature.
I used jQuery and CSS to make the shopping cart unit sticky on a fixed position on page scroll. So, it will make the cart unit be always near to access and encourage the users to checkout.
This article will guide you with simple steps to create a shopping cart in PHP. If you are planning to create a shopping cart with a modern outlook and features, it will help you to achieve this.
eCommerce software with sticky shopping cart checkout has many advantages,
It gives an enriched modern feel to the application.
It helps users to see the cart status at any moment.
It encourages users to checkout and thus increasing the conversion.
This Shopify-like sticky shopping cart software in PHP uses database and PHP sessions. It manages products in the database and shopping cart items in the PHP session.
It has a product gallery, cart HTML table and supports cart actions like add, edit and delete. These action handlers use AJAX to invoke code added with server endpoints.
The functionalities supported by this example are here with the corresponding description.
Fetching product data from the database: A PHP MySQL code section accesses product database to read the data like product name, code, price, and preview images. If data found then this will result in an array of products.
Create product gallery with add-to-cart option: Create a product gallery with an add-to-cart option. A PHP loop iterates product array to form the gallery view. Each product in the gallery has an add-to-cart button.
Manage the cart with PHP session: I have used the PHP session array to store and manage the cart items.
Handling the add, edit, delete and empty cart: This example code supports users to add a new product into the cart. A HTML table will display the cart item with edit quantity, remove an entry and more options.
File structure
The below screenshot shows the file structure of this example.
view/product-gallery.php – It includes a PHP loop to iterate the products to form the gallery.
view/shopping-cart.php – It contains a HTML table to display the cart item from the PHP session.
css/style.css – It has the styles to showcase product gallery. It helps in shopping cart software design containing appropriate cart action controls.
cart.js – This JavaScript file contains action handlers to process requests via AJAX. It also contains code to fix the shopping cart panel in a fixed position while scrolling.
handle-cart-ep.php – This is the PHP endpoint invoked from AJAX code to add, edit, remove cart items.
tblproduct.sql – This SQL contains product database CREATE and INSERT statements.
DataSource.php – This is a generic file we used for our examples requires a database.
data – This directory is the product image source used while creating the gallery.
A landing page with product gallery and shopping cart components
This HTML code includes the PHP source to render product gallery, shopping cart software pagee. It also shows a sticky cart icon with the current cart items count.
By clicking this icon, a script will toggle the shopping cart window.
This HTML includes cart.js JavaScript file. It contains all the jQuery AJAX code needed for performing cart actions and UI update.
The product gallery is a HTML container embedded with PHP-MySQL script. The PHP code prepares MySQL select statement to get the product result in an array.
By iterating this array result with a PHP foreach statement, it reads the database row data. With this product data, it forms the gallery tile on each loop iteration.
The gallery tile shows products name, price and a preview image in a card-like view. Also, it contains an add-to-cart button.
This’s button’s click event invokes AJAX to add the particular product to the cart session. Each product has a unique code which is the reference to create and manage each cart session index.
The add-to-cart button in each product tile is the trigger to add a cart item into the PHP session. When the user clicks on the ‘Add to Cart’ button, it calls the cartAction() function to execute the add action via AJAX.
In this function call, it has the product id as an argument. In PHP the code fetches the product code, price to add to the cart session.
In this example, the switch case handles cart actions. It request and process add, edit (item quantity), remove (single cart item) and empty cart.
In the “add” case I checked if the current cart item already exists in the cart session. If so, I will update its quantity, otherwise, I will push the entire item array into the session index. The product code is the session index of each cart item to keep the uniqueness. The addToCart function has the code to add the cart item into the PHP session.
case "add": $cartModel->addToCart(); break;
Model/Product.php
<?php use \Phppot\DataSource; class Product { private $ds; function __construct() { require_once __DIR__ . './../lib/DataSource.php'; $this->ds = new DataSource(); } function getAllProduct() { $query = "SELECT * FROM tblproduct ORDER BY id ASC"; $result = $this->ds->select($query); return $result; } }
Display shopping cart items from PHP Session
This code shows the HTML table containing the list of cart items added by the user. The cart data is dynamic from the PHP session.
In shopping-cart.php file, it iterates the $_SESSION[“cart”] array and displays the cart row. Each row has data like product title, price, quantity. It also has the option to edit the item quantity and to delete a single item from the cart.
This cart window is sticky that lets the users access the cart and see the status at any time. Also, it shows the total item price by summing up the individual cart items.
On changing the quantity, and AJAX code will send the data to get the calculated price based on the new quantity. Then, it will update the price in the row.
There is a remove option for each cart item. By clicking the remove action, an ajax call will request PHP code to perform the remove action. It will pass the product code as an argument to clear the particular cart session index.
Also, the shopping cart window has the option to empty the cart with one single click.
The below code shows the switch cases created to trigger and perform cart actions.
cart.js
function cartAction(action, product_code) { var queryString = ""; if (action != "") { switch (action) { case "add": queryString = 'action=' + action + '&code=' + product_code + '&quantity=' + $("#qty_" + product_code).val(); break; case "remove": queryString = 'action=' + action + '&code=' + product_code; break; case "empty": queryString = 'action=' + action; break; } } jQuery.ajax({ url: "ajax/handle-cart-ep.php", data: queryString, type: "POST", success: function (data) { $("#cart-item").html(data); $("#count").text($("#cart-item-count").val()); }, error: function () {} }); } function updatePrice(obj){ var quantity = $(obj).val(); var code = $(obj).data('code'); queryString = 'action=edit&code=' + code + '&quantity=' + quantity; $.ajax({ type: 'post', url: "ajax/handle-cart-ep.php", data: queryString, success: function(data) { $("#total").text(data); } }); } $(document).ready(function () { $("#cart-icon-container").click(function () { $("#shopping-cart").toggle(); }); var top = parseInt($("#shopping-cart").height())/2; $("#shopping-cart").css("margin-top", "-" + top + "px"); });
ajax/handle-cart-ep.php
<?php namespace Phppot; use \Phppot\Cart; require_once __DIR__ . './../Model/Cart.php'; $cartModel = new Cart(); session_start(); if (! empty($_POST["action"])) { switch ($_POST["action"]) { case "add": $cartModel->addToCart(); break; case "edit": $totalPrice = $cartModel->editCart(); print $totalPrice; exit; break; case "remove": $cartModel->removeFromCart(); break; case "empty": $cartModel->emptyCart(); break; } } require_once '../view/shopping-cart.php'; ?>
Model/Cart.php
This is the model class used to create, edit and clear cart sessions.
<?php namespace Phppot; use \Phppot\DataSource; class Cart { private $ds; public $cartSessionItemCount = 0; function __construct() { require_once __DIR__ . './../lib/DataSource.php'; $this->ds = new DataSource(); if (! empty($_SESSION["cart_item"]) && is_array($_SESSION["cart_item"])) { $this->cartSessionItemCount = count($_SESSION["cart_item"]); } } function addToCart() { $query = "SELECT * FROM tblproduct WHERE code = ?"; $paramType = "s"; $paramArray = array($_POST["code"]); $productByCode = $this->ds->select($query, $paramType, $paramArray); $itemArray = array( $productByCode[0]["code"] => array( 'name' => $productByCode[0]["name"], 'code' => $productByCode[0]["code"], 'quantity' => '1', 'price' => $productByCode[0]["price"] ) ); if (! empty($_SESSION["cart_item"])) { if (in_array($productByCode[0]["code"], $_SESSION["cart_item"])) { foreach ($_SESSION["cart_item"] as $k => $v) { if ($productByCode[0]["code"] == $k) $_SESSION["cart_item"][$k]["quantity"] = $_POST["quantity"]; } } else { $_SESSION["cart_item"] = array_merge($_SESSION["cart_item"], $itemArray); } } else { $_SESSION["cart_item"] = $itemArray; } if (! empty($_SESSION["cart_item"]) && is_array($_SESSION["cart_item"])) { $this->cartSessionItemCount = count($_SESSION["cart_item"]); } } function editCart() { if (! empty($_SESSION["cart_item"])) { $total_price = 0; foreach ($_SESSION["cart_item"] as $k => $v) { if ($_POST["code"] == $k) { $_SESSION["cart_item"][$k]["quantity"] = $_POST["quantity"]; } $total_price = $total_price + ($_SESSION["cart_item"][$k]["quantity"] * $_SESSION["cart_item"][$k]["price"] ); } return $total_price; } if (! empty($_SESSION["cart_item"]) && is_array($_SESSION["cart_item"])) { $this->cartSessionItemCount = count($_SESSION["cart_item"]); } } function removeFromCart() { if (! empty($_SESSION["cart_item"])) { foreach ($_SESSION["cart_item"] as $k => $v) { if ($_POST["code"] == $k) unset($_SESSION["cart_item"][$k]); if (empty($_SESSION["cart_item"])) unset($_SESSION["cart_item"]); } } if (! empty($_SESSION["cart_item"]) && is_array($_SESSION["cart_item"])) { $this->cartSessionItemCount = count($_SESSION["cart_item"]); } } function emptyCart() { unset($_SESSION["cart_item"]); $this->cartSessionItemCount = 0; } }
Product database table SQL script
The following SQL script has the CREATE and the INSERT query. It will help to put the product table in your development environment.
CREATE TABLE IF NOT EXISTS `tblproduct` ( `id` int(8) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `code` varchar(255) NOT NULL, `image` text NOT NULL, `price` double(10,2) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `product_code` (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ; -- -- Dumping data for table `tblproduct` -- INSERT INTO `tblproduct` (`id`, `name`, `code`, `image`, `price`) VALUES (1, 'FinePix Pro2 3D Camera', '3DcAM01', 'product-images/camera.jpg', 1500.00), (2, 'Luxury Ultra thin Wrist Watch', 'wristWear03', 'product-images/watch.jpg', 300.00), (3, 'XP 1155 Intel Core Laptop', 'LPN45', 'product-images/laptop.jpg', 800.00), (4, 'Water Bottle', 'wristWear02', 'product-images/external-hard-drive.jpg', 600.00);
Do you like trains? You'll love Train Sim World 2020!
[www.indiegala.com] Take control aboard powerful locomotives from around the world at a historical low price.
The 128th GalaQuiz will be LIVE soon, win up to $50 in GalaCredit!
[www.indiegala.com] The GalaQuiz will take place in less than 20 minutes from this announcement Today's GalaQuiz[www.indiegala.com] hints are up. The theme will be Latin Words. Get them all right and there will be a praemium for you.
Now, though, it’s time to put all of that aside and discuss our weekend gaming plans. Members of Team Nintendo Life have done just that and we’d love you to join in via the comment and poll sections below. Enjoy!
PJ O’Reilly, reviewer
This weekend I’m going to be taking advantage of the slight lull in big releases to jump back into some stuff I really need to finish up. I’ll be polishing off Luigi’s Mansion 3 and Yoshi’s Crafted World with my kids as well as jumping into my latest purchase Dragon Quest XI, which I’ve only just discovered is absolutely amazing, a proper must-own game in my opinion.
I’m also still making my way through my Xmas Labo kits, although I‘ve now entirely abandoned the instructions as they’re too complex for me and am instead creating a giant cardboard Jeff Goldblum to keep me company when I feel a bit lonely or sad.
Anthony Dickens, managing director
It’s long overdue but I’m in desperate need to blow away the physical cobwebs after an over-indulgent Christmas and New Year. Having finally gotten my hands on a copy of Ring Fit Adventure from overseas (it’s still out of stock in the UK) I intend to clear away the coffee table and see what the fuss is all about in this fitness-based RPG adventure. Deep Heat plasters are on standby, as will be the coffee. Wish me luck, my body is ready.
Ollie Reynolds, reviewer
At the moment, I’m still spending more or less every spare moment playing DOOM (OG) – I’m working my way through the game on Nightmare difficulty, and there’s just something so immediately compelling about its gameplay that few modern games can replicate. Or maybe it’s just the nostalgia!
Time permitting, I’m also quite tempted to jump back into Pokémon Sword at some point. Since the Diamond and Pearl days, I always seem to lose steam with Pokémon games about halfway through, and the exact same has happened with Sword. I feel like if I can’t get back into it this time, then I may well be done for good…
Austin Voigt, contributing writer
I’ve been getting very into Ring Fit Adventure, people. I was sceptical at first, but it’s quickly become a very addictive game to play. In fact, every time I sit down to play a different game, I usually end up picking up Ring Fit and gamer-cising instead (yeah, I just made that up). So I’ll be totally honest – that’s probably all I’ll play this weekend… at least, until the holiday weight and guilt are gone.
Ryan Craddock, staff writer
I’m getting ever closer to completing Luigi’s Mansion 3 – I’m pretty sure I’ve only got about four-or-so floors to go – and I’ve been really enjoying seeing the variety of design choices for each one as you make your way up the hotel. Hopefully I’ll find enough time to get through another floor or two over the weekend, leaving me with just the finale to enjoy next week.
I’ve also been playing Animal Crossing: New Leaf for the first time (I know, sorry!) in preparation for the new game, but I’ve actually stopped playing over the last few days so that I don’t get burnt out from it. I think I’m pretty much sold on grabbing the new game in March after this short playthrough, so I’m now having to keep myself away from the thing I’ve just fell in love with to prepare. What a first-world problem, huh?
Gavin Lane, staff writer
With the return of Captain Picard to our TV screens after a 26-year hiatus, I’m rather excited to sit down for an hour and watch the first episode of Star Trek: Picard. Once that’s done and I’ve wiped the space dust from my eyes, I’ll probably be in the mood for some space-based gaming but, as discussed earlier this week, there really aren’t many games set in the Trek universe that measure up to the show itself – certainly not on Nintendo systems. With that in mind, I’ll probably get my space kicks from something like Everspace or perhaps I’ll make a start on that Starlink: Battle For Atlas pack I picked up for a tenner before Christmas.
If they don’t scratch the itch, I may fire up Catastronauts for some calamitous co-op fun. Overcooked 2 might have received an update this week, but you can’t run around a spaceship pretending you’re Geordi La Forge in that game, can you?
Gonçalo Lopes, contributing writer
SD Gundam G Generation Cross Rays is my equivalent to your Pokémon. I can’t stop playing or thinking about it every other minute and will continue to further develop my ever-growing army of SD metal monstrosities this weekend. On the other mech front, DAEMON X MACHINA continues to process smoothly yet I can hardly recognize my avatar any more due to extensive augmentation.
Could not resist so I already cleared the wonderful 198X last night and hope the second half of it manages to surpass these original five ‘retro’ games. Unexpected package from the East brought Super Robot Wars X along with an old favourite Ninja Jajamaru Collection and both will see some action this weekend for sure. Now, if only I could find some free time to use my Mario Kart Racing Wheel Pro Deluxe…
My game of the week is obviously Warhammer 40,000: Space Wolf because picking anything else would clearly be heresy. Remain vigilant, brothers.
As always, thanks for reading! Make sure to leave a vote in the poll above and a comment below with your gaming choices over the next few days…
Xbox Insider Release Notes – Alpha Skip Ahead Ring (2004.200116-0000)
Hey Alpha Skip-Ahead ring users! Today’s Xbox Insider Release Notes highlight the latest fixes, known issues, and features coming to your console. Starting at 2 p.m. PT today, users will receive the latest 2004 Xbox One system update (build: RS_XBOX_RELEASE_2004\19041.1410.200116-0000). Keep reading for more details.
System Update Details:
OS version released:RS_XBOX_RELEASE_2004\19041.1410.200116-0000
Available: 2 p.m. PT – January 17, 2020
Mandatory: 3 a.m. PT – January 18, 2020
Fixes for Alpha Skip-Ahead
We’ve heard your feedback, and we’re happy to announce the following fixes have been implemented for this 2004 build:
System
Various updates to properly reflect local languages across the console.
Known Issues for Alpha Skip Ahead
We understand some issues have been listed in previous Xbox Insider Release Notes. These issues aren’t being ignored, but it will take Xbox engineers more time to find a solution. We appreciate your patience at this time!
Audio
We’re aware of an issue where users who enable Dolby Atmos formats (Home theater or headphones) on their console may experience Netflix playback errors with Atmos enabled shows and movies.
Workaround: Disable Dolby Atmos in Settings while we fully diagnose and rectify the issue.
Users who have Dolby Atmos enabled and console display settings set to 120hz with 36 bits per pixel (12-bit) are experiencing loss of Dolby Atmos audio in some situations.
Workaround: Disable 120hz or set Video Fidelity to 30 bits per pixel (10-bit) or lower.
Home (Experiment)
Users may see the images for ads on the dashboard looking cropped or cutoff.
Messaging
Users are reporting being unable to send a voice messages while in Parties.
Workaround: Send the message while not currently in party chat.
My Games & Apps
Users’ tile size choices in collection will revert to large in some sections.
Some users have reported focus being lost while navigating collection.
Workaround: Navigate to Home, open the Guide, select the My Games & Apps tile, press the Menu button and select “Refresh.”
Attempting to navigate to Manage Contents in My Games & Apps may redirect back to collection in error.
Attempting to Hide/Unhide games/apps in collection via button combination not working.
The “Skip to Letter” menu UI does not display correctly. We are aware and working on the issue.
Settings
Some users have reported that 3D display mode is not working with supported content.
Profile Color
Sometimes users may encounter the incorrect Profile color when powering on the console.
Are you not seeing your issue listed above? Make sure to use Report a problem to keep us informed of your issue. We may not be able to respond to everyone, but the data we’ll gather is crucial to finding a resolution.
Learn more about feedback and how each ring is differentiated in the following links:
For more information regarding the Xbox Insider Program follow us on Twitter and join the community subreddit for support and updates. Keep an eye on future Xbox Insider Release Notes for more information regarding your Xbox One Update Preview ring!