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

Fix - Product image not showing in the cart and wishlist #2137

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/User/components/Products/ProductDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ const ProductPage = () => {
try {
const response = await axios.get(`https://dummyjson.com/products/${productId}`);
const requiredProduct = response.data;
console.log(response.data)
requiredProduct.newPrice = getNewPrice(requiredProduct.discountPercentage, requiredProduct.price)
requiredProduct.image = requiredProduct.images[0] || requiredProduct.thumbnail
setProduct(requiredProduct);
} catch (error) {
console.error("Axios error:", error);
Expand Down
2 changes: 1 addition & 1 deletion src/User/pages/Order/Wishlist.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const WishlistItem = ({ product, onUpdate, onAddToCart, isExistsInTheCart }) =>
style={{ border: "1px solid black" }}>
<div className="flex items-center">
<img
src={product.thumbnail}
src={product.image}
alt={product.title}
className="w-32 h-32 md:w-20 md:h-20 rounded-lg mr-4"
/>
Expand Down
2 changes: 1 addition & 1 deletion src/User/redux/cartSlice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const cartSlice = createSlice({
oldPrice: product.price || product.oldPrice,
newPrice: product.newPrice,
total: newQuantity * product.newPrice,
image: product.thumbnail,
image: product.image,
}
: []
)
Expand Down