Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Klaus Pedersen 15 posts 71 karma points
    Apr 02, 2013 @ 13:59
    Klaus Pedersen
    0

    Dynamic Price update

    Ive been trying to figure out a way to do a dynamic price update bases on a variant. For instance if i have a variant of a shirt in sizes s, m, l , xl.

    so i have a variant with an attribute size and a attribute price

    I've been trying with javascript but i cant seem to get it working.

     

    Anyone out there that has solved this before?

  • Morten Skjoldager 440 posts 1499 karma points
    Apr 03, 2013 @ 08:33
    Morten Skjoldager
    0

    Hi Klaus.

    Do you use the razor store? 

    The easy way would be to just output the price as value in your dropdown of shirt sizes and set the price after selected item. Another way is to fetch the specific values of your variant using service stack. You can specify your own callbacks and whatnot. It is pretty straight forward once you just take a look at how it's done in the razor store.  

  • Klaus Pedersen 15 posts 71 karma points
    Apr 03, 2013 @ 13:11
    Klaus Pedersen
    0

    Hey Morten

    Thanks for your reply

    I have looked at the razor store but i cant see its updating the price on the product page when i select a diffrent size. Just to clear it up, its not when adding it to basket that i got covered. its just that when i switch the parameters in the dropdowns i want it to update the price displayed on the product instant.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Apr 09, 2013 @ 12:54
    Søren Spelling Lund
    0

    Hi Klaus,

    You could output price information on initial page load and hide it using jQuery. Based on the selection in the drop down lists you could find the appropriate price already present in the DOM and display that.

    Alternatively you can hook into the webservice, which checks for valid variant combos and have that return the appropriate price as part of the JSON it produces.

    If you download the source for Avenue Clothing you'll find a method called GetProductVariationsResponse. It outputs information for each variant. It will be pretty easy to add price info to that output.

    Hope this helps.

  • Danny Summers 22 posts 82 karma points
    Jun 19, 2013 @ 09:26
    Danny Summers
    0

    Hey Søren,

    I have had a similar issue and have tried your suggestion above, but trying to get the variant price using the "varient.GetPrice" function seems to crash my development server (before I can even see an error).

    Do you have a suggested method for doing this?  Below is the code I've tried on GetVarientSkuFromSelection.cs in the source project:

    PriceGroup priceGroup = ProductCatalog.All().Single(x => x.Name == SiteContext.Current.CatalogContext.CurrentCatalog.Name).PriceGroup;

    Variant = new ProductVariation
    {
           Sku = variant.Sku,
           VariantSku = variant.VariantSku,
           ProductName = variant.Name,
           Price = variant.GetPrice(priceGroup),
           Properties = variant.ProductProperties.Select(prop => new ProductProperty
           {
               Id = prop.Id,
               Name = prop.ProductDefinitionField.Name,
               Value = prop.Value
           })
    };

    Here is the line I've added to the ProductVariation.cs model:
    public Money Price { get; set; }

    I have verified that my "priceGroup" variable is being loaded and has the correct information in it.  However, when I go to run GetPrice, it crashes out.

    Any ideas?

    Cheers,
    Danny 

  • Morten Skjoldager 440 posts 1499 karma points
    Jun 21, 2013 @ 14:12
    Morten Skjoldager
    0

    Hi Danny,

    Do you see anything in the UmbracoLog ? 

  • Morten Skjoldager 440 posts 1499 karma points
    Jun 21, 2013 @ 14:14
    Morten Skjoldager
    0

    Also, you could just use this single line of code to get the current catalog:

    SiteContext.Current.CatalogContext.CurrentCatalog 

     

    What you do is load every catalog from the database and the using single :) 

  • Danny Summers 22 posts 82 karma points
    Jun 24, 2013 @ 01:11
    Danny Summers
    0

    Hi Morten,

    Thank you for your help.  I have checked the UmbracoLog and the server seems to crash before anything can get written.

    I will have a play with that single line of code and see how I go.

    Thanks again,
    Danny 

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 24, 2013 @ 14:34
    Søren Spelling Lund
    0

    Hi Danny,

    Your variant probably doesn't have a price set up in the price group you're asking for. It will cause a NullReferenceException at the moment.

    I have updated the code base to return a null value instead to make it easier to work around.

    Sorry about the inconvenience.

  • Danny Summers 22 posts 82 karma points
    Jun 25, 2013 @ 05:26
    Danny Summers
    0

    Hi Søren,

    Thank you for the update.  Where can I download this update?  I can't see any commits regarding this in the Razor Store repo, or a new package release for uCommerce?

    Cheers,
    Danny 

Please Sign in or register to post replies

Write your reply to:

Draft