我正在使用地理编码器和设计宝石。我正在试着在用户的位置附近得到优惠券
优惠券模型
def index
if params[:search].present?
@coupons = Coupon.near([user_long, user_lat], 50, :order => :distance)
else
@coupons = Coupon.all
end
end
应用程序助手
我已经定义了user_long和user_lat
def user_long
current_user.longitude
end
de
我正在尝试创建优惠并将它们分配到父类别,更具体地说,我有一个优惠模型,在优惠模型中,我有这种多对多的关系 public function category() {
return $this->belongsToMany(Category::class);
} 我希望上面的函数只返回parent_category为空的类别,这意味着它们是父类别。上面的代码是可能的吗?
我需要计算的总金额,一辆车将花费与多个产品和优惠券。我需要得到这个总数,而不需要更改全局WC()->cart。因此,我的想法是创建一个临时购物车,添加所有项目和优惠券,然后返回WC_Cart:get_total();
这是我的密码:
//5438 is my product (simple subscription, $55 with a $50 signup fee)
//product_schedule_discount is the coupon code that removes 100% of the signup fee
$tmpCart = new WC_Cart();
我有一个优惠券模型,它与产品模型(有枢轴表等等)有很多关系。我创建了一些本地范围,以便只获得可用的优惠券,并且只获得确定类别的优惠券:
public function scopeAvailable($query)
{
return $query->where('available', '>', 0);
}
public function scopeOfCategory($query, $category)
{
return $query->join('categories', 'categories
让我们说,我们有很多很多关系的两种模式,优惠券和产品。
class Coupon extends \Eloquent {
protected $table = 'coupons';
public function products()
{
return $this->belongsToMany('Product');
}
}
和
class Product extends \Eloquent {
protected $table = 'products';
public fun
由于某些原因,magento网站不应用优惠券代码。它总是返回无效的:
优惠券代码无效
消息。然而,奇怪的是,当购物车的价格大于120我的货币时,就会发生这种情况。
如果购物车中有一种产品的价格为65,则优惠券代码工作正常,但如果购物车中有相同的产品,但使用qty 2(这意味着总价格为130),则会得到上述无效错误消息。
我已经将代码跟踪到Mage_Sales_Model_Quote class, which has a function named_validateCouponCode()`,在下面的代码中:
$address->hasCouponCode()
总是返回fals
假设我有两个模型,Coupon和UserRedemption (当然还有一个用户模型)。它们看起来像:
Coupon(models.Model):
offer = models.TextField() # not important to this task
limited_use = models.BooleanField(default=False)
max_uses = models.IntegerField(default=0)
UserRedemption(models.Model):
user = models.ForeignKey(setting
我正在尝试构建目标记录的编辑功能。在目标索引页面上,每个目标旁边都有一个编辑按钮。单击时,每个字段都变为可编辑状态。单击保存后,更改将保存到服务器。到目前一切尚好。
还有一个取消按钮。当用户单击它时,我需要将模型的状态重置为他们更改之前的状态。控制器中的goal.rollback()可以很好地完成这项工作。除非用户已经单击了Save,但服务器端验证失败。在这种情况下,尝试使用rollback()会抛出Uncaught Error: Attempted to handle event `reloadRecord` on <App.Goal:ember123:1234> while i