I have made a custom theme on big cartel, and everything is perfect, except one thing.
I would like to have the cart update without going to the cart page when adding an item to your cart.
I have made my custom template over the "sexy" theme and have no idea how I go about implanting this
I know this can be done, because default themes like "Good Vibes" do this.
You can use the code below. I didn't include the code for the restoreButton function in the addItem callback but I'm sure you get the idea. You'll also need your own means of retrieving the product ID based on however you're displaying your product options. Make sure to also include a reference to Big Cartel's javascript api.
$('#add_to_bag').click(function(evt){
var productId;
if($('.options_select').length != 0)
productId = $( ".options_select option:selected" ).attr('value');
else
productId = $('.price_options input').attr('value');
var quantity = $('.quantity input').attr('value');
Cart.addItem(productId, quantity, function(cart) {
$('#add_to_bag').attr('value', 'Item Added');
setTimeout(restoreButton, 2000);
});
});
You'll want to take advantage of the javascript API: https://help.bigcartel.com/developers/themes/#javascript-api
With this, you can drop in the line of code to load the API into your theme and have access to add, update, and remove items from the cart using javascript.
Related
So I'm using Wix to create a ecommerce store, however the standard store isn't flexible enough for me.
I have a dynamic product page and I want to access product quantity in stock with code in order to show whether the product is in stock or not.
I fount this in the documentation (Link)
$w('#myProductPage').getProduct()
.then( (product) => {
let productName = product.name;
let productDescription = product.description;
// see example product object below
} )
.catch( (error) => {
console.log(error);
} );
The only thing is that I don't know whats the page name with what i have to replace '#myProductPage'.
As far as I understand it I have to replace it with my slug product page name however I don't know where I could see it - it should be named products-2 but that doesn't work, it shows an error that the name is not a valid selector.
I haven't found basically any example codes for Wix Corvid and that's why I'm reaaally struggling with such a small thing.
With $w(), you want to pass in the page element's ID -> $w('#elementID')
The element ID can be found in the property pane on the page. Select the page element, right click > View Properties. This will give you the ID you want to pass in to the function. Think of it like a document.getElementById() function replacement.
I am using some simple jquery to show view cart button if something has been added to the cart.
if ( $('.cartSummaryItem').text() != 'Shopping cart is empty.' ) {
$('.account').fadeIn(1000)
};
If the cart is empty it show this the text "Shopping cart is empty.", if something is added .account will fadeIn. The problem is I need to refresh the page for this to work, is there a way to do this without refreshing the page with ajax or similar?
Thanks
Nik
If the change event doesn't work. Another method is using an Interval.
<script type='text/javascript'>
$(document).ready(function()
{
setInterval(function () {
if ( $('.cartSummaryItem').text() != 'Shopping cart is empty.' ) {
$('.account').fadeIn(1000)
};
}, 10000);
});
</script>
Ofcourse, the interval should be changed to your desired amount. I would only use this if the change doesn't work.. The change event is prefered.
Well, I guess you have two choices
Call the javascript code after the user has changed the contents of the cart
Poll the server for cart changes
If you can, you should probably go for the first choice. Are you in control of the code that changes the contents of the cart?
I am sure there will be articles around this but I really don't know the correct name for it and having little success finding examples like mine.
I have a quote form where you have the ability to select a product and atributes of it. There are three dropdowns and based on the combination of the three, I have a table (with associated model/controller) that has a price. I want to display the price on the page but i must update as the selections are updated.
Setting the price from the get go seemed easy but then updating it based on dropdowns selected had me go in a tail spin of '"onSelectedIndexChanged()', javascript, AJAX, partial views and I simply confused myself.
I need a simple way to display price information on a quote form as they fill out the details (three fields control price). I did look at the music store demo but its slightly different and the shopping cart element which looked handy was grabbing data in a table so again got stuck.
Help always appreciated as ever.
Thanks,
Steve.
When one of the three dropdowns changes, I'd make an AJAX call to the server to get the price as a JSON object and use it to update the price input.
Example using jQuery to add the handlers and perform the AJAX operation.
var $priceControls = $('#control1,#control2,#control2');
$priceControls.change( function() {
$.getJSON( '#Url.Action("price","product")',
$priceControls.serialize(),
function(price) {
$('#price').val(price);
});
});
public class ProductController : Controller
{
public ActionResult Price( string control1, string control2, string control3 )
{
decimal price = ...lookup price based on control values...
return Json( price, JsonRequestBehavior.AllowGet );
}
}
i need to customize function opConfig.reloadPrice(); in magento.
can anyone tell me where is that function locate?
This function is executed on custom attribute drop down on product details page.
As i need to change the Special price calculation , i guess need to customize this function .
This method can be found in following files:
grep 'reloadPrice:' . -rsn
./js/varien/configurable.js:271: reloadPrice: function()
./js/varien/product.js:463: reloadPrice: function()
./skin/frontend/base/default/js/bundle.js:83: reloadPrice: function()
For change custom option value, you should change in to js/varient/product.js
and in that page you found, reload:function()
that function call at the time of on change event.
Good Luck
I also had the issue of having to change the default behaviour of Magento on this one. I included jQuery in my project and I finaly figured it out by first removing the default behavior of Magento and instead on calculatePrice call my calculatePrices()-function:
$j('#select_20, #select_21').removeAttr('onchange').change(function(){
calculatePrices();
});
Now, in this calculatePrices()-function, alongside with some other logic, I included this to change the prices:
function calculatePrices()
{
var price = 0;
// some logic with custom options, not interesting for this question...
// Change the price according to the options:
$j('#select_20, #select_21').each(function(){
var selectId = this.id.replace('select_', '');
var options = opConfig.config[selectId][this.value];
if(options.type == 'fixed') {
price += options.priceValue;
} else {
// percentual change:
price += price * (options.priceValue/100);
}
});
// Use Magento Objects to set these prices:
optionsPrice.changePrice('bundle', price);
optionsPrice.reload();
}
Please help me if anybody know how this work can be done.
I want to hide the website tab in catalog Product, but its functionality should exist. That is, I have made all the check boxes automatically checked,so i dont want to show this tab anybody...but at the time of adding product..check boxes values would be saved.
Not exactly sure how you would do this, but basically you need to bind an Observer in the adminhtml render sequence that calls Mage_Adminhtml_Block_Widget_Tabs::removeTab($tabId) where $tabId is the Id of the websites tab (I think it's just "websites"). The trick is to find the right event to bind your Observer to, #Joseph's list of events should get you started. I would try something like adminhtml_block_html_before.
Your observer would also set the values on the product at the same time.
Good luck,
JD
In ProductController.php
Websites
*/
if (!isset($productData['website_ids'])) {
$productData['website_ids'] = array();
}
$productData['website_ids']=$this->getStoreWebsiteId(); //newly added
//newly added
public function getStoreWebsiteId(){
$selectWebsite="SELECT * from core_website WHERE website_id!=0";
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$value=$connection->fetchAll($selectWebsite);
foreach($value as $websiteDetails){
$websiteId[]=$websiteDetails['website_id'];
}
return $websiteId;
}