def add_product(basket, price=None, quantity=1, product=None):
 has_strategy = False
 try:
  has_strategy = hasattr(basket, 'strategy')
 except RuntimeError:
  pass
 if (not has_strategy):
  basket.strategy = Default()
 if (price is None):
  price = D('1')
 if (product and product.has_stockrecords):
  record = product.stockrecords.all()[0]
 else:
  record = factories.create_stockrecord(product=product, price_excl_tax=price, num_in_stock=(quantity + 1))
 basket.add_product(record.product, quantity)

def add_product ( basket , price = None , quantity = 1 , product = None ) : has_strategy = False try : has_strategy = hasattr ( basket , 'strategy' ) except RuntimeError : pass if ( not has_strategy ) : basket . strategy = Default ( ) if ( price is None ) : price = D ( '1' ) if ( product and product . has_stockrecords ) : record = product . stockrecords . all ( ) [ 0 ] else : record = factories . create_stockrecord ( product = product , price_excl_tax = price , num_in_stock = ( quantity + 1 ) ) basket . add_product ( record . product , quantity )
helper to add a product to the basket .