Correct, it's a fairly basic usecase that you're trying to implement.
If you are trying to retrieve just one specific value, say Product Name, you can use just LookUp
function with the following script:
%%[
var @CustomerOrder, @Product
set @CustomerOrder = AttributeValue("OrderId")
set @Product = LookUp("ShoppingCart","Product Name","OrderId", @CustomerOrder)
]%%
This way you can use the variable %%=v(@Product)=%%
in your Email.
In case you want to retrieve multiple values like Product Name and Product Quantity, it's a bit trickier, as you will need to utilize LookUpRows
instead.
%%[
var @rows, @row, @rowCount, @i
set @CustomerOrder = AttributeValue("OrderId")
set @rows = LookupRows("ShoppingCart","OrderId", @CustomerOrder)
set @rowCount = rowcount(@rows)
IF @rowCount > 0 then
FOR @i = 1 to @rowCount DO
var @Product, @ProductQuantity
set @row = row(@rows, @i)
set @Product = field(@row,"Product Name")
set @ProductQuantity = field(@row,"Product Quantity")
ENDIF
]%%
This way you can grab as many attributes as necessary from your ShoppingCart DE and use them as personalization strings the same way, like %%=v(@ProductQuantity)=%%
In case you want to retrieve multiple Products for the same OrderID, do it like this:
%%[
var @rows, @row, @rowCount, @i
set @CustomerOrder = AttributeValue("OrderId")
set @rows = LookupRows("ShoppingCart","OrderId", @CustomerOrder)
set @rowCount = rowcount(@rows)
IF @rowCount > 0 then
FOR @i = 1 to @rowCount DO
var @Product, @ProductQuantity
set @row = row(@rows, @i)
set @Product = field(@row,"Product Name")
set @ProductQuantity = field(@row,"Product Quantity")
]%%
Product Name: %%=v(@Product)=%%
Product Quantity: %%=v(@ProductQuantity )=%%
%%[ NEXT @i ]%%
%%[ ELSE ]%%
No Products Found
%%[ ENDIF ]%%