How to import the rating feature into my app. #2470
Unanswered
captainwycliffe
asked this question in
Help
Replies: 1 comment
-
Hi @captainwycliffe the code you pasted in is very difficult to read. It might be easier to share a minimal repo that has the rating implemented. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi any developer, I'm trying to implement the rating feauture in my app but I don't know why it's not working?I am trying to import the rating from teh hydrogen store.Please some one help.This is the code for the products:
`*
import { Money } from "@shopify/hydrogen";
import { useVariantUrl } from '~/lib/variants';
import { Link, Form } from "@remix-run/react";
import { AddToCartButton } from "./CartButton";
import { type CSSProperties, useState } from "react";
import { motion } from "framer-motion";
export default function ProductItem({
product,
loading,
}: {
readonly product: any;
readonly loading?: 'eager' | 'lazy';
}) {
const variant: any = product.variants.nodes[0];
const variantUrl = useVariantUrl(product.handle, variant.selectedOptions);
const compareAtPrice = parseFloat(product.compareAtPriceRange?.minVariantPrice?.amount || '0');
const price = parseFloat(product.priceRange.minVariantPrice.amount);
const savings = compareAtPrice ? ((compareAtPrice - price) / compareAtPrice) * 100 : 0;
const isOnSale = compareAtPrice > price;
const onSale = compareAtPrice ? (compareAtPrice - price) : 0;
const currrency = product.compareAtPriceRange?.minVariantPrice?.currencyCode;
const onSaleMoney = {
currencyCode: currrency,
amount: onSale.toFixed(2)
}
const [isLikedHover, setIsLikedHover] = useState(false);
const [likedState, setLikedState] = useState(product.isLiked)
}
const saleIconStyle = {
position: "absolute",
top: "10px",
left: "10px",
backgroundColor: "red",
color: "white",
borderRadius: "5px",
padding: "2px 6px",
fontSize: "12px",
fontWeight: "bold",
zIndex: 1
};
const percentageSaleIconStyle = {
position: "absolute",
top: "10px",
right: "10px",
backgroundColor: "red",
color: "white",
borderRadius: "5px",
padding: "2px 6px",
fontSize: "12px",
fontWeight: "bold",
zIndex: 1
};
`*
I have attached the hydrogen store picture here.Please note this is the whole code,
Beta Was this translation helpful? Give feedback.
All reactions