I am able to get the cart price to change, and the subtotal to change... however, I want to change the actually price of the product itself, not just in the cart.
function sv_change_product_price_cart( $price, $cart_item, $cart_item_key ) {
if ( 5825 === $cart_item['product_id'] ) {
$price = '$ 1500.00';
}
return $price;
}
function sv_change_product_price_actual( $price, $product ) {
$product_id->get_id();
return $product_id;
if ( $product_id === 5825 ) {
$price = "$ 6000.00";
}
}
function filter_woocommerce_cart_product_subtotal( $product_subtotal, $product, $quantity, $instance ) {
$product_subtotal = $product->get_price() * $quantity;
return $product_subtotal;
};
function sv_change_product_price( $product, $price ) {
$product_id->get_id();
return $product_id;
if ($product_id == 5825) {
$product_price = ' $ 1500.00';
}
}
add_filter( 'woocommerce_cart_item_price', 'sv_change_product_price_cart', 10, 3 );
add_filter( 'woocommerce_cart_product_subtotal', 'filter_woocommerce_cart_product_subtotal', 10, 4 );
add_filter( 'woocommerce_product_price', 'sv_change_product_price_actual', 10, 3 );
Here's what I have already, and of course for testing purposes, the prices are hardcoded in.
Any thoughts or ideas?
Session Code Below (JavaScript):
function getColorOption() {
selectElement =
document.querySelector('#selectedColor');
outputColor = selectElement.value;
document.querySelector('.outputColor').textContent
= outputColor;
// Check browser support
if (typeof(Storage) !== "undefined") {
// Store
sessionStorage.setItem("hiddenColor", document.getElementById('selectedColor').value);
// Retrieve
document.getElementById("result2").innerHTML = sessionStorage.getItem("hiddenColor");
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Storage...";
}
};