/** * Saves userdata from payment field * * @param Enlight_Event_EventArgs $piPaymorrowArgs Arguments */ function piPaymorrowSaveNewUserdata(Enlight_Event_EventArgs $piPaymorrowArgs) { $piPaymorrowView = $piPaymorrowArgs->getSubject()->View(); $piPaymorrowResponse = $piPaymorrowArgs->getSubject()->Response(); $piPaymorrowGetPost = $piPaymorrowArgs->getSubject()->Request()->getPost(); $piPaymorrowUserdata = array(); $piPaymorrowUserdata = $piPaymorrowArgs->getSubject()->View()->sUserData; $piPaymorrowInvoiceId = ""; $piPaymorrowBirthday = ""; if ($piPaymorrowGetPost['pi_Paymorrow_saveBirthday']) { $piPaymorrowInvoiceId = piPaymorrowGetInvoicePaymentId(); } else { $piPaymorrowInvoiceId = piPaymorrowGetRatePaymentId(); } if ($piPaymorrowGetPost['register']['personal']['phone']) { $sql = "UPDATE s_user_billingaddress SET phone= ? WHERE ID= ?"; Shopware()->Db()->query($sql, array($piPaymorrowGetPost['register']['personal']['phone'], (int)$piPaymorrowUserdata['billingaddress']['id'])); } if ($piPaymorrowGetPost['register']['personal']['birthday_rate']) { $piPaymorrowBirthday = $piPaymorrowGetPost['register']['personal']['birthyear_rate'] . "-" . $piPaymorrowGetPost['register']['personal']['birthmonth_rate'] . "-" . $piPaymorrowGetPost['register']['personal']['birthday_rate']; } else { $piPaymorrowBirthday = $piPaymorrowGetPost['register']['personal']['birthyear'] . "-" . $piPaymorrowGetPost['register']['personal']['birthmonth'] . "-" . $piPaymorrowGetPost['register']['personal']['birthday']; } if ($piPaymorrowUserdata["billingaddress"]["birthday"] == "0000-00-00") { $sql = "UPDATE s_user_billingaddress SET birthday= ? WHERE id= ?"; Shopware()->Db()->query($sql, array($piPaymorrowBirthday, (int)$piPaymorrowUserdata['billingaddress']['id'])); $piPaymorrowView->pi_Paymorrow_birthdayflag = true; } $sql = "SELECT birthday FROM s_user_billingaddress WHERE id= ?"; $piPaymorrowNewBirthday = Shopware()->Db()->fetchOne($sql, array((int)$piPaymorrowUserdata['billingaddress']['id'])); $sql = "SELECT phone FROM s_user_billingaddress WHERE id= ?"; $piPaymorrowNewphone = Shopware()->Db()->fetchOne($sql, array((int)$piPaymorrowUserdata['billingaddress']['id'])); if ($piPaymorrowNewBirthday != "0000-00-00" && $piPaymorrowNewphone && !$piPaymorrowUserdata["billingaddress"]["company"] && !$piPaymorrowUserdata["shippingaddress"]["company"] ) { $sql = "UPDATE s_user SET paymentID = ? WHERE id = ?"; Shopware()->Db()->query($sql, array((int)$piPaymorrowInvoiceId,(int)$piPaymorrowUserdata['billingaddress']['userID'])); } else { $piPaymorrowHeader = $piPaymorrowResponse->getHeaders(); $piPaymorrowUrl = $piPaymorrowHeader[1][value]; $piPaymorrowNewUrl = str_replace("/sViewport,account/success,payment", "/sViewport,account/sAction,payment", $piPaymorrowUrl); $piPaymorrowNewUrl = str_replace("/sViewport,checkout/success,payment", "/sViewport,account/sAction,payment/sTarget,checkout", $piPaymorrowNewUrl); $piPaymorrowResponse->setHeader('Location', $piPaymorrowNewUrl, 2); } }
/** * Plugin unistall method * * @return bool */ public function uninstall() { $piPaymorrowInvoicePaymentId = piPaymorrowGetInvoicePaymentId(); $piPaymorrowRatePaymentId = piPaymorrowGetRatePaymentId(); $sql = "DELETE FROM s_core_rulesets WHERE paymentID = ".(int)$piPaymorrowInvoicePaymentId." OR paymentID = ".(int)$piPaymorrowRatePaymentId.""; Shopware()->Db()->query($sql); $sql = "DELETE FROM s_core_paymentmeans WHERE name IN ('PaymorrowInvoice','PaymorrowRate')"; Shopware()->Db()->query($sql); $sql = "delete from s_core_subscribes where listener like '%PaymorrowPayment%'"; Shopware()->Db()->query($sql); $sql = "DELETE FROM s_core_states WHERE description like '%Paymorrow%'"; Shopware()->Db()->query($sql); $sql = "DELETE FROM s_crontab WHERE name like '%Paymorrow%'"; Shopware()->Db()->query($sql); $mypluginid = Shopware()->Db()->fetchOne("SELECT id FROM s_core_plugins WHERE name = 'PiPaymorrowPayment' "); $sql = "DELETE FROM s_core_plugin_elements WHERE pluginID = " . (int)$mypluginid . ""; Shopware()->Db()->query($sql); $sql = "DELETE FROM s_core_plugin_configs WHERE pluginID = " . (int)$mypluginid . ""; Shopware()->Db()->query($sql); $sql = "DELETE FROM s_core_documents_box WHERE name like '%Paymorrow%'"; Shopware()->Db()->query($sql); return true; }