Regarding the product price that goes into the cart along with the product - opencart

In backend admin panel following these steps: Catalog -> Products -> (I select the product I need) -> Edit -> Special. I insert the special price I want and it displays in Frond End in the product page. The Price which is in Data appears as CUT and the price I inserted in Special appears uncut. For example: [strike] 100.00[/strike] 90.00. My main question is: When I click Add to cart in the product page I want the the main price to go in the cart not the Special one. The client wants to see the special price but the price that goes into the cart to be the main price.
Many thanks

Special Price is actually the discounted price of a product. So, if a product is of 100 then we can sell it for 90 on some festival seasons. That's when you should use special price. Regarding your specific requirement, you should either flip the values entered in special and base price (But the special price will now have strikethrough) OR you need to alter the code.

Related

OpenCart 3 - Show all products in a category from a manufacturer by direct URL

[ Using Opencart 3.x]
I'm trying to make a link in the main menu to list products from a manufacturer that belong to a certain category.
Because i couln't find anything manufacturer related in the category controller, i tried to do it by also creating a category for each manufacturer like the text below, and then combining them into a link.
Manufacturers
Sony:
manufacturer_id = 13
manufacturer_category_id = 58
LG
manufacturer_id = 14
manufacturer_category_id = 59
Product category
tv_category_id = 60
The link i tried:
/index.php?route=product/category&path=59_60
But when i do this i get all the TV's from Sony, but also all the TV's from LG in the list.
Is there a way to do this right, so only all Sony TV's will be in the result?
There is no standard controller to make a link manufacturer && category. You don't need to create category for each manufacturer.
But! There is a way using standard OC3 filters.
Catalog - Filters. Here we creating filter, Filter Group Name "Manufacturer". Filter Values - "Manufacturer 1", "Manufacturer 2", ...(all your manufacturers). Save.
Catalog - Categories. Edit your category, which you would like to connect to manufacturer, i will call it "Your category". On the Data tab find Filters. Here, by entering first letters, select all filters ("Manufacturers" in your case), which you would line to link to this category. Save.
Extensions - Extensions - Modules. Find Filter, click Install, then Edit. On a filter module page set status "Enabled". Save.
Design - Layout. Find layout Category, click Edit. Add module Filter anywhere you want (for instance, under Category in Column left). Save.
Catalog - Product. Edit all product from a category you are working with. Editing the product, on the Links tab find Filters. Here, by entering first letters, select all one filter ("Manufacturer 1" in your case), which you would line to link to this product. Save.
That's all, go to "Your category" on the client side. There you will see a Refine Search module with the list of manufacturers. Check one of the manufacturers, click Refine Search. You will see the list on a products in "Your category" filtered by "Manufacturer 1". The URL is /index.php?route=product/category&path=58&filter=1. It's not a strict constant, if you adding new filters - order can be changed. But you can use it as a menu item link. Try. This should work.
Or you can use some other filter from Opencart Marketplace which can generate filtered pages with constant URL.

Opencart - Calculate price by option field value

I looked everywhere.
I have Opencart 2.0.2.0. Some of my products are vegetable. So for them I want to insert 1kg price and give an input field for customers to enter the weight they are after. So 1kg is $29 and if the customer enters "271"g, the price should be "(29/1000)*271 = $7.85. Do you know the easiest way to implement this and pass this dynamic price?
Thanks heaps.
This OpenCart extension should be able to do it.

Inventory design management - FIFO / Weighted Average design which also needs historical inventory value

I have a database with the following details:
Product
Name
SKU
UOM (There is a UOM master, so all purchase and sales are converted to base uom and stored in the db)
Some other details
has_attribute
has_batch
Attributes
Name
Details/Remarks
Product-Attribute
Product (FK)
Attribute(FK)
Value of attribute
Inventory Details
#This is added for every product lot bought & quantity available is updated after every sale
Product (FK)
Warehouse (FK to warehoue model)
Purchase Date
Purchase Price
MRP
Tentative sales price
Quantity_bought
Quantity_available
Other batch details if applicable(batch id, manufactured_date, expiry_date)
Inventory Ledger
#This table records all in & out movement of inventory
Product
Warehouse (FK to warehoue model)
Transaction Type (Purchase/Sales)
Quantity_transacted(i.e. quantity purchased/sold)
Inventory_Purchase_cost(So as to calculate inventory valuation)
Now, my problem is:
I need to find out the historical inventory cost. For example, let's say I need to find out the value of inventory on 10th Feb 2017, what I'll be doing with the current table is not very efficient: I'll find out current inventory and go back through the ledger for all 1000-1500 SKU and about 100 transactions daily (for each sku) for more than 120 days and come to a value. taht's about 1500*100*120. It's Huge. Is there a better DB design to handle this case?
Firstly, have you tested it? 1500*100*120 is not that huge. It may be acceptable performance and there is no problem to be solved!
I'm not 100% clear how you compute the value. Do you sum up the InventoryLedger rows for each Product in each Warehouse? Is so, it's easy to put a value on the purchases, but how do you value the sales? I'm going to assume that you value the sales using the Inventory_Purchase_Cost (so it should maybe be called TransactionValue instead).
If you must optimise it, I suggest you could populate a record each day for the valuation of the product in each warehouse. I suggest the following StockValution table could be populated daily and this would allow quick computation of the valuations for any historical day.
Diagram made using QuickDBD, where I work.

How to create custom shipping costs - Spree

What I have is a website which has multiple different user roles. Normally there is just admin and user. I have multiple for different users (retail, trade etc).
What the client is wanting, is that each product has a seperate shipping cost. The actual costs differ for users (so trade shipping might be $8 where retail would be $10). If multiple products are selected, there will be 100% shipping on the first product, and 50% for each additional product. This price differs based on the customers shipping location. It also differs based on what category the item is (eg. They have a seats category and a fish box category. The seats category might be $15 and the fish box might be $17.
The way I'm thinking is that each category has its own shipping category and then the shipping methods are just the locations. This would work fine but the tricky part is how to adjust this based on what user is logged in. The prices I have been given are consistent with the difference between retail shipping and trade shipping (Trade shipping is always 80% of retail shipping).
Basically, what would be great is if I could find out where the shipping calculation is done. That way I can test if the user is a trade customer and change the value to actually be value * .80, else the value is normal.
If any of you could spare the time to help me out with this I would be most appreciative.
Basically, what would be great is if I could find out where the
shipping calculation is done.
Calculations are done in Spree::Calculator::Shipping classes (FlatRate, 'PerItem`, etc.) - check the source.
You probably want custom calculator (or decorate existing method), so add file in models/spree/calculator/shipping/my_custom_method.rb:
module Spree
module Calculator::Shipping
class MyCustomMethod < ShippingCalculator
preference :amount, :decimal, default: 0
preference :something_i_need, :string, default: :foo #and so on, those preferences will be ready to set/change in admin panel
def self.description
Spree.t(:my_custom_method) # just a label
end
# here is where magic happens
def compute_package(package)
package.order.shipment_total
end
end
end
end
As you can see method compute_package is being called on package object which has several useful methods (source) but you can call directly package.order to get all line_items, shipments, order's user and all things you need to calculate valid amount.
If you want to create new method don't forget to register it so it will appear in admin panel so you can change settings - of course you can do that programatically if you want:
initializers/shipping_methods.rb:
Rails.application.config.spree.calculators.shipping_methods << Spree::Calculator::Shipping::MyCustomMethod
Ok this is what I have so far.
In app/models/spree/calculator/shipping/per_item.rb
(Spree standard model which I copied from \vendor\bundle\ruby\1.9.1\gems\spree_core-2.4.7\app\models\spree\calculator\shipping\per_item.rb)
require_dependency spree/shipping_calculator
module Spree
module Calculator::Shipping
class PerItem < ShippingCalculator
preference :amount, :decimal, default: 0
preference :currency, :string, default: ->{ Spree::Config[:currency] }
def self.description
Spree.t(:shipping_flat_rate_per_item)
end
def compute_package(package)
if package.contents.sum(&:quantity) > 1
compute_from_multiple(package.contents.sum(&:quantity))
else
compute_from_single(package.contents.sum(&:quantity))
end
end
def compute_from_multiple(quantity)
(self.preferred_amount / 2) + ((self.preferred_amount * quantity) / 2
end
def compute_from_single(quantity)
self.preferred_amount * quantity
end
end
This will test the number of items in the cart and if there are more than 1, it will give one item 100% shipping and the rest 50%.
What I now can't figure out is how to access the current user.
eg.
if current_spree_user.has_spree_role?("admin")
(self.preferred_amount / 2) + ((self.preferred_amount * quantity) / 2)
else
((self.preferred_amount / 2) + ((self.preferred_amount * quantity) / 2)) * 0.87
end
This gives an error:
undefined local variable or method `spree_current_user'
Does anyone know how to check for the current user in a model???

Opencart - Product specific text after price ( /square meter; /piece; etc.)

As I stated in the title I'd like to have a custom text field next to the price. For example I'd like to sell a bag of X by the bag (/bag) but another product is sold by /kg or /sqmeter). Now I only have the price on the product page.
Link to my webpage:
http://www.gerocskeramia.hu/webshop/
Use either the Options if this is something that needs price adjustments, or you could also use Attributes to add simple attributes like container type etc.