-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This resolves #5132. The admin manual order cart is much more like th…
…e frontend now in that you start off by adding items to the cart(line items). You then add an address, the shipments are calculated based on the frontend rules you have set up but you as an admin can ignore those rules and muck with the shipments on the Shipments tab. You can also skip adding items to the cart altogether by just entering an address and then adding shipments manually, the way the old backend admin did before this patch. Extracting the advanceOrder function into a function in the Spree namespace so that both the shipmentsJS and line_itemsJS can share it Advancing the order after we add variants on the cart page. If we have already created shipments, then when we edit a line item the order gets reset to the address state. This call pushes it back to the payment state and destroys the old shipments, recreating them to match the new line item state. In checkout.rb we first create_proposed_shipments but here we check if addresses are valid. If not we need to destroy_all instead of delete_all so that the inventory_units that were created by create_propsed_shipments will also be destroyed and not clutter up the DB Fixing the Split tool. IF success we reload the page, else display a generic error. Would like to in the future provide more specific errors. Not allowing splits to the same shipment nor to a shipment or location that does not have the stock and is NOT backorderable. Next commit will have a boatload of automated tests. Adding appropriate tests for the splitting of shipments. Fixes #5166
- Loading branch information
Tyler Smart
authored and
Jeff Dutil
committed
Aug 14, 2014
1 parent
a9d3ad9
commit b252e9a
Showing
31 changed files
with
713 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
backend/app/assets/javascripts/spree/backend/line_items_on_order_edit.js.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// This file contains the code for interacting with line items in the manual cart | ||
$(document).ready(function () { | ||
'use strict'; | ||
|
||
// handle variant selection, show stock level. | ||
$('#add_line_item_variant_id').change(function(){ | ||
var variant_id = $(this).val(); | ||
|
||
var variant = _.find(window.variants, function(variant){ | ||
return variant.id == variant_id | ||
}) | ||
$('#stock_details').html(variantLineItemTemplate({variant: variant})); | ||
$('#stock_details').show(); | ||
|
||
$('button.add_variant').click(addVariant); | ||
|
||
// Add some tips | ||
$('.with-tip').powerTip({ | ||
smartPlacement: true, | ||
fadeInTime: 50, | ||
fadeOutTime: 50, | ||
intentPollInterval: 300 | ||
}); | ||
|
||
}); | ||
}); | ||
|
||
addVariant = function() { | ||
$('#stock_details').hide(); | ||
|
||
var variant_id = $('input.variant_autocomplete').val(); | ||
var quantity = $("input.quantity[data-variant-id='" + variant_id + "']").val(); | ||
|
||
adjustLineItems(order_number, variant_id, quantity); | ||
return 1 | ||
} | ||
|
||
adjustLineItems = function(order_number, variant_id, quantity){ | ||
var url = Spree.routes.orders_api + "/" + order_number + '/line_items'; | ||
|
||
$.ajax({ | ||
type: "POST", | ||
url: Spree.url(url), | ||
data: { line_item: {variant_id: variant_id, quantity: quantity }} | ||
}).done(function( msg ) { | ||
window.Spree.advanceOrder(); | ||
window.location.reload(); | ||
}); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
backend/app/views/spree/admin/orders/_add_line_item.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<%= render :partial => "spree/admin/variants/autocomplete", :formats => :js %> | ||
|
||
<%= render :partial => "spree/admin/variants/autocomplete_line_items_stock", :formats => :js %> | ||
|
||
|
||
<div id="add-line-item" data-hook> | ||
<fieldset class="no-border-bottom"> | ||
<legend align="center"><%= Spree.t(:add_product) %></legend> | ||
|
||
<div data-hook="add_product_name" class="field twelve columns alpha"> | ||
<%= label_tag :add_line_item_variant_id, Spree.t(:name_or_sku) %> | ||
<%= hidden_field_tag :add_line_item_variant_id, "", :class => "variant_autocomplete fullwidth" %> | ||
</div> | ||
|
||
</fieldset> | ||
|
||
<div id="stock_details"></div> | ||
</div> |
Oops, something went wrong.